]> git.ipfire.org Git - thirdparty/glibc.git/blame - nss/db-Makefile
Reenable nss_db with a completely new implementation
[thirdparty/glibc.git] / nss / db-Makefile
CommitLineData
19361cb7 1# Makefile to (re-)generate db versions of system database files.
2666d441 2# Copyright (C) 1996, 1997, 1998, 2011 Free Software Foundation, Inc.
19361cb7
UD
3# This file is part of the GNU C Library.
4# Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
5#
41bdb6e2 6
19361cb7 7# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
19361cb7
UD
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
41bdb6e2
AJ
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.
19361cb7 21
6e953631 22DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
2666d441
UD
23 /etc/rpc /etc/services /etc/shadow /etc/gshadow \
24 /etc/netgroup)
6e953631
UD
25
26VAR_DB = /var/db
27
28AWK = awk
29MAKEDB = makedb --quiet
30
31all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
32
33
34$(VAR_DB)/passwd.db: /etc/passwd
35 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 36 @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
ecb9d3e1
UD
37 /^[ \t]*$$/ { next } \
38 /^[ \t]*#/ { next } \
6e953631 39 /^[^#]/ { printf ".%s ", $$1; print; \
74015205 40 printf "=%s ", $$3; print }' $^ | \
6e953631
UD
41 $(MAKEDB) -o $@ -
42 @echo "done."
43
44$(VAR_DB)/group.db: /etc/group
45 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 46 @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
ecb9d3e1
UD
47 /^[ \t]*$$/ { next } \
48 /^[ \t]*#/ { next } \
6e953631
UD
49 /^[^#]/ { printf ".%s ", $$1; print; \
50 printf "=%s ", $$3; print }' $^ | \
51 $(MAKEDB) -o $@ -
52 @echo "done."
53
54$(VAR_DB)/ethers.db: /etc/ethers
55 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 56 @$(AWK) '/^[ \t]*$$/ { next } \
ecb9d3e1 57 /^[ \t]*#/ { next } \
afd4eb37 58 /^[^#]/ { printf ".%s ", $$1; print; \
6e953631
UD
59 printf "=%s ", $$2; print }' $^ | \
60 $(MAKEDB) -o $@ -
61 @echo "done."
62
63$(VAR_DB)/protocols.db: /etc/protocols
64 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 65 @$(AWK) '/^[ \t]*$$/ { next } \
ecb9d3e1 66 /^[ \t]*#/ { next } \
afd4eb37 67 /^[^#]/ { printf ".%s ", $$1; print; \
6e953631
UD
68 printf "=%s ", $$2; print; \
69 for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
70 { printf ".%s ", $$i; print } }' $^ | \
71 $(MAKEDB) -o $@ -
72 @echo "done."
73
74$(VAR_DB)/rpc.db: /etc/rpc
75 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 76 @$(AWK) '/^[ \t]*$$/ { next } \
ecb9d3e1 77 /^[ \t]*#/ { next } \
afd4eb37 78 /^[^#]/ { printf ".%s ", $$1; print; \
6e953631
UD
79 printf "=%s ", $$2; print; \
80 for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
81 { printf ".%s ", $$i; print } }' $^ | \
82 $(MAKEDB) -o $@ -
83 @echo "done."
84
85$(VAR_DB)/services.db: /etc/services
86 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 87 @$(AWK) 'BEGIN { FS="[ \t/]+" } \
ecb9d3e1
UD
88 /^[ \t]*$$/ { next } \
89 /^[ \t]*#/ { next } \
2666d441
UD
90 /^[^#]/ { sub(/[ \t]*#.*$$/, "");\
91 printf ":%s/%s ", $$1, $$3; print; \
92 printf ":%s/ ", $$1; print; \
6e953631 93 printf "=%s/%s ", $$2, $$3; print; \
ecb9d3e1 94 printf "=%s/ ", $$2; print; \
6e953631 95 for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
2666d441
UD
96 { printf ":%s/%s ", $$i, $$3; print; \
97 printf ":%s/ ", $$i; print } }' $^ | \
6e953631
UD
98 $(MAKEDB) -o $@ -
99 @echo "done."
100
101$(VAR_DB)/shadow.db: /etc/shadow
102 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 103 @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
ecb9d3e1
UD
104 /^[ \t]*$$/ { next } \
105 /^[ \t]*#/ { next } \
6e953631 106 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
361d49e6 107 (umask 077 && $(MAKEDB) -o $@ -)
6e953631 108 @echo "done."
361d49e6
UD
109 @if chgrp shadow $@ 2>/dev/null; then \
110 chmod g+r $@; \
111 else \
118bad87 112 chown 0 $@; chgrp 0 $@; chmod 600 $@; \
361d49e6
UD
113 echo; \
114 echo "Warning: The shadow password database $@"; \
115 echo "has been set to be readable only by root. You may want"; \
116 echo "to make it readable by the \`shadow' group depending"; \
117 echo "on your configuration."; \
118 echo; \
119 fi
a68b0d31 120
2666d441
UD
121$(VAR_DB)/gshadow.db: /etc/gshadow
122 @echo -n "$(patsubst %.db,%,$(@F))... "
123 @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
124 /^[ \t]*$$/ { next } \
125 /^[ \t]*#/ { next } \
126 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
127 (umask 077 && $(MAKEDB) -o $@ -)
128 @echo "done."
129 @if chgrp shadow $@ 2>/dev/null; then \
130 chmod g+r $@; \
131 else \
132 chown 0 $@; chgrp 0 $@; chmod 600 $@; \
133 echo; \
134 echo "Warning: The shadow group database $@"; \
135 echo "has been set to be readable only by root. You may want"; \
136 echo "to make it readable by the \`shadow' group depending"; \
137 echo "on your configuration."; \
138 echo; \
139 fi
140
a68b0d31
UD
141$(VAR_DB)/netgroup.db: /etc/netgroup
142 @echo -n "$(patsubst %.db,%,$(@F))... "
2666d441 143 @$(AWK) 'BEGIN { ini=1 } \
ecb9d3e1
UD
144 /^[ \t]*$$/ { next } \
145 /^[ \t]*#/ { next } \
2666d441
UD
146 /^[^#]/ { if (sub(/[ \t]*\\$$/, " ") == 0) end="\n"; \
147 else end=""; \
a68b0d31 148 gsub(/[ \t]+/, " "); \
2666d441
UD
149 sub(/^[ \t]*/, ""); \
150 if (ini == 0) printf "%s%s", $$0, end; \
151 else printf ".%s %s%s", $$1, $$0, end; \
152 ini=end == "" ? 0 : 1; } \
153 END { if (ini==0) printf "\n" }' $^ | \
a68b0d31
UD
154 $(MAKEDB) -o $@ -
155 @echo "done."