-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
74 lines (63 loc) · 2.21 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
# $OpenBSD: Makefile,v 1.7 2016/03/30 06:38:46 jmc Exp $
.PHONY: all clean test doc
PROG= trep
SRCS= binary.c file.c grep.c mmfile.c queue.c util.c \
strtonum.c reallocarray.c fgetln.c fts.c \
restrict_process_null.c \
restrict_process_pledge.c \
restrict_process_seccomp.c \
restrict_process_capsicum.c \
restrict_process_rlimit.c
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Linux)
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-DHAVE_QUEUE -DHAVE_FTS \
-Wformat -Werror=format-security \
-pie -fPIE \
-fno-strict-aliasing
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
RESTRICT_PROCESS ?= seccomp
else ifeq ($(UNAME_SYS), OpenBSD)
CFLAGS ?= -DHAVE_STRTONUM -DHAVE_REALLOCARRAY -DHAVE_FGETLN \
-DHAVE_QUEUE -DHAVE_FTS \
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-pie -fPIE \
-fno-strict-aliasing
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
RESTRICT_PROCESS ?= pledge
else ifeq ($(UNAME_SYS), FreeBSD)
CFLAGS ?= -DHAVE_STRTONUM -DHAVE_REALLOCARRAY -DHAVE_FGETLN \
-DHAVE_QUEUE -DHAVE_FTS \
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-pie -fPIE \
-fno-strict-aliasing
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
RESTRICT_PROCESS ?= capsicum
else ifeq ($(UNAME_SYS), Darwin)
CFLAGS ?= -DHAVE_FGETLN \
-DHAVE_QUEUE -DHAVE_FTS \
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-pie -fPIE \
-fno-strict-aliasing
RESTRICT_PROCESS_RLIMIT_NOFILE ?= 4
endif
RESTRICT_PROCESS ?= rlimit
RESTRICT_PROCESS_RLIMIT_NOFILE ?= 0
TREP_CFLAGS ?= -g -Wall -Wextra -Wno-sign-compare -Wno-implicit-fallthrough -fwrapv
CFLAGS += $(TREP_CFLAGS) \
-DRESTRICT_PROCESS=\"$(RESTRICT_PROCESS)\" -DRESTRICT_PROCESS_$(RESTRICT_PROCESS) \
-DRESTRICT_PROCESS_RLIMIT_NOFILE=$(RESTRICT_PROCESS_RLIMIT_NOFILE)
LDFLAGS += $(TREP_LDFLAGS)
all: $(PROG)
$(PROG):
$(CC) -DNOZ $(CFLAGS) -o $(PROG) $(SRCS) $(LDFLAGS)
clean:
-@$(RM) trep
test: $(PROG)
@PATH=.:$(PATH) bats test
doc:
groff -mandoc -Thtml trep.1 > trep.1.html
pandoc -t markdown_github -o README.md trep.1.html