forked from SiGe/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (75 loc) · 1.99 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
OSCFLAGS=
OSLDFLAGS=
ifeq ($(OS),Windows_NT)
exit -1
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSCFLAGS+=-pthread
OSLDFLAGS+=-pthread
endif
ifeq ($(UNAME_S),Darwin)
OSCFLAGS+=-pthread
endif
endif
BUILD_DIR = build
BIN_DIR = bin
TARGET = main
#BINARY = netre-debug
BINARY = netre
#CC ?= gcc
CC ?= clang
STD=gnu11
#OPT = -O0 -pg -g
#OPT = -O3 -pg -g
OPT = -O3
SRC:=$(filter-out src/traffic_compressor.c src/main.c src/test.c, \
$(wildcard src/*.c src/*/*.c src/*/*/*.c lib/*/*.c src/algo/nauty.h src/algo/nausparse.h src/algo/nauty.a))
MAIN_SRC:=$(SRC)
MAIN_SRC+=src/main.c
MAIN_OBJ=$(MAIN_SRC:%.c=$(BUILD_DIR)/%.o)
TRAFFIC_COMPRESSOR_SRC:=$(SRC)
TRAFFIC_COMPRESSOR_SRC+=src/traffic_compressor.c
TRAFFIC_COMPRESSOR_OBJ=$(TRAFFIC_COMPRESSOR_SRC:%.c=$(BUILD_DIR)/%.o)
TEST_SRC:=$(SRC)
TEST_SRC+=src/test.c
TEST_OBJ=$(TEST_SRC:%.c=$(BUILD_DIR)/%.o)
ifeq (test, $(firstword $(MAKECMDGOALS)))
OPT = -O0 -pg -g
endif
CFLAGS=$(OPT) $(DEFINE) -Wall \
-pedantic -Wsign-conversion\
-Wno-unused-function\
-Iinclude/ -std=$(STD) -Ilib/ \
-fms-extensions \
-mtune=native $(OSCFLAGS)
LDFLAGS=-lm $(OPT) $(DEFINE) -Wall\
-pedantic -Wsign-conversion\
-Wno-unused-function -Wno-nested-anon-types -Wno-keyword-macro\
-Iinclude/ -Ilib/ -std=$(STD) -flto \
-mtune=native $(OSLDFLAGS)
ifeq (gcc, $(CC))
LDFLAGS += -pthread
else ifeq (clang, $(CC))
CFLAGS += -Wno-nested-anon-types -Wno-keyword-macro -Wno-microsoft-anon-tag
endif
all: $(TARGET)
$(BUILD_DIR)/%.o: %.c
@>&2 echo Compiling $<
@mkdir -p $(@D)
@$(CC) $(CFLAGS) $(EXTRA) $(CPPFLAGS) -c -o $@ $<
$(TARGET): $(MAIN_OBJ)
@>&2 echo Building $(BINARY)
@mkdir -p $(BIN_DIR)
@$(CC) -o $(BIN_DIR)/$(BINARY) $^ $(LDFLAGS)
test: $(TEST_OBJ)
@>&2 echo Building $@
@mkdir -p $(BIN_DIR)
@$(CC) -o $(BIN_DIR)/$@ $^ $(LDFLAGS)
traffic_compressor: $(TRAFFIC_COMPRESSOR_OBJ)
@>&2 echo Building $@
@mkdir -p $(BIN_DIR)
@$(CC) -o $(BIN_DIR)/$@ $^ $(LDFLAGS)
.PHONY: clean
clean:
rm -fr $(BUILD_DIR)/*