7339bb92f36e96fc897d573c5cb9dd2a48fe67ad
[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
4 SUBDIR= sendmail
5
6 # Files that should be installed read-only (444)
7 #
8 BINUPDATE= devd.conf fbtab network.subr \
9         pf.os \
10         protocols \
11         rc rc.firewall rc.firewall6 \
12         rc.sendmail rc.shutdown \
13         rc.subr regdomain.xml rpc \
14         etc.${MACHINE_ARCH}/disktab
15 .if defined(BINARY_UPGRADE) # location of these depends on upgrade method
16 BINUPDATE+=mail.rc locate.rc
17 .else
18 BINUPDATE+=${.CURDIR}/../usr.bin/mail/misc/mail.rc \
19         ${.CURDIR}/../usr.bin/locate/locate/locate.rc \
20         ${.CURDIR}/../contrib/openresolv/resolvconf.conf \
21         ${.CURDIR}/../contrib/dhcpcd/src/dhcpcd.conf
22 .endif
23
24 # Initial distribution files are installed read-write (644)
25 #
26 BIN1=   auth.conf \
27         crontab csh.cshrc csh.login csh.logout \
28         devtab dhclient.conf dntpd.conf \
29         ftpusers gettytab \
30         hosts hosts.allow hosts.equiv hosts.lpd \
31         inetd.conf login.access login.conf \
32         motd modems netconfig networks newsyslog.conf \
33         nscd.conf pf.conf phones printcap profile \
34         remote sensorsd.conf services \
35         shells sysctl.conf syslog.conf \
36         wpa_supplicant.conf \
37         etc.${MACHINE_ARCH}/ttys
38
39 DIRS+=  lib/libssh usr.bin/openssl usr.bin/ssh usr.sbin/sshd
40
41 # Files that should be installed read-only-executable (555) root:wheel
42 #
43 BIN2=   pccard_ether rc.suspend rc.resume
44
45 DEFAULTS= compilers.conf devfs.conf make.conf periodic.conf \
46           pfi.conf rc.conf uuids
47
48 MTREE=  BSD.include.dist BSD.root.dist BSD.usr.dist BSD.var.dist
49 .if !defined(NOFSCHG)
50 MTREE_FSCHG=    -i
51 .endif
52
53 PPPCNF= ppp.conf
54
55 ETCMAIL=aliases mailer.conf access.sample virtusertable.sample \
56         mailertable.sample
57
58 # Use this directory as the source for new configuration files when upgrading
59 UPGRADE_SRCDIR?=${.CURDIR}
60
61 CHECK_DEPRECATED_DIRS+= /usr/local
62
63 # Include file which contains obsolete files
64 .if exists(${DESTDIR}/etc/upgrade/Makefile_upgrade.inc)
65 .include "${DESTDIR}/etc/upgrade/Makefile_upgrade.inc"
66 .endif
67
68 remove-obsolete-files:
69         @if [ -z "${TO_REMOVE}" ]; then \
70                 echo "Please do a 'make installworld' first."; \
71                 echo "See build(7) for further information."; \
72                 /usr/bin/false; \
73         fi;
74         @echo "===> Remove now obsolete files"
75         @for item in ${TO_REMOVE}; do \
76                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
77                         echo "${DESTDIR}$${item}"; \
78                         chflags -Rf noschg "${DESTDIR}$${item}"; \
79                         rm -rf "${DESTDIR}$${item}"; \
80                 fi; \
81         done;
82
83 remove-deprecated-files:
84 .if defined(REMOVE_DEPRECATED)
85         @echo "===> Remove now deprecated files"
86         @for item in ${TO_REMOVE_LATE}; do \
87                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
88                         echo "${DESTDIR}$${item}"; \
89                         chflags -Rf noschg "${DESTDIR}$${item}"; \
90                         rm -rf "${DESTDIR}$${item}"; \
91                 fi; \
92         done;
93 .else
94         @make check-deprecated-files
95 .endif
96
97 check-deprecated-files:
98         @echo "===> Checking for deprecated files"
99         @echo "     (harmless ELF linker warnings may appear here)"
100         @tmpldd=`mktemp -t chkldd`; \
101         chroot ${DESTDIR}/ find ${CHECK_DEPRECATED_DIRS:O:u} \
102                                 -type f \( -name '*.so*' -o -perm +111 \) | \
103                                 chroot ${DESTDIR}/ xargs ldd 2>/dev/null > $${tmpldd}; \
104         count=0; for item in ${TO_REMOVE_LATE}; do \
105                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
106                         echo "${DESTDIR}$${item} is deprecated"; \
107                         deps=""; \
108                         for object in `cat $${tmpldd} | awk -v library=$${item} \
109                                 -f ${.CURDIR}/../tools/tools/chkldd/chkldd.awk`; do \
110                                 echo "${TO_REMOVE_LATE}" | grep -q "$${object}" \
111                                         || deps="$${deps} $${object}"; \
112                         done; \
113                         if [ -n "$${deps}" ]; then \
114                                 echo "  but it's still linked from these objects:"; \
115                                 echo "  " $${deps}; \
116                                 echo ""; \
117                         fi; \
118                         count=`expr $$count + 1`; \
119                 fi; \
120         done; \
121         rm $${tmpldd}; \
122         if [ "$$count" -gt 0 ]; then \
123                 echo "==================================================================" ; \
124                 echo "= You have $$count now deprecated files." ; \
125                 echo "= Once you are sure that none of your third party (ports or local)" ; \
126                 echo "= software are still using them, rerun with:" ; \
127                 echo "=     make upgrade -DREMOVE_DEPRECATED" ; \
128                 echo "==================================================================" ; \
129         fi;
130
131 preinstall:
132 .if exists(${DESTDIR}/etc/master.passwd)
133         sh ${.CURDIR}/../tools/pw-update.sh \
134                 -d ${DESTDIR}/etc \
135                 -g ${.CURDIR}/group \
136                 -p ${.CURDIR}/master.passwd
137 .endif
138
139 upgrade_check:
140         @if [ -n "`grep '^sendmail.*/usr/libexec/sendmail/sendmail' ${DESTDIR}/etc/mail/mailer.conf`" ]; then \
141                 echo "==================================================================" ; \
142                 echo "=  sendmail is being removed from the base system." ; \
143                 echo "=  /etc/mail/mailer.conf is still configured to use sendmail." ; \
144                 echo "=  See http://www.dragonflybsd.com/docs/docs/newhandbook/mta/" ; \
145                 echo "=  Quick: cp /usr/src/libexec/dma/mailer-conf/mailer.conf.dma " ; \
146                 echo "=            ${DESTDIR}/etc/mail/mailer.conf ; make upgrade" ; \
147                 echo "==================================================================" ; \
148                 /usr/bin/false ; \
149         fi
150
151 upgrade_base:   upgrade_check preinstall remove-obsolete-files
152         # files that should be dirs (not possible with Makefile_upgrade.inc)
153 .for f in usr/include/dev/misc/ppi usr/share/initrd/sbin var/db/entropy
154         [ -d ${DESTDIR}/${f} ] || rm -f ${DESTDIR}/${f}
155 .endfor
156 .if !defined(BINARY_UPGRADE) # binary upgrade just copies these files
157         cd ${UPGRADE_SRCDIR}/../share/mk; ${MAKE} install
158 .endif
159         cd ${UPGRADE_SRCDIR}; \
160             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
161                 ${BINUPDATE} ${DESTDIR}/etc; \
162             cap_mkdb ${DESTDIR}/etc/login.conf; \
163             for f in ${BIN1}; do \
164                 [ -e "${DESTDIR}/etc/$${f##*/}" ] || \
165                     ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
166                         $$f ${DESTDIR}/etc; \
167             done; \
168             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
169                 ${BIN2} ${DESTDIR}/etc
170         cd ${UPGRADE_SRCDIR}/defaults; \
171             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
172                 ${DEFAULTS} ${DESTDIR}/etc/defaults
173         cd ${UPGRADE_SRCDIR}/periodic; ${MAKE} install
174         mkdir -p ${DESTDIR}/etc/rc.d
175         cd ${UPGRADE_SRCDIR}/rc.d; ${MAKE} install
176         cd ${UPGRADE_SRCDIR}/devd; ${MAKE} install
177         # "../share/termcap/make etc-termcap" expanded inline here:
178         ${LN} -fs /usr/share/misc/termcap ${DESTDIR}/etc/termcap
179         # "../usr.sbin/rmt/make etc-rmt" expanded inline here:
180         ${LN} -fs /usr/sbin/rmt ${DESTDIR}/etc/rmt
181         cd ${UPGRADE_SRCDIR}/mtree; \
182             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
183                 ${MTREE} ${DESTDIR}/etc/mtree
184         cd ${UPGRADE_SRCDIR}/bluetooth; ${MAKE} install
185         cd ${UPGRADE_SRCDIR}/calendar; ${MAKE} install
186         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
187             ${UPGRADE_SRCDIR}/Makefile.usr ${DESTDIR}/usr/Makefile
188 .if !exists(${DESTDIR}/etc/pam.d)
189         mkdir -p ${DESTDIR}/etc/pam.d
190         cd ${UPGRADE_SRCDIR}/pam.d; ${MAKE} install
191         sh ${DESTDIR}/etc/pam.d/convert.sh ${DESTDIR}/etc/pam.d \
192             ${DESTDIR}/etc/pam.conf
193 .else
194 .for pamconf in README convert.sh atrun cron passwd su system
195 .if !exists(${DESTDIR}/etc/pam.d/${pamconf})
196         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
197             ${UPGRADE_SRCDIR}/pam.d/${pamconf} ${DESTDIR}/etc/pam.d
198 .endif
199 .endfor
200 .endif
201 .if !defined(BINARY_UPGRADE) # binary upgrade just copies these files
202         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
203             ${UPGRADE_SRCDIR}/../COPYRIGHT ${DESTDIR}/
204 .endif
205         rm -f ${DESTDIR}/usr/include/machine/ioctl_meteor.h
206         rm -f ${DESTDIR}/usr/include/machine/ioctl_bt848.h
207         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" \
208             ${DESTDIR}/usr/include/machine/ioctl_bt848.h
209         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" \
210             ${DESTDIR}/usr/include/machine/ioctl_meteor.h
211 .if exists(${DESTDIR}/usr/lib/gcc2)
212         ldconfig -m ${DESTDIR}/usr/lib/gcc2
213 .endif
214 .for lib in ${COMPAT_LIBS:M*.so.*}
215 .if exists(${DESTDIR}/usr/lib/${lib})
216         chflags noschg ${DESTDIR}/usr/lib/${lib}
217         rm -f ${DESTDIR}/usr/lib/${lib}
218 .endif
219 .endfor
220         cd ${.CURDIR}/../lib/libssh; ${MAKE} -f Makefile.etc install
221 .if exists(${DESTDIR}/boot)
222 .if exists(${DESTDIR}/kernel)
223         chflags noschg ${DESTDIR}/kernel
224         mv ${DESTDIR}/kernel ${DESTDIR}/boot/kernel
225         chflags schg ${DESTDIR}/boot/kernel
226 .endif
227 .if exists(${DESTDIR}/modules)
228         mv ${DESTDIR}/modules ${DESTDIR}/boot/modules
229         rm -rf ${DESTDIR}/boot/modules/modules
230 .endif
231 .if exists(${DESTDIR}/kernel.old)
232         mv ${DESTDIR}/kernel.old ${DESTDIR}/boot/kernel.old
233 .endif
234 .if exists(${DESTDIR}/modules.old)
235         mv ${DESTDIR}/modules.old ${DESTDIR}/boot/modules.old
236         rm -rf ${DESTDIR}/boot/modules.old/modules.old
237 .endif
238 .endif
239 .if exists(${DESTDIR}/etc/settings.conf)
240         mv ${DESTDIR}/etc/settings.conf ${DESTDIR}/etc/pkg_radd.conf
241 .endif
242         for ext in a so.0; do \
243                 f=${DESTDIR}/usr/lib/libpthread.$$ext; \
244                 dest=$$(readlink "$$f"); \
245                 case "$$dest" in \
246                 libthread_xu.*) \
247                         ln -fs thread/$$dest $$f ;; \
248                 esac; \
249         done
250         ldconfig -R
251         mkdir -p ${DESTDIR}/dev
252         mkdir -p ${DESTDIR}/var/run/sem
253         chmod 1777 ${DESTDIR}/var/run/sem
254
255         # The existence of cleartext_pass_ok means pam config files are out of date.
256         @set - `fgrep -e cleartext_pass_ok -e pam_opie ${DESTDIR}/etc/pam.d/*`; \
257         if [ $$# -gt 0 ] ; \
258         then \
259                 echo "It appears your PAM configuration files need to be updated"; \
260                 echo "This can be done by manually editing the files or:"; \
261                 echo "  cd ${UPGRADE_SRCDIR}/pam.d"; \
262                 echo "  make install"; \
263         fi
264
265         # dhcpcd had been made to chroot into /var/chroot/dhcp, which however
266         # is inappropriate, so move the dhcpcd duid, secret and lease files
267         # back and ensure the chroot (/var/empty) is empty.
268         DHCPCD_DB="${DESTDIR}/var/db/dhcpcd"; \
269         DHCPCD_CHROOT="/var/chroot/dhcp"; \
270         DHCPCD_CHROOT_DB="${DESTDIR}$$DHCPCD_CHROOT/var/db/dhcpcd"; \
271         if [ -f "$$DHCPCD_CHROOT_DB/duid" ] && \
272             [ ! -f "$$DHCPCD_DB/duid" ]; then \
273                 mv "$$DHCPCD_CHROOT_DB"/* "$$DHCPCD_DB"; \
274                 chown -R root:wheel "$$DHCPCD_DB"; \
275                 rm -rf "$$DHCPCD_CHROOT"; \
276         fi
277         sh ${.CURDIR}/../tools/pw-update.sh \
278                 -d ${DESTDIR}/etc \
279                 -g ${.CURDIR}/group \
280                 -p ${.CURDIR}/master.passwd \
281                 -U _dhcp
282
283 upgrade_etc:    upgrade_base remove-deprecated-files
284         @echo "Upgrade was successful"
285
286 distribution:
287         cd ${.CURDIR}; \
288             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
289                 ${BINUPDATE} ${DESTDIR}/etc; \
290             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
291                 ${BIN1} group ${DESTDIR}/etc; \
292             cap_mkdb ${DESTDIR}/etc/login.conf; \
293             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
294                 ${BIN2} ${DESTDIR}/etc; \
295             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
296                 master.passwd nsmb.conf ${DESTDIR}/etc; \
297             pwd_mkdb -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
298         cd ${.CURDIR}/defaults; \
299             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
300                 ${DEFAULTS} ${DESTDIR}/etc/defaults
301         cd ${.CURDIR}/pam.d; ${MAKE} install
302         cd ${.CURDIR}/bluetooth; ${MAKE} install
303         cd ${.CURDIR}/calendar; ${MAKE} install
304         cd ${.CURDIR}/periodic; ${MAKE} install
305         cd ${.CURDIR}/rc.d; ${MAKE} install
306         cd ${.CURDIR}/devd; ${MAKE} install
307         cd ${.CURDIR}/../share/termcap; ${MAKE} etc-termcap
308         cd ${.CURDIR}/../usr.sbin/rmt; ${MAKE} etc-rmt
309         cd ${.CURDIR}; \
310             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
311                 Makefile.usr ${DESTDIR}/usr/Makefile
312 .for dir in ${DIRS}
313 .if exists(${.CURDIR}/../${dir}/Makefile.etc)
314         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc obj
315         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc install
316 .endif
317 .endfor
318         mkdir -p ${DESTDIR}/dev
319         cd ${.CURDIR}/../share/skel; \
320             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
321                 dot.cshrc ${DESTDIR}/root/.cshrc; \
322             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
323                 dot.login ${DESTDIR}/root/.login; \
324             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
325                 dot.profile ${DESTDIR}/root/.profile; \
326             rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
327         cd ${.CURDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
328             ${MTREE} ${DESTDIR}/etc/mtree
329         cd ${.CURDIR}/ppp; ${INSTALL} -o root -g ${BINGRP} -m 600 \
330             ${PPPCNF} ${DESTDIR}/etc/ppp
331         cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
332             ${ETCMAIL} ${DESTDIR}/etc/mail
333         @if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
334               ! -f ${DESTDIR}/etc/aliases ]; then \
335                 set -x; \
336                 ${LN} -s mail/aliases ${DESTDIR}/etc/aliases; \
337         fi
338         ${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
339             ${DESTDIR}/etc/dumpdates
340         ${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
341             ${DESTDIR}/var/db/locate.database
342         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
343             ${DESTDIR}/var/log/auth.log
344         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
345             ${DESTDIR}/var/log/cron
346         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
347             ${DESTDIR}/var/log/daemon
348         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
349             ${DESTDIR}/var/log/lpd-errs
350         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
351             ${DESTDIR}/var/log/maillog
352         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
353             ${DESTDIR}/var/log/lastlogx
354         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
355             ${DESTDIR}/var/log/messages
356         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
357             ${DESTDIR}/var/log/security
358         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
359             ${DESTDIR}/var/log/slip.log
360         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
361             ${DESTDIR}/var/log/ppp.log
362         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
363             ${DESTDIR}/var/log/wtmpx
364         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
365             ${DESTDIR}/var/run/utmpx
366         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
367             ${DESTDIR}/var/crash
368         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
369             ${.CURDIR}/../COPYRIGHT ${DESTDIR}/
370         rm -f ${DESTDIR}/usr/include/machine/ioctl_bt848.h
371         rm -f ${DESTDIR}/usr/include/machine/ioctl_meteor.h
372         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" \
373             ${DESTDIR}/usr/include/machine/ioctl_bt848.h
374         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" \
375             ${DESTDIR}/usr/include/machine/ioctl_meteor.h
376 .if !defined(NOMAN)
377         cd ${.CURDIR}/../share/man; ${MAKE} makedb
378 .endif
379
380 #
381 #
382 distrib-dirs:
383         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.root.dist \
384                 -p ${DESTDIR}/
385         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.var.dist \
386                 -p ${DESTDIR}/var
387         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.usr.dist \
388                 -p ${DESTDIR}/usr
389         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.include.dist \
390                 -p ${DESTDIR}/usr/include
391         -chflags xlink ${DESTDIR}/* ${DESTDIR}/usr/* ${DESTDIR}/var/* \
392                         ${DESTDIR}/home/*
393         cd ${DESTDIR}/; test -e sys || (rm -f sys;  ${LN} -s usr/src/sys sys)
394 .if !defined(NO_SHARE)
395         cd ${DESTDIR}/usr/share/nls; \
396         rm -rf "POSIX"; \
397         rm -rf "en_US.US-ASCII"; \
398         ${LN} -s "C" "POSIX"; \
399         ${LN} -s "C" "en_US.US-ASCII"
400 .endif
401
402 etc-examples:
403         cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
404             ${BINUPDATE} ${BIN1} ${BIN2} \
405             group master.passwd nsmb.conf \
406             ${DESTDIR}/usr/share/examples/etc
407         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
408             ${DEFAULTS} ${DESTDIR}/usr/share/examples/etc/defaults
409
410 .include <bsd.prog.mk>