about summary refs log tree commit diff
path: root/nss/db-Makefile
blob: 983a36fb59f695fb53172472956374d0520cc660 (plain) (blame)
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
DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
		       /etc/rpc /etc/services /etc/shadow /etc/netgroup)

VAR_DB = /var/db

AWK = awk
MAKEDB = makedb --quiet

all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))


$(VAR_DB)/passwd.db: /etc/passwd
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { printf ".%s ", $$1; print; \
			   if (!uids[$$3]++) \
			     { printf "=%s ", $$3; print } }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

$(VAR_DB)/group.db: /etc/group
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { printf ".%s ", $$1; print; \
			   printf "=%s ", $$3; print }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

$(VAR_DB)/ethers.db: /etc/ethers
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { printf ".%s ", $$1; print; \
			   printf "=%s ", $$2; print }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

$(VAR_DB)/protocols.db: /etc/protocols
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { printf ".%s ", $$1; print; \
			   printf "=%s ", $$2; print; \
			   for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
			     { printf ".%s ", $$i; print } }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

$(VAR_DB)/rpc.db: /etc/rpc
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { printf ".%s ", $$1; print; \
			   printf "=%s ", $$2; print; \
			   for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
			     { printf ".%s ", $$i; print } }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

$(VAR_DB)/services.db: /etc/services
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
			   printf "=%s/%s ", $$2, $$3; print; \
			   for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
			     { printf ".%s/%s ", $$i, $$3; print } }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

$(VAR_DB)/shadow.db: /etc/shadow
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

$(VAR_DB)/netgroup.db: /etc/netgroup
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) 'BEGIN { cnt=0 } \
		 { printf "0%u ", cnt++; print } \
		 /^[^#]/ { end=sub(/\\/, " "); \
			   gsub(/[ \t]+/, " "); \
			   if(end == 1) printf "%s", $$0; else print }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."