-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (42 loc) · 1.48 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
.PHONY: all clean test
PROG= hexlog
SRCS= hexlog.c \
waitfor.c \
restrict_process_capsicum.c \
restrict_process_null.c \
restrict_process_pledge.c \
restrict_process_rlimit.c \
restrict_process_seccomp.c
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Linux)
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-fno-strict-aliasing
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
RESTRICT_PROCESS ?= seccomp
else ifeq ($(UNAME_SYS), OpenBSD)
CFLAGS ?= -DHAVE_STRTONUM \
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-fno-strict-aliasing
LDFLAGS ?= -Wno-missing-braces -Wl,-z,relro,-z,now -Wl,-z,noexecstack
RESTRICT_PROCESS ?= pledge
else ifeq ($(UNAME_SYS), FreeBSD)
CFLAGS ?= -DHAVE_STRTONUM \
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-fno-strict-aliasing
LDFLAGS ?= -Wno-missing-braces -Wl,-z,relro,-z,now -Wl,-z,noexecstack
RESTRICT_PROCESS ?= capsicum
endif
CFLAGS += -g -Wall -Wextra -fwrapv -pedantic -pie -fPIE $(HEXLOG_CFLAGS)
LDFLAGS += $(HEXLOG_LDFLAGS)
RESTRICT_PROCESS ?= rlimit
all:
$(CC) $(CFLAGS) \
-DRESTRICT_PROCESS=\"$(RESTRICT_PROCESS)\" -DRESTRICT_PROCESS_$(RESTRICT_PROCESS) \
-o $(PROG) $(SRCS) $(LDFLAGS)
clean:
-@rm $(PROG)
test: $(PROG)
@PATH=.:$(PATH) bats test