Fix mtrace stack overflow bug
[kopensolaris-gnu/glibc.git] / nss / db-Makefile
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.
5 #
6
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.
11
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.
16
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.
21
22 DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
23                        /etc/rpc /etc/services /etc/shadow /etc/netgroup)
24
25 VAR_DB = /var/db
26
27 AWK = awk
28 MAKEDB = makedb --quiet
29
30 all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
31
32
33 $(VAR_DB)/passwd.db: /etc/passwd
34         @echo -n "$(patsubst %.db,%,$(@F))... "
35         @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
36                  /^[ \t]*$$/ { next } \
37                  /^[ \t]*#/ { next } \
38                  { printf "0%u ", cnt++; print } \
39                  /^[^#]/ { printf ".%s ", $$1; print; \
40                            printf "=%s ", $$3; print }' $^ | \
41         $(MAKEDB) -o $@ -
42         @echo "done."
43
44 $(VAR_DB)/group.db: /etc/group
45         @echo -n "$(patsubst %.db,%,$(@F))... "
46         @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
47                  /^[ \t]*$$/ { next } \
48                  /^[ \t]*#/ { next } \
49                  { printf "0%u ", cnt++; print } \
50                  /^[^#]/ { printf ".%s ", $$1; print; \
51                            printf "=%s ", $$3; print }' $^ | \
52         $(MAKEDB) -o $@ -
53         @echo "done."
54
55 $(VAR_DB)/ethers.db: /etc/ethers
56         @echo -n "$(patsubst %.db,%,$(@F))... "
57         @$(AWK) 'BEGIN { cnt=0 } \
58                  /^[ \t]*$$/ { next } \
59                  /^[ \t]*#/ { next } \
60                  { printf "0%u ", cnt++; print } \
61                  /^[^#]/ { printf ".%s ", $$1; print; \
62                            printf "=%s ", $$2; print }' $^ | \
63         $(MAKEDB) -o $@ -
64         @echo "done."
65
66 $(VAR_DB)/protocols.db: /etc/protocols
67         @echo -n "$(patsubst %.db,%,$(@F))... "
68         @$(AWK) 'BEGIN { cnt=0 } \
69                  /^[ \t]*$$/ { next } \
70                  /^[ \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 } }' $^ | \
76         $(MAKEDB) -o $@ -
77         @echo "done."
78
79 $(VAR_DB)/rpc.db: /etc/rpc
80         @echo -n "$(patsubst %.db,%,$(@F))... "
81         @$(AWK) 'BEGIN { cnt=0 } \
82                  /^[ \t]*$$/ { next } \
83                  /^[ \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 } }' $^ | \
89         $(MAKEDB) -o $@ -
90         @echo "done."
91
92 $(VAR_DB)/services.db: /etc/services
93         @echo -n "$(patsubst %.db,%,$(@F))... "
94         @$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
95                  /^[ \t]*$$/ { next } \
96                  /^[ \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 } }' $^ | \
105         $(MAKEDB) -o $@ -
106         @echo "done."
107
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 $@ -)
116         @echo "done."
117         @if chgrp shadow $@ 2>/dev/null; then \
118           chmod g+r $@; \
119         else \
120           chown 0 $@; chgrp 0 $@; chmod 600 $@; \
121           echo; \
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."; \
126           echo; \
127         fi
128
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 }' $^ | \
138         $(MAKEDB) -o $@ -
139         @echo "done."