update from main archive 961016
[glibc.git] / nss / db-Makefile
blob756f4c6ce60adf67ad11b3e158018ab482f01f03
1 DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
2                        /etc/rpc /etc/services /etc/shadow /etc/netgroup)
4 VAR_DB = /var/db
6 AWK = awk
7 MAKEDB = makedb --quiet
9 all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
12 $(VAR_DB)/passwd.db: /etc/passwd
13         @echo -n "$(patsubst %.db,%,$(@F))... "
14         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
15                  /^[^#]/ { printf ".%s ", $$1; print; \
16                            if (!uids[$$3]++) \
17                              { printf "=%s ", $$3; print } }' $^ | \
18         $(MAKEDB) -o $@ -
19         @echo "done."
21 $(VAR_DB)/group.db: /etc/group
22         @echo -n "$(patsubst %.db,%,$(@F))... "
23         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
24                  /^[^#]/ { printf ".%s ", $$1; print; \
25                            printf "=%s ", $$3; print }' $^ | \
26         $(MAKEDB) -o $@ -
27         @echo "done."
29 $(VAR_DB)/ethers.db: /etc/ethers
30         @echo -n "$(patsubst %.db,%,$(@F))... "
31         @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
32                            printf "=%s ", $$2; print }' $^ | \
33         $(MAKEDB) -o $@ -
34         @echo "done."
36 $(VAR_DB)/protocols.db: /etc/protocols
37         @echo -n "$(patsubst %.db,%,$(@F))... "
38         @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
39                            printf "=%s ", $$2; print; \
40                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
41                              { printf ".%s ", $$i; print } }' $^ | \
42         $(MAKEDB) -o $@ -
43         @echo "done."
45 $(VAR_DB)/rpc.db: /etc/rpc
46         @echo -n "$(patsubst %.db,%,$(@F))... "
47         @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
48                            printf "=%s ", $$2; print; \
49                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
50                              { printf ".%s ", $$i; print } }' $^ | \
51         $(MAKEDB) -o $@ -
52         @echo "done."
54 $(VAR_DB)/services.db: /etc/services
55         @echo -n "$(patsubst %.db,%,$(@F))... "
56         @$(AWK) 'BEGIN { FS="[ \t/]+" } \
57                  /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
58                            printf "=%s/%s ", $$2, $$3; print; \
59                            for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
60                              { printf ".%s/%s ", $$i, $$3; print } }' $^ | \
61         $(MAKEDB) -o $@ -
62         @echo "done."
64 $(VAR_DB)/shadow.db: /etc/shadow
65         @echo -n "$(patsubst %.db,%,$(@F))... "
66         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
67                  /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
68         $(MAKEDB) -o $@ -
69         @echo "done."
71 $(VAR_DB)/netgroup.db: /etc/netgroup
72         @echo -n "$(patsubst %.db,%,$(@F))... "
73         @$(AWK) '/^[^#]/ { end=sub(/\\/, " "); \
74                            gsub(/[ \t]+/, " "); \
75                            if(end == 1) printf "%s", $$0; else print }' $^ | \
76         $(MAKEDB) -o $@ -
77         @echo "done."