2017-02-17 14:57:32 +00:00
|
|
|
.PHONY: all static clean test
|
|
|
|
|
2017-04-16 19:24:01 +00:00
|
|
|
PROG=xmppipe
|
2015-05-11 19:19:35 +00:00
|
|
|
RM=rm
|
|
|
|
|
2015-07-01 13:12:16 +00:00
|
|
|
UNAME_SYS := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_SYS), Linux)
|
2017-11-02 14:19:19 +00:00
|
|
|
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
|
|
|
|
-Wformat -Werror=format-security \
|
2018-12-30 12:57:52 +00:00
|
|
|
-pie -fPIE \
|
2017-04-23 13:55:09 +00:00
|
|
|
-fno-strict-aliasing
|
2017-08-25 14:47:57 +00:00
|
|
|
XMPPIPE_SANDBOX ?= seccomp
|
2017-02-01 15:25:38 +00:00
|
|
|
XMPPIPE_SANDBOX_RLIMIT_NOFILE ?= 0
|
2018-12-30 12:57:52 +00:00
|
|
|
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
|
2017-02-04 14:00:49 +00:00
|
|
|
else ifeq ($(UNAME_SYS), FreeBSD)
|
2017-05-18 13:55:45 +00:00
|
|
|
CFLAGS ?= -DHAVE_STRTONUM \
|
2017-11-02 14:19:19 +00:00
|
|
|
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
|
|
|
|
-Wformat -Werror=format-security \
|
2018-12-30 12:57:52 +00:00
|
|
|
-pie -fPIE \
|
2017-04-23 13:55:09 +00:00
|
|
|
-fno-strict-aliasing
|
2017-08-25 14:47:57 +00:00
|
|
|
XMPPIPE_SANDBOX ?= capsicum
|
2018-12-30 12:57:52 +00:00
|
|
|
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
|
2017-01-30 15:17:54 +00:00
|
|
|
else ifeq ($(UNAME_SYS), OpenBSD)
|
2017-05-18 13:55:45 +00:00
|
|
|
CFLAGS ?= -DHAVE_STRTONUM \
|
2017-11-02 14:19:19 +00:00
|
|
|
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
|
|
|
|
-Wformat -Werror=format-security \
|
2018-12-30 12:57:52 +00:00
|
|
|
-pie -fPIE \
|
2017-04-23 13:55:09 +00:00
|
|
|
-fno-strict-aliasing
|
2017-08-25 14:47:57 +00:00
|
|
|
XMPPIPE_SANDBOX ?= pledge
|
2018-12-30 12:57:52 +00:00
|
|
|
LDFLAGS ?= -Wl,-z,relro,-z,now -Wl,-z,noexecstack
|
2015-07-01 13:12:16 +00:00
|
|
|
else ifeq ($(UNAME_SYS), SunOS)
|
|
|
|
else ifeq ($(UNAME_SYS), Darwin)
|
2018-04-13 11:32:46 +00:00
|
|
|
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong \
|
|
|
|
-Wformat -Werror=format-security \
|
2018-12-30 12:57:52 +00:00
|
|
|
-pie -fPIE \
|
2018-04-13 11:32:46 +00:00
|
|
|
-fno-strict-aliasing
|
2015-07-01 13:12:16 +00:00
|
|
|
endif
|
|
|
|
|
2017-08-25 14:47:57 +00:00
|
|
|
XMPPIPE_SANDBOX ?= rlimit
|
2017-02-01 15:25:38 +00:00
|
|
|
XMPPIPE_SANDBOX_RLIMIT_NOFILE ?= -1
|
2017-04-26 11:23:55 +00:00
|
|
|
|
|
|
|
XMPPIPE_CFLAGS ?= -g -Wall
|
|
|
|
CFLAGS += $(XMPPIPE_CFLAGS) \
|
2017-10-26 14:56:51 +00:00
|
|
|
-fwrapv \
|
2017-08-25 14:47:57 +00:00
|
|
|
-DXMPPIPE_SANDBOX=\"$(XMPPIPE_SANDBOX)\" \
|
|
|
|
-DXMPPIPE_SANDBOX_$(XMPPIPE_SANDBOX) \
|
2017-02-03 14:47:12 +00:00
|
|
|
-DXMPPIPE_SANDBOX_RLIMIT_NOFILE=$(XMPPIPE_SANDBOX_RLIMIT_NOFILE)
|
2017-01-29 14:13:18 +00:00
|
|
|
|
2017-12-07 14:57:43 +00:00
|
|
|
LDFLAGS += $(XMPPIPE_LDFLAGS)
|
2017-04-26 11:23:55 +00:00
|
|
|
|
2017-04-16 19:24:01 +00:00
|
|
|
all: $(PROG)
|
|
|
|
|
|
|
|
$(PROG):
|
2017-04-26 11:23:55 +00:00
|
|
|
$(CC) $(CFLAGS) -o xmppipe src/*.c $(LDFLAGS) -lstrophe
|
2015-05-25 14:20:04 +00:00
|
|
|
|
|
|
|
static:
|
2019-01-09 15:20:23 +00:00
|
|
|
$(CC) $(CFLAGS) \
|
|
|
|
-no-pie -fno-PIE \
|
|
|
|
$(XMPPIPE_CFLAGS) \
|
|
|
|
-o xmppipe src/*.c -Wl,--no-as-needed \
|
2017-12-07 14:57:43 +00:00
|
|
|
$(LDFLAGS) -ldl -lz -lresolv \
|
2017-10-31 14:09:01 +00:00
|
|
|
-l:libstrophe.a \
|
|
|
|
-l:libssl.a -l:libcrypto.a \
|
|
|
|
-l:libexpat.a
|
2015-05-11 19:19:35 +00:00
|
|
|
|
|
|
|
clean:
|
2017-04-16 19:24:01 +00:00
|
|
|
-@$(RM) $(PROG)
|
2017-02-17 14:57:32 +00:00
|
|
|
|
2017-04-16 19:24:01 +00:00
|
|
|
test: $(PROG)
|
2017-02-18 14:56:22 +00:00
|
|
|
-@PATH=.:$$PATH bats test
|