update from main archive 961116
[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 /etc/netgroup)
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=":"; cnt=0 } \
15                  { printf "0%u ", cnt++; print } \
16                  /^[^#]/ { printf ".%s ", $$1; print; \
17                            if (!uids[$$3]++) \
18                              { printf "=%s ", $$3; print } }' $^ | \
19         $(MAKEDB) -o $@ -
20         @echo "done."
21
22 $(VAR_DB)/group.db: /etc/group
23         @echo -n "$(patsubst %.db,%,$(@F))... "
24         @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
25                  { printf "0%u ", cnt++; print } \
26                  /^[^#]/ { printf ".%s ", $$1; print; \
27                            printf "=%s ", $$3; print }' $^ | \
28         $(MAKEDB) -o $@ -
29         @echo "done."
30
31 $(VAR_DB)/ethers.db: /etc/ethers
32         @echo -n "$(patsubst %.db,%,$(@F))... "
33         @$(AWK) 'BEGIN { cnt=0 } \
34                  { printf "0%u ", cnt++; print } \
35                  /^[^#]/ { printf ".%s ", $$1; print; \
36                            printf "=%s ", $$2; print }' $^ | \
37         $(MAKEDB) -o $@ -
38         @echo "done."
39
40 $(VAR_DB)/protocols.db: /etc/protocols
41         @echo -n "$(patsubst %.db,%,$(@F))... "
42         @$(AWK) 'BEGIN { cnt=0 } \
43                  { printf "0%u ", cnt++; print } \
44                  /^[^#]/ { printf ".%s ", $$1; print; \
45                            printf "=%s ", $$2; print; \
46                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
47                              { printf ".%s ", $$i; print } }' $^ | \
48         $(MAKEDB) -o $@ -
49         @echo "done."
50
51 $(VAR_DB)/rpc.db: /etc/rpc
52         @echo -n "$(patsubst %.db,%,$(@F))... "
53         @$(AWK) 'BEGIN { cnt=0 } \
54                  { printf "0%u ", cnt++; print } \
55                  /^[^#]/ { printf ".%s ", $$1; print; \
56                            printf "=%s ", $$2; print; \
57                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
58                              { printf ".%s ", $$i; print } }' $^ | \
59         $(MAKEDB) -o $@ -
60         @echo "done."
61
62 $(VAR_DB)/services.db: /etc/services
63         @echo -n "$(patsubst %.db,%,$(@F))... "
64         @$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
65                  { printf "0%u ", cnt++; print } \
66                  /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
67                            printf "=%s/%s ", $$2, $$3; print; \
68                            for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
69                              { printf ".%s/%s ", $$i, $$3; print } }' $^ | \
70         $(MAKEDB) -o $@ -
71         @echo "done."
72
73 $(VAR_DB)/shadow.db: /etc/shadow
74         @echo -n "$(patsubst %.db,%,$(@F))... "
75         @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
76                  { printf "0%u ", cnt++; print } \
77                  /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
78         $(MAKEDB) -o $@ -
79         @echo "done."
80
81 $(VAR_DB)/netgroup.db: /etc/netgroup
82         @echo -n "$(patsubst %.db,%,$(@F))... "
83         @$(AWK) 'BEGIN { cnt=0 } \
84                  { printf "0%u ", cnt++; print } \
85                  /^[^#]/ { end=sub(/\\/, " "); \
86                            gsub(/[ \t]+/, " "); \
87                            if(end == 1) printf "%s", $$0; else print }' $^ | \
88         $(MAKEDB) -o $@ -
89         @echo "done."