summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile72
1 files changed, 72 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e2ef40e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,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 $@
+