-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
62 lines (47 loc) · 2.27 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
DEBUG_PRINT?=0
RELEASE?=0
PROJ_DIR:=.
YAMC_FILES=$(wildcard $(PROJ_DIR)/yamc/*.c)
CFLAGS:=-std=gnu11 -Wall -Wextra -Wpedantic -I$(PROJ_DIR)/yamc
LDFLAGS:=-lrt -lpthread -lyamc -L$(PROJ_DIR)
CFLAGS_DEBUG:=-Og -ggdb
CFLAGS_RELEASE:=-O3
CFLAGS_DEBUG_PRINT:=-DYAMC_DEBUG=1
ifeq ($(RELEASE),0)
CFLAGS+=$(CFLAGS_DEBUG)
else
CFLAGS+=$(CFLAGS_RELEASE)
endif
ifeq ($(DEBUG_PRINT),1)
CFLAGS+=$(CFLAGS_DEBUG_PRINT)
endif
.PHONY: all clean dist-clean
all: libyamc.a examples
libyamc.a: CFLAGS += -I$(PROJ_DIR)/wrappers
libyamc.a: $(YAMC_FILES:.c=.o) $(PROJ_DIR)/wrappers/yamc_net_core.o
$(AR) -rcs $@ $^
wrappers: CFLAGS += -I$(PROJ_DIR)/wrappers
wrappers: yamc_socket yamc_stdin
yamc_socket: libyamc.a $(PROJ_DIR)/wrappers/yamc_net_core.o $(PROJ_DIR)/wrappers/yamc_runner_socket.o $(PROJ_DIR)/wrappers/yamc_debug_pkt_handler.o
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
yamc_stdin: libyamc.a $(PROJ_DIR)/wrappers/yamc_runner_stdin.o $(PROJ_DIR)/wrappers/yamc_fuzzing_pkt_handler.o
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
examples: CFLAGS += -I$(PROJ_DIR)/examples -I$(PROJ_DIR)/wrappers
examples: yamc_pub yamc_sub
#command line parsers are generated by gengetopt
$(PROJ_DIR)/examples/yamc_pub_cmdline.c: $(PROJ_DIR)/examples/yamc_pub.ggo
@which gengetopt > /dev/null 2>&1 || (echo "Please install gengetopt package i.e.: sudo apt install gengetopt"; exit 1)
gengetopt -i $(PROJ_DIR)/examples/yamc_pub.ggo --output-dir=$(PROJ_DIR)/examples
$(PROJ_DIR)/examples/yamc_sub_cmdline.c: $(PROJ_DIR)/examples/yamc_sub.ggo
@which gengetopt > /dev/null 2>&1 || (echo "Please install gengetopt package i.e.: sudo apt install gengetopt"; exit 1)
gengetopt -i $(PROJ_DIR)/examples/yamc_sub.ggo --output-dir=$(PROJ_DIR)/examples
yamc_pub: $(PROJ_DIR)/examples/yamc_pub_cmdline.o libyamc.a $(PROJ_DIR)/wrappers/yamc_net_core.o $(PROJ_DIR)/examples/yamc_pub.o
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
yamc_sub: $(PROJ_DIR)/examples/yamc_sub_cmdline.o libyamc.a $(PROJ_DIR)/wrappers/yamc_net_core.o $(PROJ_DIR)/examples/yamc_sub.o
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
#leaves auto generated cmdline parsers alone
clean:
rm -f yamc_pub yamc_sub yamc_socket yamc_stdin libyamc.a $(YAMC_FILES:.c=.o) $(PROJ_DIR)/wrappers/*.o $(PROJ_DIR)/examples/*.o
#deletes auto generated stuff
dist-clean: clean
rm -f $(PROJ_DIR)/examples/*_cmdline.[ch]