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

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=":" } \
		 /^[^#]/ { printf ".%s ", $$1; print; \
			   printf "=%s ", $$3; print }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."

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

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

$(VAR_DB)/protocols.db: /etc/protocols
	@echo -n "$(patsubst %.db,%,$(@F))... "
	@$(AWK) '/^[^#]/ { 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) '/^[^#]/ { 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/]+" } \
		 /^[^#]/ { 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=":" } \
		 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
	$(MAKEDB) -o $@ -
	@echo "done."