File: Makefile

package info (click to toggle)
libnss-cache 0.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212 kB
  • sloc: ansic: 1,701; makefile: 137; sh: 38
file content (148 lines) | stat: -rw-r--r-- 5,390 bytes parent folder | download
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
CC ?= gcc
CFLAGS ?= -Wall -Wstrict-prototypes
CFLAGS += -fPIC
LIBRARY=libnss_cache.so.2
PREFIX=$(DESTDIR)/usr
LIBDIR=$(PREFIX)/lib
TESTDATA=.testdata

LIBNSSCACHE = nss_cache.o compat/getpwent_r.o compat/getgrent_r.o

SOURCES = Makefile gen_getent.c lookup.c nss_cache.c nss_cache.h nss_test.h COPYING version libnss-cache.spec
VERSION = $(shell git describe --tags --always | sed -E 's@.*/([^-]*).*@\1@')

GETENT_DATA_TOUCH = $(TESTDATA)/.touch.getent_data
LOOKUP_DATA_TOUCH = $(TESTDATA)/.touch.lookup_data
INDEX_DATA_TOUCH = $(TESTDATA)/.touch.index_data

.PHONY: all
all: $(LIBRARY)

.PHONY: test check
test check: CFLAGS += -O0 -g --coverage
test check: LDFLAGS += --coverage
test check: test_getent time_lookups

lookup: lookup.o $(LIBNSSCACHE)

.PHONY: time_lookups
time_lookups: lookup_data index_data lookup
	@echo Linear username lookups
	rm -f $(TESTDATA)/passwd.cache.ixname
	time -f %E ./lookup -c getpwnam -f $(TESTDATA)/rand_pwnames
	@echo Binary username lookups
	ln -sf passwd_cache_ixname_disabled $(TESTDATA)/passwd.cache.ixname
	time -f %E ./lookup -c getpwnam -f $(TESTDATA)/rand_pwnames
	@echo Linear UID lookups
	rm -f $(TESTDATA)/passwd.cache.ixuid
	time -f %E ./lookup -c getpwuid -f $(TESTDATA)/rand_pwuids
	@echo Binary UID lookups
	ln -sf passwd_cache_ixuid_disabled $(TESTDATA)/passwd.cache.ixuid
	time -f %E ./lookup -c getpwuid -f $(TESTDATA)/rand_pwuids
	@echo Linear groupname lookups
	rm -f $(TESTDATA)/group.cache.ixname
	time -f %E ./lookup -c getgrnam -f $(TESTDATA)/rand_grnames
	@echo Binary groupname lookups
	ln -sf group_cache_ixname_disabled $(TESTDATA)/group.cache.ixname
	time -f %E ./lookup -c getgrnam -f $(TESTDATA)/rand_grnames
	@echo Linear GID lookups
	rm -f $(TESTDATA)/group.cache.ixgid
	time -f %E ./lookup -c getgrgid -f $(TESTDATA)/rand_grgids
	@echo Binary GID lookups
	ln -sf group_cache_ixuid_disabled $(TESTDATA)/group.cache.ixuid
	time -f %E ./lookup -c getgrgid -f $(TESTDATA)/rand_grgids
	@echo Linear shadow lookups
	rm -f $(TESTDATA)/shadow.cache.ixname
	time -f %E ./lookup -c getspnam -f $(TESTDATA)/rand_spnames
	@echo Binary shadow lookups
	ln -sf shadow_cache_ixname_disabled $(TESTDATA)/shadow.cache.ixname
	time -f %E ./lookup -c getspnam -f $(TESTDATA)/rand_spnames
	@echo Linear gshadow lookups
	rm -f $(TESTDATA)/gshadow.cache.ixname
	time -f %E ./lookup -c getsgnam -f $(TESTDATA)/rand_sgnames
	@echo Binary gshadow lookups
	ln -sf gshadow_cache_ixname_disabled $(TESTDATA)/gshadow.cache.ixname
	time -f %E ./lookup -c getsgnam -f $(TESTDATA)/rand_sgnames
	gcov --all-blocks --branch-probabilities --branch-counts --function-summaries --unconditional-branches ./lookup

gen_getent: gen_getent.o $(LIBNSSCACHE)


