]> ruderich.org/simon Gitweb - nsscash/nsscash.git/blob - nss/Makefile
0ce909345aec31410edd330806f82cea50d8c325
[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             libcash_test.so tests/pw tests/passwd.nsscash
17
18 libnss_cash.so.2 libcash_test.so: $(wildcard *.c) $(wildcard *.h)
19         $(CC) -o $@ -shared -fPIC -Wl,-soname,$@ \
20                 $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \
21                 file.c pw.c search.c \
22                 $(LDLIBS)
23
24
25 # Tests
26
27 test: tests/pw tests/passwd.nsscash
28         LD_LIBRARY_PATH=. LD_PRELOD= ./tests/pw
29
30 tests/pw: tests/pw.c libcash_test.so
31         $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \
32                 $(TEST_CFLAGS) $(TEST_LDFLAGS) -L. \
33                 $< $(LDLIBS) -lcash_test -lasan
34
35 tests/passwd.nsscash: tests/passwd
36         ../nsscash convert passwd $< $@
37
38 libcash_test.so: CFLAGS += $(TEST_CFLAGS)
39 libcash_test.so: CPPFLAGS += -DNSSCASH_PASSWD_FILE='"./tests/passwd.nsscash"'
40 libcash_test.so: LDFLAGS += $(TEST_LDFLAGS)
41
42 .PHONY: all clean test