1 # Makefile to (re-)generate db versions of system database files.
2 # Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4 # Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
7 # The GNU C Library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # The GNU C Library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with the GNU C Library; if not, write to the Free
19 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
23 /etc/rpc /etc/services /etc/shadow /etc/netgroup)
28 MAKEDB = makedb --quiet
30 all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
33 $(VAR_DB)/passwd.db: /etc/passwd
34 @echo -n "$(patsubst %.db,%,$(@F))... "
35 @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
36 /^[ \t]*$$/ { next } \
38 { printf "0%u ", cnt++; print } \
39 /^[^#]/ { printf ".%s ", $$1; print; \
40 printf "=%s ", $$3; print }' $^ | \
44 $(VAR_DB)/group.db: /etc/group
45 @echo -n "$(patsubst %.db,%,$(@F))... "
46 @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
47 /^[ \t]*$$/ { next } \
49 { printf "0%u ", cnt++; print } \
50 /^[^#]/ { printf ".%s ", $$1; print; \
51 printf "=%s ", $$3; print }' $^ | \
55 $(VAR_DB)/ethers.db: /etc/ethers
56 @echo -n "$(patsubst %.db,%,$(@F))... "
57 @$(AWK) 'BEGIN { cnt=0 } \
58 /^[ \t]*$$/ { next } \
60 { printf "0%u ", cnt++; print } \
61 /^[^#]/ { printf ".%s ", $$1; print; \
62 printf "=%s ", $$2; print }' $^ | \
66 $(VAR_DB)/protocols.db: /etc/protocols
67 @echo -n "$(patsubst %.db,%,$(@F))... "
68 @$(AWK) 'BEGIN { cnt=0 } \
69 /^[ \t]*$$/ { next } \
71 { printf "0%u ", cnt++; print } \
72 /^[^#]/ { printf ".%s ", $$1; print; \
73 printf "=%s ", $$2; print; \
74 for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
75 { printf ".%s ", $$i; print } }' $^ | \
79 $(VAR_DB)/rpc.db: /etc/rpc
80 @echo -n "$(patsubst %.db,%,$(@F))... "
81 @$(AWK) 'BEGIN { cnt=0 } \
82 /^[ \t]*$$/ { next } \
84 { printf "0%u ", cnt++; print } \
85 /^[^#]/ { printf ".%s ", $$1; print; \
86 printf "=%s ", $$2; print; \
87 for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
88 { printf ".%s ", $$i; print } }' $^ | \
92 $(VAR_DB)/services.db: /etc/services
93 @echo -n "$(patsubst %.db,%,$(@F))... "
94 @$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
95 /^[ \t]*$$/ { next } \
97 { printf "0%u ", cnt++; print } \
98 /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
99 printf ".%s/ ", $$1; print; \
100 printf "=%s/%s ", $$2, $$3; print; \
101 printf "=%s/ ", $$2; print; \
102 for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
103 { printf ".%s/%s ", $$i, $$3; print; \
104 printf ".%s/ ", $$i; print } }' $^ | \
108 $(VAR_DB)/shadow.db: /etc/shadow
109 @echo -n "$(patsubst %.db,%,$(@F))... "
110 @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
111 /^[ \t]*$$/ { next } \
112 /^[ \t]*#/ { next } \
113 { printf "0%u ", cnt++; print } \
114 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
115 (umask 077 && $(MAKEDB) -o $@ -)
117 @if chgrp shadow $@ 2>/dev/null; then \
120 chown 0 $@; chgrp 0 $@; chmod 600 $@; \
122 echo "Warning: The shadow password database $@"; \
123 echo "has been set to be readable only by root. You may want"; \
124 echo "to make it readable by the \`shadow' group depending"; \
125 echo "on your configuration."; \
129 $(VAR_DB)/netgroup.db: /etc/netgroup
130 @echo -n "$(patsubst %.db,%,$(@F))... "
131 @$(AWK) 'BEGIN { cnt=0 } \
132 /^[ \t]*$$/ { next } \
133 /^[ \t]*#/ { next } \
134 { printf "0%u ", cnt++; print } \
135 /^[^#]/ { end=sub(/\\/, " "); \
136 gsub(/[ \t]+/, " "); \
137 if(end == 1) printf "%s", $$0; else print }' $^ | \