881cabfa4b518455f902932f62436ca85dd3afcf
[kopensolaris-gnu/glibc.git] / nss / db-Makefile
1 DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
2                        /etc/rpc /etc/services /etc/shadow)
3
4 VAR_DB = /var/db
5
6 AWK = awk
7 MAKEDB = makedb --quiet
8
9 all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
10
11
12 $(VAR_DB)/passwd.db: /etc/passwd
13         @echo -n "$(patsubst %.db,%,$(@F))... "
14         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
15                  /^[^#]/ { printf ".%s ", $$1; print; \
16                            printf "=%s ", $$3; print }' $^ | \
17         $(MAKEDB) -o $@ -
18         @echo "done."
19
20 $(VAR_DB)/group.db: /etc/group
21         @echo -n "$(patsubst %.db,%,$(@F))... "
22         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
23                  /^[^#]/ { printf ".%s ", $$1; print; \
24                            printf "=%s ", $$3; print }' $^ | \
25         $(MAKEDB) -o $@ -
26         @echo "done."
27
28 $(VAR_DB)/ethers.db: /etc/ethers
29         @echo -n "$(patsubst %.db,%,$(@F))... "
30         @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
31                            printf "=%s ", $$2; print }' $^ | \
32         $(MAKEDB) -o $@ -
33         @echo "done."
34
35 $(VAR_DB)/protocols.db: /etc/protocols
36         @echo -n "$(patsubst %.db,%,$(@F))... "
37         @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
38                            printf "=%s ", $$2; print; \
39                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
40                              { printf ".%s ", $$i; print } }' $^ | \
41         $(MAKEDB) -o $@ -
42         @echo "done."
43
44 $(VAR_DB)/rpc.db: /etc/rpc
45         @echo -n "$(patsubst %.db,%,$(@F))... "
46         @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
47                            printf "=%s ", $$2; print; \
48                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
49                              { printf ".%s ", $$i; print } }' $^ | \
50         $(MAKEDB) -o $@ -
51         @echo "done."
52
53 $(VAR_DB)/services.db: /etc/services
54         @echo -n "$(patsubst %.db,%,$(@F))... "
55         @$(AWK) 'BEGIN { FS="[ \t/]+" } \
56                  /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
57                            printf "=%s/%s ", $$2, $$3; print; \
58                            for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
59                              { printf ".%s/%s ", $$i, $$3; print } }' $^ | \
60         $(MAKEDB) -o $@ -
61         @echo "done."
62
63 $(VAR_DB)/shadow.db: /etc/shadow
64         @echo -n "$(patsubst %.db,%,$(@F))... "
65         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
66                  /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
67         $(MAKEDB) -o $@ -
68         @echo "done."