-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
72 lines (62 loc) · 1.9 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
.PHONY: all static clean test
PROG=xmppipe
RM=rm
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Linux)
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-Wshadow \
-Wpointer-arith -Wcast-qual \
-Wstrict-prototypes -Wmissing-prototypes \
-pie -fPIE \
-fno-strict-aliasing
RESTRICT_PROCESS ?= seccomp
RESTRICT_PROCESS_RLIMIT_NOFILE ?= 0
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
else ifeq ($(UNAME_SYS), FreeBSD)
CFLAGS ?= -DHAVE_STRTONUM \
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-pie -fPIE \
-fno-strict-aliasing
RESTRICT_PROCESS ?= capsicum
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
else ifeq ($(UNAME_SYS), OpenBSD)
CFLAGS ?= -DHAVE_STRTONUM \
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-pie -fPIE \
-fno-strict-aliasing
RESTRICT_PROCESS ?= pledge
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
else ifeq ($(UNAME_SYS), Darwin)
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
-Wformat -Werror=format-security \
-pie -fPIE \
-fno-strict-aliasing
endif
RESTRICT_PROCESS ?= rlimit
RESTRICT_PROCESS_RLIMIT_NOFILE ?= -1
XMPPIPE_CFLAGS ?= -g -Wall
CFLAGS += $(XMPPIPE_CFLAGS) \
-Wextra -Wno-unused-parameter \
-fwrapv \
-DRESTRICT_PROCESS=\"$(RESTRICT_PROCESS)\" \
-DRESTRICT_PROCESS_$(RESTRICT_PROCESS) \
-DRESTRICT_PROCESS_RLIMIT_NOFILE=$(RESTRICT_PROCESS_RLIMIT_NOFILE)
LDFLAGS += $(XMPPIPE_LDFLAGS)
all: $(PROG)
$(PROG):
$(CC) $(CFLAGS) -o xmppipe src/*.c $(LDFLAGS) -lstrophe
static:
$(CC) $(CFLAGS) \
$(XMPPIPE_CFLAGS) \
-o xmppipe src/*.c -Wl,--no-as-needed \
$(LDFLAGS) -ldl -lpthread -lz -lresolv \
-l:libstrophe.a \
-l:libssl.a -l:libcrypto.a \
-l:libexpat.a
clean:
-@$(RM) $(PROG)
test: $(PROG)
-@PATH=.:$$PATH bats test