]> ruderich.org/simon Gitweb - nsscash/nsscash.git/blob - nss/Makefile
7dfe54738cf998245b2ca8ab5c61769e715dacff
[nsscash/nsscash.git] / nss / Makefile
1 # Compiler flags
2 LDLIBS  = -pthread
3 CFLAGS  = -Wall -Wextra -Wconversion
4 # DEB_BUILD_MAINT_OPTIONS='hardening=+all qa=+bug' dpkg-buildflags --export=make
5 CFLAGS   += -g -O2 -Werror=array-bounds -Werror=clobbered -Werror=volatile-register-var -Werror=implicit-function-declaration -fstack-protector-strong -Wformat -Werror=format-security
6 CPPFLAGS += -Wdate-time -D_FORTIFY_SOURCE=2
7 LDFLAGS  += -Wl,-z,relro -Wl,-z,now
8 # For tests
9 TEST_CFLAGS  += -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined
10 TEST_LDFLAGS += -fsanitize=address -fsanitize=undefined
11
12 all: libnss_cash.so.2
13
14 clean:
15         rm -f libnss_cash.so.2 \
16             tests/libcash_test.so tests/gr tests/pw \
17             tests/group.nsscash tests/passwd.nsscash
18
19 libnss_cash.so.2 tests/libcash_test.so: $(wildcard *.c) $(wildcard *.h)
20         $(CC) -o $@ -shared -fPIC -Wl,-soname,$@ \
21                 $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \
22                 file.c gr.c pw.c search.c \
23                 $(LDLIBS)
24
25
26 # Tests
27
28 test: tests/gr tests/pw tests/group.nsscash tests/passwd.nsscash
29         LD_LIBRARY_PATH=./tests LD_PRELOAD= ./tests/gr
30         LD_LIBRARY_PATH=./tests LD_PRELOAD= ./tests/pw
31
32 tests/%: tests/%.c tests/libcash_test.so
33         $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \
34                 $(TEST_CFLAGS) $(TEST_LDFLAGS) -Ltests \
35                 $< $(LDLIBS) -lcash_test -lasan
36
37 tests/passwd.nsscash: tests/passwd
38         ../nsscash convert passwd $< $@
39 tests/group.nsscash: tests/group
40         ../nsscash convert group $< $@
41
42 tests/libcash_test.so: CFLAGS += $(TEST_CFLAGS)
43 tests/libcash_test.so: CPPFLAGS += -DNSSCASH_GROUP_FILE='"./tests/group.nsscash"' \
44                                    -DNSSCASH_PASSWD_FILE='"./tests/passwd.nsscash"'
45 tests/libcash_test.so: LDFLAGS += $(TEST_LDFLAGS)
46
47 .PHONY: all clean test