1 # Makefile to (re-)generate db versions of system database files.
2 # Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4 # Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Library General Public License for more details.
16 # You should have received a copy of the GNU Library General Public
17 # License along with the GNU C Library; see the file COPYING.LIB. If not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA. */
21 DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
22 /etc/rpc /etc/services /etc/shadow /etc/netgroup)
27 MAKEDB = makedb --quiet
29 all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
32 $(VAR_DB)/passwd.db: /etc/passwd
33 @echo -n "$(patsubst %.db,%,$(@F))... "
34 @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
35 { printf "0%u ", cnt++; print } \
36 /^[^#]/ { printf ".%s ", $$1; print; \
38 { printf "=%s ", $$3; print } }' $^ | \
42 $(VAR_DB)/group.db: /etc/group
43 @echo -n "$(patsubst %.db,%,$(@F))... "
44 @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
45 { printf "0%u ", cnt++; print } \
46 /^[^#]/ { printf ".%s ", $$1; print; \
47 printf "=%s ", $$3; print }' $^ | \
51 $(VAR_DB)/ethers.db: /etc/ethers
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 }' $^ | \
60 $(VAR_DB)/protocols.db: /etc/protocols
61 @echo -n "$(patsubst %.db,%,$(@F))... "
62 @$(AWK) 'BEGIN { cnt=0 } \
63 { printf "0%u ", cnt++; print } \
64 /^[^#]/ { printf ".%s ", $$1; print; \
65 printf "=%s ", $$2; print; \
66 for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
67 { printf ".%s ", $$i; print } }' $^ | \
71 $(VAR_DB)/rpc.db: /etc/rpc
72 @echo -n "$(patsubst %.db,%,$(@F))... "
73 @$(AWK) 'BEGIN { cnt=0 } \
74 { printf "0%u ", cnt++; print } \
75 /^[^#]/ { printf ".%s ", $$1; print; \
76 printf "=%s ", $$2; print; \
77 for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
78 { printf ".%s ", $$i; print } }' $^ | \
82 $(VAR_DB)/services.db: /etc/services
83 @echo -n "$(patsubst %.db,%,$(@F))... "
84 @$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
85 { printf "0%u ", cnt++; print } \
86 /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
87 printf "=%s/%s ", $$2, $$3; print; \
88 for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
89 { printf ".%s/%s ", $$i, $$3; print } }' $^ | \
93 $(VAR_DB)/shadow.db: /etc/shadow
94 @echo -n "$(patsubst %.db,%,$(@F))... "
95 @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
96 { printf "0%u ", cnt++; print } \
97 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
101 $(VAR_DB)/netgroup.db: /etc/netgroup
102 @echo -n "$(patsubst %.db,%,$(@F))... "
103 @$(AWK) 'BEGIN { cnt=0 } \
104 { printf "0%u ", cnt++; print } \
105 /^[^#]/ { end=sub(/\\/, " "); \
106 gsub(/[ \t]+/, " "); \
107 if(end == 1) printf "%s", $$0; else print }' $^ | \