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
9 TEST_CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined
10 TEST_LDFLAGS += -fsanitize=address -fsanitize=undefined
15 rm -f libnss_cash.so.2 \
16 tests/libcash_test.so tests/gr tests/pw \
17 tests/group.nsscash tests/passwd.nsscash
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 \
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
32 tests/%: tests/%.c tests/libcash_test.so
33 $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \
34 $(TEST_CFLAGS) $(TEST_LDFLAGS) -Ltests \
35 $< $(LDLIBS) -lcash_test
37 tests/passwd.nsscash: tests/passwd
38 ../nsscash convert passwd $< $@
39 tests/group.nsscash: tests/group
40 ../nsscash convert group $< $@
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)
47 .PHONY: all clean test