make upgrade: Remove a file that was existing with a dir name for a while.
[dragonfly.git] / etc / Makefile
1 #       from: @(#)Makefile      5.11 (Berkeley) 5/21/91
2 # $FreeBSD: src/etc/Makefile,v 1.219.2.38 2003/03/04 09:49:00 ru Exp $
3 # $DragonFly: src/etc/Makefile,v 1.217 2008/10/03 10:27:42 swildner Exp $
4
5 .if !defined(NO_SENDMAIL)
6 SUBDIR= sendmail
7 .endif
8
9 # Files that should be installed read-only (444)
10 #
11 BINUPDATE= apmd.conf fbtab gettytab network.subr \
12         pf.os \
13         protocols \
14         rc rc.firewall6 \
15         rc.sendmail rc.shutdown \
16         rc.subr rpc services \
17         etc.${MACHINE_ARCH}/disktab
18 .if defined(BINARY_UPGRADE) # location of these depends on upgrade method
19 BINUPDATE+=mail.rc locate.rc
20 .else
21 BINUPDATE+=${.CURDIR}/../usr.bin/mail/misc/mail.rc \
22         ${.CURDIR}/../usr.bin/locate/locate/locate.rc
23 .endif
24
25 # Initial distribution files are installed read-write (644)
26 #
27 BIN1=   amd.map auth.conf \
28         crontab csh.cshrc csh.login csh.logout \
29         devd.conf devtab dhclient.conf dm.conf dntpd.conf \
30         ftpusers group \
31         hosts hosts.allow hosts.equiv hosts.lpd \
32         inetd.conf login.access login.conf \
33         motd modems netconfig networks newsyslog.conf \
34         nscd.conf pf.conf phones printcap profile \
35         remote sensorsd.conf \
36         shells sysctl.conf syslog.conf usbd.conf \
37         etc.${MACHINE_ARCH}/ttys
38 .if defined(BINARY_UPGRADE) # location of these depends on upgrade method
39 BIN1+=  manpath.config
40 .else
41 BIN1+=  ${.CURDIR}/../gnu/usr.bin/man/manpath/manpath.config
42 .endif
43
44 .if exists(${.CURDIR}/../crypto) && !defined(NO_OPENSSL)
45 .if !defined(NO_OPENSSH)
46 DIRS+=  secure/lib/libssh \
47         secure/usr.bin/ssh \
48         secure/usr.sbin/sshd
49 .endif
50 DIRS+=  secure/usr.bin/openssl
51 .endif
52
53 # Files that should be installed read-only-executable (555) root:wheel
54 #
55 BIN2=   pccard_ether rc.firewall rc.suspend rc.resume
56
57 DEFAULTS= compilers.conf devfs.conf make.conf periodic.conf rc.conf uuids
58
59 MTREE=  BSD.include.dist BSD.local.dist BSD.root.dist BSD.usr.dist \
60         BSD.var.dist
61 .if !defined(NO_SENDMAIL)
62 MTREE+= BSD.sendmail.dist
63 .endif
64
65 NAMEDB= PROTO.localhost.rev PROTO.localhost-v6.rev named.conf named.root \
66         make-localhost getroot README
67
68 PPPCNF= ppp.conf
69
70 ETCMAIL=Makefile README mailer.conf access.sample virtusertable.sample \
71         mailertable.sample aliases
72
73 # Special top level files for FreeBSD
74 FREEBSD=COPYRIGHT
75
76 # List of libraries in /usr/lib/compat that might have to be removed
77 # from /usr/lib.
78 COMPAT_LIBS != cd ${DESTDIR}/usr/lib/compat && find . -name '*.so.*'
79
80 # Use this directory as the source for new configuration files when upgrading
81 UPGRADE_SRCDIR?=${.CURDIR}
82
83 # Include file which contains obsolete files
84 .if exists(${DESTDIR}/etc/upgrade/Makefile_upgrade.inc)
85 .include "${DESTDIR}/etc/upgrade/Makefile_upgrade.inc"
86 .endif
87
88 remove-obsolete-files:
89         @if [ -z "${TO_REMOVE}" ]; then \
90                 echo "Please do a 'make installworld' first."; \
91                 echo "See build(7) for further information."; \
92                 exit 1; \
93         fi;
94         @echo "===> Remove now obsolete files"
95         @for item in ${TO_REMOVE:M*.info.gz}; do \
96                 if [ -e ${DESTDIR}$${item} ]; then \
97                         install-info --delete ${DESTDIR}$${item} \
98                             /usr/share/info/dir; \
99                 fi; \
100         done;
101         @for item in ${TO_REMOVE}; do \
102                 if [ -e ${DESTDIR}$${item} ]; then \
103                         echo "${DESTDIR}$${item}"; \
104                         rm -rf "${DESTDIR}$${item}"; \
105                 fi; \
106         done
107         @rm -f "${DESTDIR}/etc/upgrade/Makefile_upgrade.inc"
108
109 preupgrade:
110 .if !defined(NO_SENDMAIL)
111         (pw -V ${DESTDIR}/etc groupshow smmsp -q > /dev/null) || \
112                 pw -V ${DESTDIR}/etc groupadd smmsp -g 25
113         (pw -V ${DESTDIR}/etc usershow smmsp -q > /dev/null) || \
114                 pw -V ${DESTDIR}/etc useradd smmsp -u 25 \
115                    -c "Sendmail Submission User" \
116                    -d /var/spool/clientmqueue -s /sbin/nologin
117 .endif
118         (pw -V ${DESTDIR}/etc usershow _pflogd -q > /dev/null) || \
119                 pw -V ${DESTDIR}/etc useradd _pflogd -u 64 \
120                    -c "pflogd privsep user" \
121                    -d /var/empty -s /sbin/nologin
122         (pw -V ${DESTDIR}/etc usershow _sdpd -q > /dev/null) || \
123                 pw -V ${DESTDIR}/etc useradd _sdpd -u 70 \
124                    -c "sdpd privsep user" \
125                    -d /var/empty -s /sbin/nologin
126         (pw -V ${DESTDIR}/etc usershow _dhcp -q > /dev/null) || \
127                 pw -V ${DESTDIR}/etc useradd _dhcp -u 77 \
128                    -c "DHCP programs" \
129                    -d /var/empty -s /sbin/nologin
130         (pw -V ${DESTDIR}/etc groupshow authpf -q > /dev/null) || \
131                 pw -V ${DESTDIR}/etc groupadd authpf -g 63
132         (pw -V ${DESTDIR}/etc groupshow _pflogd -q > /dev/null) || \
133                 pw -V ${DESTDIR}/etc groupadd _pflogd -g 64
134         (pw -V ${DESTDIR}/etc groupshow _sdpd -q > /dev/null) || \
135                 pw -V ${DESTDIR}/etc groupadd _sdpd -g 70
136         (pw -V ${DESTDIR}/etc groupshow _dhcp -q > /dev/null) || \
137                 pw -V ${DESTDIR}/etc groupadd _dhcp -g 77
138
139 upgrade_etc:    preupgrade remove-obsolete-files
140         # files that should be dirs (not possible with Makefile_upgrade.inc)
141 .for f in usr/include/dev/misc/ppi
142         [ -d ${DESTDIR}/${f} ] || rm -f ${DESTDIR}/${f}
143 .endfor
144 .if !defined(BINARY_UPGRADE) # binary upgrade just copies these files
145         cd ${UPGRADE_SRCDIR}/../share/mk; ${MAKE} install
146 .endif
147         cd ${UPGRADE_SRCDIR}; \
148             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
149                 ${BINUPDATE} ${DESTDIR}/etc; \
150             cap_mkdb ${DESTDIR}/etc/login.conf; \
151             for f in ${BIN1}; do \
152                 [ -e "${DESTDIR}/etc/$${f##*/}" ] || \
153                     ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
154                         $$f ${DESTDIR}/etc; \
155             done; \
156             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
157                 ${BIN2} ${DESTDIR}/etc;
158         cd ${UPGRADE_SRCDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
159             ${DEFAULTS} ${DESTDIR}/etc/defaults
160         cd ${UPGRADE_SRCDIR}/periodic; ${MAKE} install
161         mkdir -p ${DESTDIR}/etc/rc.d
162         cd ${UPGRADE_SRCDIR}/rc.d; ${MAKE} install 
163         # "../share/termcap/make etc-termcap" expanded inline here:
164         ${LN} -fs /usr/share/misc/termcap ${DESTDIR}/etc/termcap
165         # "../usr.sbin/rmt/make etc-rmt" expanded inline here:
166         ${LN} -fs /usr/sbin/rmt ${DESTDIR}/etc/rmt
167 .if !defined(BINARY_UPGRADE) # XXX not yet handled by binary upgrade
168 .if !defined(NO_SENDMAIL)
169         cd ${UPGRADE_SRCDIR}/sendmail; ${MAKE} upgrade
170 .endif
171 .endif
172 .if !defined(NO_I4B)
173         cd ${UPGRADE_SRCDIR}/isdn; ${MAKE} install
174 .endif
175         cd ${UPGRADE_SRCDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
176             ${MTREE} ${DESTDIR}/etc/mtree
177         cd ${UPGRADE_SRCDIR}/bluetooth; ${MAKE} install
178         cd ${UPGRADE_SRCDIR}/dma; ${MAKE} install
179         cd ${UPGRADE_SRCDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 Makefile.usr ${DESTDIR}/usr/Makefile
180 .if !exists(${DESTDIR}/etc/pam.d)
181         mkdir -p ${DESTDIR}/etc/pam.d
182         cd ${UPGRADE_SRCDIR}/pam.d; ${MAKE} install
183         sh ${DESTDIR}/etc/pam.d/convert.sh ${DESTDIR}/etc/pam.d ${DESTDIR}/etc/pam.conf
184 .else
185 .for pamconf in README convert.sh atrun cron passwd rsh su system
186 .if !exists(${DESTDIR}/etc/pam.d/${pamconf})
187         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${UPGRADE_SRCDIR}/pam.d/${pamconf} ${DESTDIR}/etc/pam.d
188 .endif
189 .endfor
190 .endif
191         # these removals must occur AFTER any pam conversion
192         csh -c "rm -f /usr/lib/pam_{cleartext_pass_ok,deny,opie,opieaccess,permit,radius,skey,ssh,tacplus,unix}.so"
193         rm -f /etc/pam.conf
194 .if !defined(BINARY_UPGRADE) # binary upgrade just copies these files
195         cd ${UPGRADE_SRCDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
196             ${FREEBSD} ${DESTDIR}/
197 .endif
198         rm -f ${DESTDIR}/usr/include/machine/ioctl_meteor.h
199         rm -f ${DESTDIR}/usr/include/machine/ioctl_bt848.h
200         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" ${DESTDIR}/usr/include/machine/ioctl_bt848.h
201         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" ${DESTDIR}/usr/include/machine/ioctl_meteor.h
202 .if exists(${DESTDIR}/usr/lib/gcc2)
203         ldconfig -m ${DESTDIR}/usr/lib/gcc2
204 .endif
205 .for lib in ${COMPAT_LIBS:M*.so.*}
206 .if exists(${DESTDIR}/usr/lib/${lib})
207         chflags noschg ${DESTDIR}/usr/lib/${lib}
208         rm -f ${DESTDIR}/usr/lib/${lib}
209 .endif
210 .endfor
211 .if !defined(NO_OPENSSH)
212         cd ${.CURDIR}/../secure/lib/libssh; ${MAKE} -f Makefile.etc obj
213         cd ${.CURDIR}/../secure/lib/libssh; ${MAKE} -f Makefile.etc install
214 .endif
215 .if exists(${DESTDIR}/boot)
216 .if exists(${DESTDIR}/kernel)
217         chflags noschg ${DESTDIR}/kernel
218         mv ${DESTDIR}/kernel ${DESTDIR}/boot/kernel
219         chflags schg ${DESTDIR}/boot/kernel
220 .endif
221 .if exists(${DESTDIR}/modules)
222         mv ${DESTDIR}/modules ${DESTDIR}/boot/modules
223         rm -rf ${DESTDIR}/boot/modules/modules
224 .endif
225 .if exists(${DESTDIR}/kernel.old)
226         mv ${DESTDIR}/kernel.old ${DESTDIR}/boot/kernel.old
227 .endif
228 .if exists(${DESTDIR}/modules.old)
229         mv ${DESTDIR}/modules.old ${DESTDIR}/boot/modules.old
230         rm -rf ${DESTDIR}/boot/modules.old/modules.old
231 .endif
232 .endif
233         ldconfig -R
234         mkdir -p ${DESTDIR}/dev
235
236 # The existence of cleartext_pass_ok means pam config files are out of date.
237         @set - `fgrep cleartext_pass_ok ${DESTDIR}/etc/pam.d/*`; \
238         if [ $$# -gt 0 ] ; \
239         then \
240                 echo "It appears your PAM configuration files need to be updated"; \
241                 echo "This can be done by manually editing the files or:"; \
242                 echo "  cd ${UPGRADE_SRCDIR}/pam.d"; \
243                 echo "  make install"; \
244         fi
245
246 distribution:
247         cd ${.CURDIR}; \
248             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
249                 ${BINUPDATE} ${DESTDIR}/etc; \
250             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
251                 ${BIN1} ${DESTDIR}/etc; \
252             cap_mkdb ${DESTDIR}/etc/login.conf; \
253             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
254                 ${BIN2} ${DESTDIR}/etc; \
255             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
256                 master.passwd nsmb.conf opieaccess ${DESTDIR}/etc; \
257             pwd_mkdb -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
258         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
259             ${DEFAULTS} ${DESTDIR}/etc/defaults
260         cd ${.CURDIR}/pam.d; ${MAKE} install
261         cd ${.CURDIR}/bluetooth; ${MAKE} install
262         cd ${.CURDIR}/dma; ${MAKE} install
263         cd ${.CURDIR}/periodic; ${MAKE} install
264         cd ${.CURDIR}/rc.d; ${MAKE} install 
265         cd ${.CURDIR}/../share/termcap; ${MAKE} etc-termcap
266         cd ${.CURDIR}/../usr.sbin/rmt; ${MAKE} etc-rmt
267         cd ${.CURDIR}; \
268             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
269                 Makefile.usr ${DESTDIR}/usr/Makefile
270 .if !defined(NO_I4B)
271         cd ${.CURDIR}/isdn; ${MAKE} install
272 .endif
273 .if !defined(NO_SENDMAIL)
274         cd ${.CURDIR}/sendmail; ${MAKE} obj
275         cd ${.CURDIR}/sendmail; ${MAKE} distribution
276 .endif
277 .for dir in ${DIRS}
278 .if exists(${.CURDIR}/../${dir}/Makefile.etc)
279         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc obj
280         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc install
281 .endif
282 .endfor
283         mkdir -p ${DESTDIR}/dev
284         cd ${.CURDIR}/root; \
285             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
286                 dot.cshrc ${DESTDIR}/root/.cshrc; \
287             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
288                 dot.klogin ${DESTDIR}/root/.klogin; \
289             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
290                 dot.login ${DESTDIR}/root/.login; \
291             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
292                 dot.profile ${DESTDIR}/root/.profile; \
293             rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
294             ${LN} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
295             ${LN} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
296         cd ${.CURDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
297             ${MTREE} ${DESTDIR}/etc/mtree
298         cd ${.CURDIR}/namedb; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
299             ${NAMEDB} ${DESTDIR}/etc/namedb
300         cd ${.CURDIR}/ppp; ${INSTALL} -o root -g ${BINGRP} -m 600 \
301             ${PPPCNF} ${DESTDIR}/etc/ppp
302         cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
303             ${ETCMAIL} ${DESTDIR}/etc/mail
304         @if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
305               ! -f ${DESTDIR}/etc/aliases ]; then \
306                 set -x; \
307                 ${LN} -s mail/aliases ${DESTDIR}/etc/aliases; \
308         fi
309         ${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
310             ${DESTDIR}/etc/dumpdates
311         ${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
312             ${DESTDIR}/var/db/locate.database
313         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
314             ${DESTDIR}/var/log/auth.log
315         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
316             ${DESTDIR}/var/log/cron
317         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
318             ${DESTDIR}/var/log/lpd-errs
319         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
320             ${DESTDIR}/var/log/maillog
321         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
322             ${DESTDIR}/var/log/lastlog
323         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
324             ${DESTDIR}/var/log/messages
325         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
326             ${DESTDIR}/var/log/security
327         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
328             ${DESTDIR}/var/log/slip.log
329         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
330             ${DESTDIR}/var/log/ppp.log
331         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
332             ${DESTDIR}/var/log/wtmp
333         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
334             ${DESTDIR}/var/run/utmp
335         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
336             ${DESTDIR}/var/crash
337         cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
338             ${FREEBSD} ${DESTDIR}/
339 .if !defined(NOMAN)
340         cd ${.CURDIR}/../share/man; ${MAKE} makedb
341 .endif
342
343 distrib-dirs:
344         -set - `grep "^[a-zA-Z]" ${.CURDIR}/locale.deprecated`; \
345         while [ $$# -gt 0 ] ; \
346         do \
347                 for dir in /usr/share/locale \
348                            /usr/share/nls \
349                            /usr/local/share/nls; \
350                 do \
351                         test -d ${DESTDIR}/$${dir} && cd ${DESTDIR}/$${dir}; \
352                         test -L "$$2" && rm -rf "$$2"; \
353                         test \! -L "$$1" && test -d "$$1" && mv "$$1" "$$2"; \
354                 done; \
355                 shift; shift; \
356         done
357         mtree -deU -f ${.CURDIR}/mtree/BSD.root.dist -p ${DESTDIR}/
358         mtree -deU -f ${.CURDIR}/mtree/BSD.var.dist -p ${DESTDIR}/var
359         mtree -deU -f ${.CURDIR}/mtree/BSD.usr.dist -p ${DESTDIR}/usr
360         mtree -deU -f ${.CURDIR}/mtree/BSD.include.dist \
361                 -p ${DESTDIR}/usr/include
362 .if !defined(NO_SENDMAIL)
363         mtree -deU -f ${.CURDIR}/mtree/BSD.sendmail.dist -p ${DESTDIR}/
364 .endif
365         cd ${DESTDIR}/etc/namedb; rm -f etc/namedb; ${LN} -s ".." etc/namedb
366         cd ${DESTDIR}/; test -e sys || (rm -f sys;  ${LN} -s usr/src/sys sys)
367         cd ${DESTDIR}/usr/share/man/en.ISO8859-1; ${LN} -sf ../man* .
368         cd ${DESTDIR}/usr/share/man; \
369         set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \
370         while [ $$# -gt 0 ] ; \
371         do \
372                 rm -rf "$$1"; \
373                 ${LN} -s "$$2" "$$1"; \
374                 shift; shift; \
375         done
376         cd ${DESTDIR}/usr/share/locale; \
377         set - `grep "^[a-zA-Z]" ${.CURDIR}/locale.alias`; \
378         while [ $$# -gt 0 ] ; \
379         do \
380                 rm -rf "$$1"; \
381                 ${LN} -s "$$2" "$$1"; \
382                 shift; shift; \
383         done
384         cd ${DESTDIR}/usr/share/openssl/man/en.ISO8859-1; ${LN} -sf ../man* .
385         cd ${DESTDIR}/usr/share/nls; \
386         set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
387         while [ $$# -gt 0 ] ; \
388         do \
389                 rm -rf "$$1"; \
390                 ${LN} -s "$$2" "$$1"; \
391                 shift; shift; \
392         done
393
394 etc-examples:
395         cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
396             ${BINUPDATE} ${BIN1} ${BIN2} nsmb.conf opieaccess \
397             ${DESTDIR}/usr/share/examples/etc
398         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
399             ${DEFAULTS} ${DESTDIR}/usr/share/examples/etc/defaults
400
401 .include <bsd.prog.mk>