1140b6126774aaff61328d3830b62baa665632fe
[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 gettytab network.subr \
9         pf.os \
10         protocols \
11         rc rc.firewall rc.firewall6 \
12         rc.sendmail rc.shutdown \
13         rc.subr 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 auto_master \
27         crontab csh.cshrc csh.login csh.logout \
28         devtab dhclient.conf dntpd.conf \
29         ftpusers group \
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         regdomain.xml 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 # Include file which contains obsolete files
62 .if exists(${DESTDIR}/etc/upgrade/Makefile_upgrade.inc)
63 .include "${DESTDIR}/etc/upgrade/Makefile_upgrade.inc"
64 .endif
65
66 remove-obsolete-files:
67         @if [ -z "${TO_REMOVE}" ]; then \
68                 echo "Please do a 'make installworld' first."; \
69                 echo "See build(7) for further information."; \
70                 /usr/bin/false; \
71         fi;
72         @echo "===> Remove now obsolete files"
73         @for item in ${TO_REMOVE}; do \
74                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
75                         echo "${DESTDIR}$${item}"; \
76                         chflags -Rf noschg "${DESTDIR}$${item}"; \
77                         rm -rf "${DESTDIR}$${item}"; \
78                 fi; \
79         done;
80
81 remove-deprecated-files:
82 .if defined(REMOVE_DEPRECATED)
83         @echo "===> Remove now deprecated files"
84         @for item in ${TO_REMOVE_LATE}; do \
85                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
86                         echo "${DESTDIR}$${item}"; \
87                         chflags -Rf noschg "${DESTDIR}$${item}"; \
88                         rm -rf "${DESTDIR}$${item}"; \
89                 fi; \
90         done;
91 .else
92         @echo "===> Checking for deprecated files"
93         @count=0; for item in ${TO_REMOVE_LATE}; do \
94                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
95                         echo "${DESTDIR}$${item} is deprecated"; \
96                         count=`expr $$count + 1`; \
97                 fi; \
98         done; \
99         if [ "$$count" -gt 0 ]; then \
100                 echo "==================================================================" ; \
101                 echo "= You have $$count now deprecated files." ; \
102                 echo "= Once you are sure that none of your third party (ports or local)" ; \
103                 echo "= software are still using them, rerun with:" ; \
104                 echo "=     make upgrade -DREMOVE_DEPRECATED" ; \
105                 echo "==================================================================" ; \
106         fi;
107 .endif
108
109 preupgrade:
110         (pw -V ${DESTDIR}/etc usershow mail -q > /dev/null) || \
111                 pw -V ${DESTDIR}/etc useradd mail -u 6 -g 6 \
112                    -c "Mail user" \
113                    -d /nonexistent -s /sbin/nologin
114         (pw -V ${DESTDIR}/etc usershow _pflogd -q > /dev/null) || \
115                 pw -V ${DESTDIR}/etc useradd _pflogd -u 64 \
116                    -c "pflogd privsep user" \
117                    -d /var/empty -s /sbin/nologin
118         (pw -V ${DESTDIR}/etc usershow _sdpd -q > /dev/null) || \
119                 pw -V ${DESTDIR}/etc useradd _sdpd -u 70 \
120                    -c "sdpd privsep user" \
121                    -d /var/empty -s /sbin/nologin
122         (pw -V ${DESTDIR}/etc usershow _dhcp -q > /dev/null) || \
123                 pw -V ${DESTDIR}/etc useradd _dhcp -u 77 \
124                    -c "DHCP programs" \
125                    -d /var/chroot/dhcp -s /sbin/nologin
126         if [ `pw -V ${DESTDIR}/etc usershow _dhcp | cut -d: -f9` = /var/empty ]; then \
127                 pw -V ${DESTDIR}/etc usermod _dhcp -d /var/chroot/dhcp; \
128                 mkdir -p ${DESTDIR}/var/chroot/dhcp; \
129         fi
130         (pw -V ${DESTDIR}/etc groupshow input -q > /dev/null) || \
131                 pw -V ${DESTDIR}/etc groupadd input -g 43
132         (pw -V ${DESTDIR}/etc groupshow video -q > /dev/null) || \
133                 pw -V ${DESTDIR}/etc groupadd video -g 44
134         (pw -V ${DESTDIR}/etc groupshow authpf -q > /dev/null) || \
135                 pw -V ${DESTDIR}/etc groupadd authpf -g 63
136         (pw -V ${DESTDIR}/etc groupshow _pflogd -q > /dev/null) || \
137                 pw -V ${DESTDIR}/etc groupadd _pflogd -g 64
138         (pw -V ${DESTDIR}/etc groupshow _sdpd -q > /dev/null) || \
139                 pw -V ${DESTDIR}/etc groupadd _sdpd -g 70
140         (pw -V ${DESTDIR}/etc groupshow _dhcp -q > /dev/null) || \
141                 pw -V ${DESTDIR}/etc groupadd _dhcp -g 77
142
143 upgrade_check:
144         @if [ -n "`grep '^sendmail.*/usr/libexec/sendmail/sendmail' ${DESTDIR}/etc/mail/mailer.conf`" ]; then \
145                 echo "==================================================================" ; \
146                 echo "=  sendmail is being removed from the base system." ; \
147                 echo "=  /etc/mail/mailer.conf is still configured to use sendmail." ; \
148                 echo "=  See http://www.dragonflybsd.com/docs/docs/newhandbook/mta/" ; \
149                 echo "=  Quick: cp /usr/src/libexec/dma/mailer-conf/mailer.conf.dma " ; \
150                 echo "=            ${DESTDIR}/etc/mail/mailer.conf ; make upgrade" ; \
151                 echo "==================================================================" ; \
152                 /usr/bin/false ; \
153         fi
154
155 upgrade_base:   upgrade_check preupgrade remove-obsolete-files
156         # files that should be dirs (not possible with Makefile_upgrade.inc)
157 .for f in usr/include/dev/misc/ppi usr/share/initrd/sbin var/db/entropy
158         [ -d ${DESTDIR}/${f} ] || rm -f ${DESTDIR}/${f}
159 .endfor
160 .if !defined(BINARY_UPGRADE) # binary upgrade just copies these files
161         cd ${UPGRADE_SRCDIR}/../share/mk; ${MAKE} install
162 .endif
163         cd ${UPGRADE_SRCDIR}; \
164             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
165                 ${BINUPDATE} ${DESTDIR}/etc; \
166             cap_mkdb ${DESTDIR}/etc/login.conf; \
167             for f in ${BIN1}; do \
168                 [ -e "${DESTDIR}/etc/$${f##*/}" ] || \
169                     ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
170                         $$f ${DESTDIR}/etc; \
171             done; \
172             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
173                 ${BIN2} ${DESTDIR}/etc;
174         cd ${UPGRADE_SRCDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
175             ${DEFAULTS} ${DESTDIR}/etc/defaults
176         cd ${UPGRADE_SRCDIR}/periodic; ${MAKE} install
177         mkdir -p ${DESTDIR}/etc/rc.d
178         cd ${UPGRADE_SRCDIR}/rc.d; ${MAKE} install
179         cd ${UPGRADE_SRCDIR}/devd; ${MAKE} install
180         mkdir -p ${DESTDIR}/etc/autofs
181         cd ${UPGRADE_SRCDIR}/autofs; ${MAKE} install
182         # "../share/termcap/make etc-termcap" expanded inline here:
183         ${LN} -fs /usr/share/misc/termcap ${DESTDIR}/etc/termcap
184         # "../usr.sbin/rmt/make etc-rmt" expanded inline here:
185         ${LN} -fs /usr/sbin/rmt ${DESTDIR}/etc/rmt
186         cd ${UPGRADE_SRCDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
187             ${MTREE} ${DESTDIR}/etc/mtree
188         cd ${UPGRADE_SRCDIR}/bluetooth; ${MAKE} install
189         cd ${UPGRADE_SRCDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 Makefile.usr ${DESTDIR}/usr/Makefile
190 .if !exists(${DESTDIR}/etc/pam.d)
191         mkdir -p ${DESTDIR}/etc/pam.d
192         cd ${UPGRADE_SRCDIR}/pam.d; ${MAKE} install
193         sh ${DESTDIR}/etc/pam.d/convert.sh ${DESTDIR}/etc/pam.d ${DESTDIR}/etc/pam.conf
194 .else
195 .for pamconf in README convert.sh atrun cron passwd su system
196 .if !exists(${DESTDIR}/etc/pam.d/${pamconf})
197         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${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         cd ${UPGRADE_SRCDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
203             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" ${DESTDIR}/usr/include/machine/ioctl_bt848.h
208         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" ${DESTDIR}/usr/include/machine/ioctl_meteor.h
209 .if exists(${DESTDIR}/usr/lib/gcc2)
210         ldconfig -m ${DESTDIR}/usr/lib/gcc2
211 .endif
212 .for lib in ${COMPAT_LIBS:M*.so.*}
213 .if exists(${DESTDIR}/usr/lib/${lib})
214         chflags noschg ${DESTDIR}/usr/lib/${lib}
215         rm -f ${DESTDIR}/usr/lib/${lib}
216 .endif
217 .endfor
218         cd ${.CURDIR}/../lib/libssh; ${MAKE} -f Makefile.etc install
219 .if exists(${DESTDIR}/boot)
220 .if exists(${DESTDIR}/kernel)
221         chflags noschg ${DESTDIR}/kernel
222         mv ${DESTDIR}/kernel ${DESTDIR}/boot/kernel
223         chflags schg ${DESTDIR}/boot/kernel
224 .endif
225 .if exists(${DESTDIR}/modules)
226         mv ${DESTDIR}/modules ${DESTDIR}/boot/modules
227         rm -rf ${DESTDIR}/boot/modules/modules
228 .endif
229 .if exists(${DESTDIR}/kernel.old)
230         mv ${DESTDIR}/kernel.old ${DESTDIR}/boot/kernel.old
231 .endif
232 .if exists(${DESTDIR}/modules.old)
233         mv ${DESTDIR}/modules.old ${DESTDIR}/boot/modules.old
234         rm -rf ${DESTDIR}/boot/modules.old/modules.old
235 .endif
236 .endif
237 .if exists(${DESTDIR}/etc/settings.conf)
238         mv ${DESTDIR}/etc/settings.conf ${DESTDIR}/etc/pkg_radd.conf
239 .endif
240         for ext in a so.0; do \
241                 f=${DESTDIR}/usr/lib/libpthread.$$ext; \
242                 dest=$$(readlink "$$f"); \
243                 case "$$dest" in \
244                 libthread_xu.*) \
245                         ln -fs thread/$$dest $$f ;; \
246                 esac; \
247         done
248         ldconfig -R
249         mkdir -p ${DESTDIR}/dev
250         mkdir -p ${DESTDIR}/var/run/sem
251         chmod 1777 ${DESTDIR}/var/run/sem
252
253 # The existence of cleartext_pass_ok means pam config files are out of date.
254         @set - `fgrep -e cleartext_pass_ok -e pam_opie ${DESTDIR}/etc/pam.d/*`; \
255         if [ $$# -gt 0 ] ; \
256         then \
257                 echo "It appears your PAM configuration files need to be updated"; \
258                 echo "This can be done by manually editing the files or:"; \
259                 echo "  cd ${UPGRADE_SRCDIR}/pam.d"; \
260                 echo "  make install"; \
261         fi
262
263 # Move the dhcpcd duid, secret and lease files to the chroot
264 # to ensure users get the same address upon restarting.
265         DHCPCD_CHROOT=`pw -V ${DESTDIR}/etc usershow _dhcp | cut -d: -f9`; \
266         DHCPCD_CHROOT_DB="${DESTDIR}$$DHCPCD_CHROOT/var/db/dhcpcd"; \
267         if [ -f "${DESTDIR}/var/db/dhcpcd/duid" ] && \
268            [ ! -f "$$DHCPCD_CHROOT_DB/duid" ]; then \
269                 mkdir -p "$$DHCPCD_CHROOT_DB" && \
270                 mv "${DESTDIR}/var/db/dhcpcd/"* "$$DHCPCD_CHROOT_DB"; \
271                 chown -R _dhcp:_dhcp "$$DHCPCD_CHROOT"; \
272                 rmdir "${DESTDIR}/var/db/dhcpcd"; \
273         fi
274
275 upgrade_etc:    upgrade_base remove-deprecated-files
276         @echo "Upgrade was successful"
277
278 distribution:
279         cd ${.CURDIR}; \
280             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
281                 ${BINUPDATE} ${DESTDIR}/etc; \
282             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
283                 ${BIN1} ${DESTDIR}/etc; \
284             cap_mkdb ${DESTDIR}/etc/login.conf; \
285             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
286                 ${BIN2} ${DESTDIR}/etc; \
287             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
288                 master.passwd nsmb.conf ${DESTDIR}/etc; \
289             pwd_mkdb -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
290         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
291             ${DEFAULTS} ${DESTDIR}/etc/defaults
292         cd ${.CURDIR}/pam.d; ${MAKE} install
293         cd ${.CURDIR}/bluetooth; ${MAKE} install
294         cd ${.CURDIR}/periodic; ${MAKE} install
295         cd ${.CURDIR}/rc.d; ${MAKE} install
296         cd ${.CURDIR}/devd; ${MAKE} install
297         cd ${.CURDIR}/autofs; ${MAKE} install
298         cd ${.CURDIR}/../share/termcap; ${MAKE} etc-termcap
299         cd ${.CURDIR}/../usr.sbin/rmt; ${MAKE} etc-rmt
300         cd ${.CURDIR}; \
301             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
302                 Makefile.usr ${DESTDIR}/usr/Makefile
303 .for dir in ${DIRS}
304 .if exists(${.CURDIR}/../${dir}/Makefile.etc)
305         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc obj
306         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc install
307 .endif
308 .endfor
309         mkdir -p ${DESTDIR}/dev
310         cd ${.CURDIR}/root; \
311             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
312                 dot.cshrc ${DESTDIR}/root/.cshrc; \
313             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
314                 dot.klogin ${DESTDIR}/root/.klogin; \
315             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
316                 dot.login ${DESTDIR}/root/.login; \
317             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
318                 dot.profile ${DESTDIR}/root/.profile; \
319             rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
320         cd ${.CURDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
321             ${MTREE} ${DESTDIR}/etc/mtree
322         cd ${.CURDIR}/ppp; ${INSTALL} -o root -g ${BINGRP} -m 600 \
323             ${PPPCNF} ${DESTDIR}/etc/ppp
324         cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
325             ${ETCMAIL} ${DESTDIR}/etc/mail
326         @if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
327               ! -f ${DESTDIR}/etc/aliases ]; then \
328                 set -x; \
329                 ${LN} -s mail/aliases ${DESTDIR}/etc/aliases; \
330         fi
331         ${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
332             ${DESTDIR}/etc/dumpdates
333         ${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
334             ${DESTDIR}/var/db/locate.database
335         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
336             ${DESTDIR}/var/log/auth.log
337         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
338             ${DESTDIR}/var/log/cron
339         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
340             ${DESTDIR}/var/log/daemon
341         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
342             ${DESTDIR}/var/log/lpd-errs
343         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
344             ${DESTDIR}/var/log/maillog
345         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
346             ${DESTDIR}/var/log/lastlogx
347         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
348             ${DESTDIR}/var/log/messages
349         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
350             ${DESTDIR}/var/log/security
351         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
352             ${DESTDIR}/var/log/slip.log
353         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
354             ${DESTDIR}/var/log/ppp.log
355         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
356             ${DESTDIR}/var/log/wtmpx
357         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
358             ${DESTDIR}/var/run/utmpx
359         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
360             ${DESTDIR}/var/crash
361         cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
362             COPYRIGHT ${DESTDIR}/
363         rm -f ${DESTDIR}/usr/include/machine/ioctl_bt848.h
364         rm -f ${DESTDIR}/usr/include/machine/ioctl_meteor.h
365         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" ${DESTDIR}/usr/include/machine/ioctl_bt848.h
366         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" ${DESTDIR}/usr/include/machine/ioctl_meteor.h
367 .if !defined(NOMAN)
368         cd ${.CURDIR}/../share/man; ${MAKE} makedb
369 .endif
370
371 #
372 #
373 distrib-dirs:
374         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.root.dist \
375                 -p ${DESTDIR}/
376         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.var.dist \
377                 -p ${DESTDIR}/var
378         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.usr.dist \
379                 -p ${DESTDIR}/usr
380         mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/mtree/BSD.include.dist \
381                 -p ${DESTDIR}/usr/include
382         -chflags xlink ${DESTDIR}/* ${DESTDIR}/usr/* ${DESTDIR}/var/* \
383                         ${DESTDIR}/home/*
384         cd ${DESTDIR}/; test -e sys || (rm -f sys;  ${LN} -s usr/src/sys sys)
385 .if !defined(NO_SHARE)
386         cd ${DESTDIR}/usr/share/nls; \
387         rm -rf "POSIX"; \
388         rm -rf "en_US.US-ASCII"; \
389         ${LN} -s "C" "POSIX"; \
390         ${LN} -s "C" "en_US.US-ASCII"
391 .endif
392
393 etc-examples:
394         cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
395             ${BINUPDATE} ${BIN1} ${BIN2} nsmb.conf \
396             ${DESTDIR}/usr/share/examples/etc
397         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
398             ${DEFAULTS} ${DESTDIR}/usr/share/examples/etc/defaults
399
400 .include <bsd.prog.mk>