.PHONY: test_getent
test_getent: getent_data gen_getent nss_cache.c
	./gen_getent
	diff $(TESTDATA)/passwd.cache $(TESTDATA)/passwd.cache.out
	diff $(TESTDATA)/group.cache $(TESTDATA)/group.cache.out
	diff $(TESTDATA)/shadow.cache $(TESTDATA)/shadow.cache.out
	diff $(TESTDATA)/gshadow.cache $(TESTDATA)/gshadow.cache.out
	gcov --all-blocks --branch-probabilities --branch-counts --function-summaries --unconditional-branches ./gen_getent


.PHONY: index_data
index_data: $(INDEX_DATA_TOUCH)

$(INDEX_DATA_TOUCH): $(LOOKUP_DATA_TOUCH)
	./scripts/index.sh $(TESTDATA)/passwd.cache  1 $(TESTDATA)/passwd_cache_ixname_disabled
	./scripts/index.sh $(TESTDATA)/passwd.cache  3 $(TESTDATA)/passwd_cache_ixuid_disabled
	./scripts/index.sh $(TESTDATA)/group.cache   1 $(TESTDATA)/group_cache_ixname_disabled
	./scripts/index.sh $(TESTDATA)/group.cache   3 $(TESTDATA)/group_cache_ixgid_disabled
	./scripts/index.sh $(TESTDATA)/shadow.cache  1 $(TESTDATA)/shadow_cache_ixname_disabled
	./scripts/index.sh $(TESTDATA)/gshadow.cache 1 $(TESTDATA)/gshadow_cache_ixname_disabled

.PHONY: lookup_data
lookup_data: $(LOOKUP_DATA_TOUCH)

$(LOOKUP_DATA_TOUCH): $(GETENT_DATA_TOUCH)
	cut -d : -f 1 $(TESTDATA)/passwd.cache |\
	  sort -R | head -500 > $(TESTDATA)/rand_pwnames
	cut -d : -f 3 $(TESTDATA)/passwd.cache |\
	  sort -R | head -500 > $(TESTDATA)/rand_pwuids
	cut -d : -f 1 $(TESTDATA)/group.cache |\
	  sort -R | head -500 > $(TESTDATA)/rand_grnames
	cut -d : -f 3 $(TESTDATA)/group.cache |\
	  sort -R | head -500 > $(TESTDATA)/rand_grgids
	cut -d : -f 1 $(TESTDATA)/shadow.cache |\
	  sort -R | head -500 > $(TESTDATA)/rand_spnames
	cut -d : -f 1 $(TESTDATA)/gshadow.cache |\
	  sort -R | head -500 > $(TESTDATA)/rand_sgnames
	touch $@

.PHONY: getent_data
getent_data: $(GETENT_DATA_TOUCH)

$(GETENT_DATA_TOUCH): scripts/gentestdata.sh
	mkdir -p $(TESTDATA)
	./scripts/gentestdata.sh $(TESTDATA)
	touch $@

last_pw_errno_test: test/last_pw_errno_test.c

$(LIBRARY): LDFLAGS += -shared
$(LIBRARY): $(LIBNSSCACHE)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(LIBRARY) $+

.PHONY: install
install: $(LIBRARY)
	install -d $(LIBDIR)
	install $(LIBRARY) $(LIBDIR)

.PHONY: clean
clean:
	rm -f $(LIBRARY) *.o compat/*.o *.gcov *.gcda *.gcno compat/*.gcda compat/*.gcno lookup gen_getent last_pw_errno_test

.PHONY: veryclean
veryclean: clean
	rm -rf $(TESTDATA)

.PHONY: distclean
distclean: veryclean
	rm -f *~ \#*

.PHONY: dist
dist:
	rm -rf libnss-cache-$(VERSION) libnss-cache-$(VERSION).tar libnss-cache-$(VERSION).tar.gz
	mkdir libnss-cache-$(VERSION)
	cp $(SOURCES) libnss-cache-$(VERSION)
	tar cf libnss-cache-$(VERSION).tar libnss-cache-$(VERSION)
	gzip -9 libnss-cache-$(VERSION).tar
	rm -rf libnss-cache-$(VERSION)