Fix jn precision
[glibc.git] / nss / db-Makefile
blob13259c188cc6cfbf1d194f87be0eea98bc0f6d71
1 # Makefile to (re-)generate db versions of system database files.
2 # Copyright (C) 1996, 1997, 1998, 2011 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
20 # 02111-1307 USA.
22 DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
23                        /etc/rpc /etc/services /etc/shadow /etc/gshadow \
24                        /etc/netgroup)
26 VAR_DB = /var/db
28 AWK = awk
29 MAKEDB = makedb --quiet
31 all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
34 $(VAR_DB)/passwd.db: /etc/passwd
35         @echo -n "$(patsubst %.db,%,$(@F))... "
36         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
37                  /^[ \t]*$$/ { next } \
38                  /^[ \t]*#/ { next } \
39                  /^[^#]/ { printf ".%s ", $$1; print; \
40                            printf "=%s ", $$3; print }' $^ | \
41         $(MAKEDB) -o $@ -
42         @echo "done."
44 $(VAR_DB)/group.db: /etc/group
45         @echo -n "$(patsubst %.db,%,$(@F))... "
46         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
47                  /^[ \t]*$$/ { next } \
48                  /^[ \t]*#/ { next } \
49                  /^[^#]/ { printf ".%s ", $$1; print; \
50                            printf "=%s ", $$3; print; \
51                            if ($$4 != "") { \
52                              split($$4, grmems, ","); \
53                              for (memidx in grmems) { \
54                                mem=grmems[memidx]; \
55                                if (members[mem] == "") \
56                                  members[mem]=$$3; \
57                                else \
58                                  members[mem]=members[mem] "," $$3; \
59                              } \
60                              delete grmems; } } \
61                  END { for (mem in members) \
62                          printf ":%s $s %s\n", mem, mem, members[mem]; }' $^ | \
63         $(MAKEDB) -o $@ -
64         @echo "done."
66 $(VAR_DB)/ethers.db: /etc/ethers
67         @echo -n "$(patsubst %.db,%,$(@F))... "
68         @$(AWK) '/^[ \t]*$$/ { next } \
69                  /^[ \t]*#/ { next } \
70                  /^[^#]/ { printf ".%s ", $$1; print; \
71                            printf "=%s ", $$2; print }' $^ | \
72         $(MAKEDB) -o $@ -
73         @echo "done."
75 $(VAR_DB)/protocols.db: /etc/protocols
76         @echo -n "$(patsubst %.db,%,$(@F))... "
77         @$(AWK) '/^[ \t]*$$/ { next } \
78                  /^[ \t]*#/ { next } \
79                  /^[^#]/ { printf ".%s ", $$1; print; \
80                            printf "=%s ", $$2; print; \
81                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
82                              { printf ".%s ", $$i; print } }' $^ | \
83         $(MAKEDB) -o $@ -
84         @echo "done."
86 $(VAR_DB)/rpc.db: /etc/rpc
87         @echo -n "$(patsubst %.db,%,$(@F))... "
88         @$(AWK) '/^[ \t]*$$/ { next } \
89                  /^[ \t]*#/ { next } \
90                  /^[^#]/ { printf ".%s ", $$1; print; \
91                            printf "=%s ", $$2; print; \
92                            for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
93                              { printf ".%s ", $$i; print } }' $^ | \
94         $(MAKEDB) -o $@ -
95         @echo "done."
97 $(VAR_DB)/services.db: /etc/services
98         @echo -n "$(patsubst %.db,%,$(@F))... "
99         @$(AWK) 'BEGIN { FS="[ \t/]+" } \
100                  /^[ \t]*$$/ { next } \
101                  /^[ \t]*#/ { next } \
102                  /^[^#]/ { sub(/[ \t]*#.*$$/, "");\
103                            printf ":%s/%s ", $$1, $$3; print; \
104                            printf ":%s/ ", $$1; print; \
105                            printf "=%s/%s ", $$2, $$3; print; \
106                            printf "=%s/ ", $$2; print; \
107                            for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
108                              { printf ":%s/%s ", $$i, $$3; print; \
109                                printf ":%s/ ", $$i; print } }' $^ | \
110         $(MAKEDB) -o $@ -
111         @echo "done."
113 $(VAR_DB)/shadow.db: /etc/shadow
114         @echo -n "$(patsubst %.db,%,$(@F))... "
115         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
116                  /^[ \t]*$$/ { next } \
117                  /^[ \t]*#/ { next } \
118                  /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
119         (umask 077 && $(MAKEDB) -o $@ -)
120         @echo "done."
121         @if chgrp shadow $@ 2>/dev/null; then \
122           chmod g+r $@; \
123         else \
124           chown 0 $@; chgrp 0 $@; chmod 600 $@; \
125           echo; \
126           echo "Warning: The shadow password database $@"; \
127           echo "has been set to be readable only by root.  You may want"; \
128           echo "to make it readable by the \`shadow' group depending"; \
129           echo "on your configuration."; \
130           echo; \
131         fi
133 $(VAR_DB)/gshadow.db: /etc/gshadow
134         @echo -n "$(patsubst %.db,%,$(@F))... "
135         @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
136                  /^[ \t]*$$/ { next } \
137                  /^[ \t]*#/ { next } \
138                  /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
139         (umask 077 && $(MAKEDB) -o $@ -)
140         @echo "done."
141         @if chgrp shadow $@ 2>/dev/null; then \
142           chmod g+r $@; \
143         else \
144           chown 0 $@; chgrp 0 $@; chmod 600 $@; \
145           echo; \
146           echo "Warning: The shadow group database $@"; \
147           echo "has been set to be readable only by root.  You may want"; \
148           echo "to make it readable by the \`shadow' group depending"; \
149           echo "on your configuration."; \
150           echo; \
151         fi
153 $(VAR_DB)/netgroup.db: /etc/netgroup
154         @echo -n "$(patsubst %.db,%,$(@F))... "
155         @$(AWK) 'BEGIN { ini=1 } \
156                  /^[ \t]*$$/ { next } \
157                  /^[ \t]*#/ { next } \
158                  /^[^#]/ { if (sub(/[ \t]*\\$$/, " ") == 0) end="\n"; \
159                            else end=""; \
160                            gsub(/[ \t]+/, " "); \
161                            sub(/^[ \t]*/, ""); \
162                            if (ini == 0) printf "%s%s", $$0, end; \
163                            else printf ".%s %s%s", $$1, $$0, end; \
164                            ini=end == "" ? 0 : 1; } \
165                            END { if (ini==0) printf "\n" }' $^ | \
166         $(MAKEDB) -o $@ -
167         @echo "done."