-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
91 lines (66 loc) · 1.87 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
export CC=gcc
export CFLAGS=-Wall -Wextra -Wno-unused-parameter -O2
export LDFLAGS=
export THREAD_LIB=-lpthread
export MODULES = print
ENABLED_MODULES = print
MODULES_CFG =
MODULES_DIR = modules
OBJS=cscan.o hardcoded.o socket_list.o queue.o utils.o socket_utils.o rand.o target.o log.o cba.o
TARGETS=cscan
ifneq ($(MUSL),)
CC = musl-gcc
CFLAGS += -static
LDFLAGS += -static
TARGETS += strip
endif
ifneq ($(METRICS),)
OBJS += metrics.o
CFLAGS += -DMETRICS
endif
ifneq ($(DEBUG),)
CFLAGS += -ggdb
LDFLAGS += -ggdb
endif
ifneq ($(GPROF),)
CFLAGS += -pg -no-pie
LDFLAGS += -pg -no-pie
endif
all: $(TARGETS)
MODULE_LIB = $(MODULES_DIR)/modules.a
$(MODULE_LIB): $(OBJS) $(MODULES_DIR)
$(MAKE) -C $(MODULES_DIR)
cscan: $(OBJS) $(MODULE_LIB)
$(CC) $(LDFLAGS) $(OBJS) $(MODULE_LIB) $(THREAD_LIB) -o $@
target_gen_test: rand_for_test.o target.o target_gen_test.o utils.o
$(CC) $(LDFLAGS) $^ -o $@
queue_test: queue.o queue_test.o
$(CC) $(LDFLAGS) $(THREAD_LIB) $^ -o $@
socket_list_test: socket_list.o socket_list_test.o
$(CC) $(LDFLAGS) $^ -o $@
cba_tester: cba.o cba_tester.o socket_utils.o utils.o
$(CC) $(LDFLAGS) $^ -o $@
cscan.o: cscan.c
$(CC) $(CFLAGS) -DENABLED_MODULES='"''$(ENABLED_MODULES)''"' -DMODULES_CFG='"''$(MODULES_CFG)''"' -c $< -o $@
socket_utils.o: socket_utils.c socket_utils.h
utils.o: utils.c utils.h
rand_for_test.o: rand_for_test.c rand.h
target.o: target.c target.h
target_gen_test.o: target_gen_test.c
queue_test.o: queue_test.c
queue.o: queue.c queue.h
socket_list.o: socket_list.c socket_list.h
metrics.o: metrics.c metrics.h
cba.o: cba.c cba.h
modules_test:
$(MAKE) -C $(MODULES_DIR) test
TEST_PROGS = target_gen_test queue_test socket_list_test cba_tester modules_test
test: $(TEST_PROGS)
strip: cscan
strip $<
clean:
rm -f *.o
rm -f cscan
rm -f $(TEST_PROGS)
make -C $(MODULES_DIR) clean
.PHONY: clean strip test $(MODULES_DIR) modules_test