blob: e2ef40e75dc470e8ed323c0f4e2f3978a2de7d00 (
plain)
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
|
ifeq ($(LLVM),1)
CC = clang
else
CC = gcc
endif
CFLAGS = \
-O2 \
-std=c2x \
-Wall \
-Wextra \
-Werror
LDFLAGS = -pthread -lrt
ifeq ($(DEBUG),1)
CFLAGS += -g -fsanitize=address,leak,undefined
#,memory
else
CFLAGS += -flto
LDFLAGS += -flto
endif
ifeq ($(SECURITY),1)
CFLAGS += \
-fwrapv -fwrapv-pointer \
-fno-strict-aliasing \
-fno-delete-null-pointer-checks \
-D_FORTIFY_SOURCE=2 \
-fstack-protector-strong \
-fPIE -fPIC -fpic \
-fno-builtin-fprintf -fno-builtin-fwprintf \
-fno-builtin-printf -fno-builtin-snprintf \
-fno-builtin-sprintf -fno-builtin-swprintf \
-fno-builtin-wprintf \
-fno-builtin-memcpy -fno-builtin-memmove \
-fno-builtin-memset -fno-builtin-strcat \
-fno-builtin-strcpy -fno-builtin-strncat \
-fno-builtin-strncpy -fno-builtin-wcscat \
-fno-builtin-scwcpy -fno-builtin-wcsncat \
-fno-builtin-wcsncpy -fno-builtin-wmemcpy \
-fno-builtin-wmemmove -fno-builtin-wmemset \
-Wclobbered \
-Warray-bounds \
-Wdiv-by-zero \
-Wshift-count-negative -Wshift-count-overflow \
-fstack-protector
endif
.PHONY: all clean controller worker test analyze
all: build/controller build/worker
clean:
@rm -rf build
controller: build/controller
worker: build/worker
build/%.o: %.c
@mkdir -p $(@D)
@$(CC) $(CFLAGS) -c $^ -o $@
build/%: %.c build/lib.o
@mkdir -p $(@D)
@$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
build/lib.o: $(patsubst %.c,build/%.o,$(shell find lib -type f -name '*.c' -print))
@mkdir -p $(@D)
@ld -r $^ -o $@
|