Merge branch 'vendor/DIFFUTILS'
[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 .endif
21
22 # Initial distribution files are installed read-write (644)
23 #
24 BIN1=   auth.conf auto_master \
25         crontab csh.cshrc csh.login csh.logout \
26         devtab dhclient.conf dntpd.conf \
27         ftpusers group \
28         hosts hosts.allow hosts.equiv hosts.lpd \
29         inetd.conf login.access login.conf \
30         motd modems netconfig networks newsyslog.conf \
31         nscd.conf pf.conf phones printcap profile \
32         regdomain.xml remote sensorsd.conf services \
33         shells sysctl.conf syslog.conf \
34         wpa_supplicant.conf \
35         etc.${MACHINE_ARCH}/ttys
36 .if defined(BINARY_UPGRADE) # location of these depends on upgrade method
37 BIN1+=  manpath.config
38 .else
39 BIN1+=  ${.CURDIR}/../gnu/usr.bin/man/manpath/manpath.config
40 .endif
41
42 DIRS+=  lib/libssh usr.bin/openssl usr.bin/ssh usr.sbin/sshd
43
44 # Files that should be installed read-only-executable (555) root:wheel
45 #
46 BIN2=   pccard_ether rc.suspend rc.resume
47
48 DEFAULTS= compilers.conf devfs.conf make.conf periodic.conf \
49           pfi.conf rc.conf uuids
50
51 MTREE=  BSD.include.dist BSD.root.dist BSD.usr.dist BSD.var.dist
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         @for item in ${TO_REMOVE:M*/man/man[1-9]/*:C@/man/man([1-9])/@/man/cat\1/@g}; do \
81                 if [ -e ${DESTDIR}$${item} ]; then \
82                         echo "${DESTDIR}$${item}"; \
83                         chflags -Rf noschg "${DESTDIR}$${item}"; \
84                         rm -rf "${DESTDIR}$${item}"; \
85                 fi; \
86         done
87
88 remove-deprecated-files:
89 .if defined(REMOVE_DEPRECATED)
90         @echo "===> Remove now deprecated files"
91         @for item in ${TO_REMOVE_LATE}; do \
92                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
93                         echo "${DESTDIR}$${item}"; \
94                         chflags -Rf noschg "${DESTDIR}$${item}"; \
95                         rm -rf "${DESTDIR}$${item}"; \
96                 fi; \
97         done;
98 .else
99         @echo "===> Checking for deprecated files"
100         @count=0; for item in ${TO_REMOVE_LATE}; do \
101                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
102                         echo "${DESTDIR}$${item} is deprecated"; \
103                         count=`expr $$count + 1`; \
104                 fi; \
105         done; \
106         if [ "$$count" -gt 0 ]; then \
107                 echo "==================================================================" ; \
108                 echo "= You have $$count now deprecated files." ; \
109                 echo "= Once you are sure that none of your third party (ports or local)" ; \
110                 echo "= software are still using them, rerun with REMOVE_DEPRECATED set." ; \
111                 echo "==================================================================" ; \
112         fi;
113 .endif
114
115 preupgrade:
116         (pw -V ${DESTDIR}/etc usershow mail -q > /dev/null) || \
117                 pw -V ${DESTDIR}/etc useradd mail -u 6 -g 6 \
118                    -c "Mail user" \
119                    -d /nonexistent -s /sbin/nologin
120         (pw -V ${DESTDIR}/etc usershow _pflogd -q > /dev/null) || \
121                 pw -V ${DESTDIR}/etc useradd _pflogd -u 64 \
122                    -c "pflogd privsep user" \
123                    -d /var/empty -s /sbin/nologin
124         (pw -V ${DESTDIR}/etc usershow _sdpd -q > /dev/null) || \
125                 pw -V ${DESTDIR}/etc useradd _sdpd -u 70 \
126                    -c "sdpd privsep user" \
127                    -d /var/empty -s /sbin/nologin
128         (pw -V ${DESTDIR}/etc usershow _dhcp -q > /dev/null) || \
129                 pw -V ${DESTDIR}/etc useradd _dhcp -u 77 \
130                    -c "DHCP programs" \
131                    -d /var/empty -s /sbin/nologin
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
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 rsh 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         rm -f ${DESTDIR}/usr/include/sys/ata.h
208         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" ${DESTDIR}/usr/include/machine/ioctl_bt848.h
209         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" ${DESTDIR}/usr/include/machine/ioctl_meteor.h
210         ${LN} -s nata.h ${DESTDIR}/usr/include/sys/ata.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 obj
221         cd ${.CURDIR}/../lib/libssh; ${MAKE} -f Makefile.etc install
222 .if exists(${DESTDIR}/boot)
223 .if exists(${DESTDIR}/kernel)
224         chflags noschg ${DESTDIR}/kernel
225         mv ${DESTDIR}/kernel ${DESTDIR}/boot/kernel
226         chflags schg ${DESTDIR}/boot/kernel
227 .endif
228 .if exists(${DESTDIR}/modules)
229         mv ${DESTDIR}/modules ${DESTDIR}/boot/modules
230         rm -rf ${DESTDIR}/boot/modules/modules
231 .endif
232 .if exists(${DESTDIR}/kernel.old)
233         mv ${DESTDIR}/kernel.old ${DESTDIR}/boot/kernel.old
234 .endif
235 .if exists(${DESTDIR}/modules.old)
236         mv ${DESTDIR}/modules.old ${DESTDIR}/boot/modules.old
237         rm -rf ${DESTDIR}/boot/modules.old/modules.old
238 .endif
239 .endif
240 .if exists(${DESTDIR}/etc/settings.conf)
241         mv ${DESTDIR}/etc/settings.conf ${DESTDIR}/etc/pkg_radd.conf
242 .endif
243         for ext in a so.0; do \
244                 f=${DESTDIR}/usr/lib/libpthread.$$ext; \
245                 dest=$$(readlink "$$f"); \
246                 case "$$dest" in \
247                 libthread_xu.*|libc_r.*) \
248                         ln -fs thread/$$dest $$f ;; \
249                 esac; \
250         done
251         ldconfig -R
252         mkdir -p ${DESTDIR}/dev
253         mkdir -p ${DESTDIR}/var/run/sem
254         chmod 1777 ${DESTDIR}/var/run/sem
255
256 # The existence of cleartext_pass_ok means pam config files are out of date.
257         @set - `fgrep cleartext_pass_ok ${DESTDIR}/etc/pam.d/*`; \
258         if [ $$# -gt 0 ] ; \
259         then \
260                 echo "It appears your PAM configuration files need to be updated"; \
261                 echo "This can be done by manually editing the files or:"; \
262                 echo "  cd ${UPGRADE_SRCDIR}/pam.d"; \
263                 echo "  make install"; \
264         fi
265
266 upgrade_etc:    upgrade_base remove-deprecated-files
267         @echo "Upgrade was successful"
268
269 distribution:
270         cd ${.CURDIR}; \
271             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
272                 ${BINUPDATE} ${DESTDIR}/etc; \
273             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
274                 ${BIN1} ${DESTDIR}/etc; \
275             cap_mkdb ${DESTDIR}/etc/login.conf; \
276             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
277                 ${BIN2} ${DESTDIR}/etc; \
278             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
279                 master.passwd nsmb.conf opieaccess ${DESTDIR}/etc; \
280             pwd_mkdb -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
281         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
282             ${DEFAULTS} ${DESTDIR}/etc/defaults
283         cd ${.CURDIR}/pam.d; ${MAKE} install
284         cd ${.CURDIR}/bluetooth; ${MAKE} install
285         cd ${.CURDIR}/periodic; ${MAKE} install
286         cd ${.CURDIR}/rc.d; ${MAKE} install 
287         cd ${.CURDIR}/devd; ${MAKE} install
288         cd ${.CURDIR}/autofs; ${MAKE} install
289         cd ${.CURDIR}/../share/termcap; ${MAKE} etc-termcap
290         cd ${.CURDIR}/../usr.sbin/rmt; ${MAKE} etc-rmt
291         cd ${.CURDIR}; \
292             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
293                 Makefile.usr ${DESTDIR}/usr/Makefile
294 .for dir in ${DIRS}
295 .if exists(${.CURDIR}/../${dir}/Makefile.etc)
296         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc obj
297         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc install
298 .endif
299 .endfor
300         mkdir -p ${DESTDIR}/dev
301         cd ${.CURDIR}/root; \
302             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
303                 dot.cshrc ${DESTDIR}/root/.cshrc; \
304             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
305                 dot.klogin ${DESTDIR}/root/.klogin; \
306             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
307                 dot.login ${DESTDIR}/root/.login; \
308             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
309                 dot.profile ${DESTDIR}/root/.profile; \
310             rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
311         cd ${.CURDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
312             ${MTREE} ${DESTDIR}/etc/mtree
313         cd ${.CURDIR}/ppp; ${INSTALL} -o root -g ${BINGRP} -m 600 \
314             ${PPPCNF} ${DESTDIR}/etc/ppp
315         cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
316             ${ETCMAIL} ${DESTDIR}/etc/mail
317         @if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
318               ! -f ${DESTDIR}/etc/aliases ]; then \
319                 set -x; \
320                 ${LN} -s mail/aliases ${DESTDIR}/etc/aliases; \
321         fi
322         ${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
323             ${DESTDIR}/etc/dumpdates
324         ${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
325             ${DESTDIR}/var/db/locate.database
326         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
327             ${DESTDIR}/var/log/auth.log
328         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
329             ${DESTDIR}/var/log/cron
330         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
331             ${DESTDIR}/var/log/daemon
332         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
333             ${DESTDIR}/var/log/lpd-errs
334         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
335             ${DESTDIR}/var/log/maillog
336         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
337             ${DESTDIR}/var/log/lastlog
338         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
339             ${DESTDIR}/var/log/lastlogx
340         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
341             ${DESTDIR}/var/log/messages
342         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
343             ${DESTDIR}/var/log/security
344         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
345             ${DESTDIR}/var/log/slip.log
346         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
347             ${DESTDIR}/var/log/ppp.log
348         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
349             ${DESTDIR}/var/log/wtmp
350         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
351             ${DESTDIR}/var/log/wtmpx
352         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
353             ${DESTDIR}/var/run/utmp
354         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
355             ${DESTDIR}/var/run/utmpx
356         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
357             ${DESTDIR}/var/crash
358         cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
359             COPYRIGHT ${DESTDIR}/
360         rm -f ${DESTDIR}/usr/include/machine/ioctl_bt848.h
361         rm -f ${DESTDIR}/usr/include/machine/ioctl_meteor.h
362         rm -f ${DESTDIR}/usr/include/sys/ata.h
363         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" ${DESTDIR}/usr/include/machine/ioctl_bt848.h
364         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" ${DESTDIR}/usr/include/machine/ioctl_meteor.h
365         ${LN} -s nata.h ${DESTDIR}/usr/include/sys/ata.h
366 .if !defined(NOMAN)
367         cd ${.CURDIR}/../share/man; ${MAKE} makedb
368 .endif
369
370 #
371 #
372 distrib-dirs:
373         mtree -deU -f ${.CURDIR}/mtree/BSD.root.dist -p ${DESTDIR}/
374         mtree -deU -f ${.CURDIR}/mtree/BSD.var.dist -p ${DESTDIR}/var
375         mtree -deU -f ${.CURDIR}/mtree/BSD.usr.dist -p ${DESTDIR}/usr
376         mtree -deU -f ${.CURDIR}/mtree/BSD.include.dist \
377                 -p ${DESTDIR}/usr/include
378         -chflags xlink ${DESTDIR}/* ${DESTDIR}/usr/* ${DESTDIR}/var/* \
379                         ${DESTDIR}/home/*
380         cd ${DESTDIR}/; test -e sys || (rm -f sys;  ${LN} -s usr/src/sys sys)
381 .if !defined(NO_SHARE)
382         cd ${DESTDIR}/usr/share/nls; \
383         rm -rf "POSIX"; \
384         rm -rf "en_US.US-ASCII"; \
385         ${LN} -s "C" "POSIX"; \
386         ${LN} -s "C" "en_US.US-ASCII"
387 .endif
388
389 etc-examples:
390         cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
391             ${BINUPDATE} ${BIN1} ${BIN2} nsmb.conf opieaccess \
392             ${DESTDIR}/usr/share/examples/etc
393         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
394             ${DEFAULTS} ${DESTDIR}/usr/share/examples/etc/defaults
395
396 .include <bsd.prog.mk>