sensor: Factor out helper functions.
[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= apmd.conf devd.conf fbtab gettytab network.subr \
9         pf.os \
10         protocols \
11         rc 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=   amd.map auth.conf \
25         crontab csh.cshrc csh.login csh.logout \
26         devtab dhclient.conf dm.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         hostapd.conf 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 .if exists(${.CURDIR}/../crypto) && !defined(NO_OPENSSL)
43 .if !defined(NO_OPENSSH)
44 DIRS+=  secure/lib/libssh \
45         secure/usr.bin/ssh \
46         secure/usr.sbin/sshd
47 .endif
48 DIRS+=  secure/usr.bin/openssl
49 .endif
50
51 # Files that should be installed read-only-executable (555) root:wheel
52 #
53 BIN2=   pccard_ether rc.firewall rc.suspend rc.resume
54
55 DEFAULTS= compilers.conf devfs.conf make.conf mkinitrd.conf periodic.conf \
56           pfi.conf rc.conf uuids
57
58 MTREE=  BSD.include.dist BSD.local.dist BSD.root.dist BSD.usr.dist \
59         BSD.var.dist
60
61 PPPCNF= ppp.conf
62
63 ETCMAIL=aliases mailer.conf access.sample virtusertable.sample \
64         mailertable.sample
65
66 # List of libraries in /usr/lib/compat that might have to be removed
67 # from /usr/lib.
68 .if ${MACHINE_ARCH} == "i386"
69 COMPAT_LIBS != cd ${DESTDIR}/usr/lib/compat && find . -name '*.so.*'
70 .endif
71
72 # Use this directory as the source for new configuration files when upgrading
73 UPGRADE_SRCDIR?=${.CURDIR}
74
75 # Include file which contains obsolete files
76 .if exists(${DESTDIR}/etc/upgrade/Makefile_upgrade.inc)
77 .include "${DESTDIR}/etc/upgrade/Makefile_upgrade.inc"
78 .endif
79
80 remove-obsolete-files:
81         @if [ -z "${TO_REMOVE}" ]; then \
82                 echo "Please do a 'make installworld' first."; \
83                 echo "See build(7) for further information."; \
84                 /usr/bin/false; \
85         fi;
86         @echo "===> Remove now obsolete files"
87         @for item in ${TO_REMOVE}; do \
88                 if [ -e ${DESTDIR}$${item} -o -L ${DESTDIR}$${item} ]; then \
89                         echo "${DESTDIR}$${item}"; \
90                         chflags -Rf noschg "${DESTDIR}$${item}"; \
91                         rm -rf "${DESTDIR}$${item}"; \
92                 fi; \
93         done;
94         @for item in ${TO_REMOVE:M*/man/man[1-9]/*:C@/man/man([1-9])/@/man/cat\1/@g}; do \
95                 if [ -e ${DESTDIR}$${item} ]; then \
96                         echo "${DESTDIR}$${item}"; \
97                         chflags -Rf noschg "${DESTDIR}$${item}"; \
98                         rm -rf "${DESTDIR}$${item}"; \
99                 fi; \
100         done
101
102 preupgrade:
103         (pw -V ${DESTDIR}/etc usershow mail -q > /dev/null) || \
104                 pw -V ${DESTDIR}/etc useradd mail -u 6 -g 6 \
105                    -c "Mail user" \
106                    -d /nonexistent -s /sbin/nologin
107         (pw -V ${DESTDIR}/etc usershow _pflogd -q > /dev/null) || \
108                 pw -V ${DESTDIR}/etc useradd _pflogd -u 64 \
109                    -c "pflogd privsep user" \
110                    -d /var/empty -s /sbin/nologin
111         (pw -V ${DESTDIR}/etc usershow _sdpd -q > /dev/null) || \
112                 pw -V ${DESTDIR}/etc useradd _sdpd -u 70 \
113                    -c "sdpd privsep user" \
114                    -d /var/empty -s /sbin/nologin
115         (pw -V ${DESTDIR}/etc usershow _dhcp -q > /dev/null) || \
116                 pw -V ${DESTDIR}/etc useradd _dhcp -u 77 \
117                    -c "DHCP programs" \
118                    -d /var/empty -s /sbin/nologin
119         (pw -V ${DESTDIR}/etc groupshow authpf -q > /dev/null) || \
120                 pw -V ${DESTDIR}/etc groupadd authpf -g 63
121         (pw -V ${DESTDIR}/etc groupshow _pflogd -q > /dev/null) || \
122                 pw -V ${DESTDIR}/etc groupadd _pflogd -g 64
123         (pw -V ${DESTDIR}/etc groupshow _sdpd -q > /dev/null) || \
124                 pw -V ${DESTDIR}/etc groupadd _sdpd -g 70
125         (pw -V ${DESTDIR}/etc groupshow _dhcp -q > /dev/null) || \
126                 pw -V ${DESTDIR}/etc groupadd _dhcp -g 77
127
128 upgrade_check:
129         @if [ -n "`grep '^sendmail.*/usr/libexec/sendmail/sendmail' ${DESTDIR}/etc/mail/mailer.conf`" ]; then \
130                 echo "==================================================================" ; \
131                 echo "=  sendmail is being removed from the base system." ; \
132                 echo "=  /etc/mail/mailer.conf is still configured to use sendmail." ; \
133                 echo "=  See http://www.dragonflybsd.com/docs/docs/newhandbook/mta/" ; \
134                 echo "=  Quick: cp /usr/src/libexec/dma/mailer-conf/mailer.conf.dma " ; \
135                 echo "=            ${DESTDIR}/etc/mail/mailer.conf ; make upgrade" ; \
136                 echo "==================================================================" ; \
137                 /usr/bin/false ; \
138         fi
139
140 upgrade_etc:    upgrade_check preupgrade remove-obsolete-files
141         # files that should be dirs (not possible with Makefile_upgrade.inc)
142 .for f in usr/include/dev/misc/ppi usr/share/initrd/sbin
143         [ -d ${DESTDIR}/${f} ] || rm -f ${DESTDIR}/${f}
144 .endfor
145 .if !defined(BINARY_UPGRADE) # binary upgrade just copies these files
146         cd ${UPGRADE_SRCDIR}/../share/mk; ${MAKE} install
147 .endif
148         cd ${UPGRADE_SRCDIR}; \
149             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
150                 ${BINUPDATE} ${DESTDIR}/etc; \
151             cap_mkdb ${DESTDIR}/etc/login.conf; \
152             for f in ${BIN1}; do \
153                 [ -e "${DESTDIR}/etc/$${f##*/}" ] || \
154                     ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
155                         $$f ${DESTDIR}/etc; \
156             done; \
157             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
158                 ${BIN2} ${DESTDIR}/etc;
159         cd ${UPGRADE_SRCDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
160             ${DEFAULTS} ${DESTDIR}/etc/defaults
161         cd ${UPGRADE_SRCDIR}/periodic; ${MAKE} install
162         mkdir -p ${DESTDIR}/etc/rc.d
163         cd ${UPGRADE_SRCDIR}/rc.d; ${MAKE} install 
164         cd ${UPGRADE_SRCDIR}/devd; ${MAKE} install
165         # "../share/termcap/make etc-termcap" expanded inline here:
166         ${LN} -fs /usr/share/misc/termcap ${DESTDIR}/etc/termcap
167         # "../usr.sbin/rmt/make etc-rmt" expanded inline here:
168         ${LN} -fs /usr/sbin/rmt ${DESTDIR}/etc/rmt
169         cd ${UPGRADE_SRCDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
170             ${MTREE} ${DESTDIR}/etc/mtree
171         cd ${UPGRADE_SRCDIR}/bluetooth; ${MAKE} install
172         cd ${UPGRADE_SRCDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 Makefile.usr ${DESTDIR}/usr/Makefile
173 .if !exists(${DESTDIR}/etc/pam.d)
174         mkdir -p ${DESTDIR}/etc/pam.d
175         cd ${UPGRADE_SRCDIR}/pam.d; ${MAKE} install
176         sh ${DESTDIR}/etc/pam.d/convert.sh ${DESTDIR}/etc/pam.d ${DESTDIR}/etc/pam.conf
177 .else
178 .for pamconf in README convert.sh atrun cron passwd rsh su system
179 .if !exists(${DESTDIR}/etc/pam.d/${pamconf})
180         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${UPGRADE_SRCDIR}/pam.d/${pamconf} ${DESTDIR}/etc/pam.d
181 .endif
182 .endfor
183 .endif
184         # these removals must occur AFTER any pam conversion
185         csh -c "rm -f /usr/lib/pam_{cleartext_pass_ok,deny,opie,opieaccess,permit,radius,skey,ssh,tacplus,unix}.so"
186         rm -f /etc/pam.conf
187 .if !defined(BINARY_UPGRADE) # binary upgrade just copies these files
188         cd ${UPGRADE_SRCDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
189             COPYRIGHT ${DESTDIR}/
190 .endif
191         rm -f ${DESTDIR}/usr/include/machine/ioctl_meteor.h
192         rm -f ${DESTDIR}/usr/include/machine/ioctl_bt848.h
193         rm -f ${DESTDIR}/usr/include/sys/ata.h
194         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" ${DESTDIR}/usr/include/machine/ioctl_bt848.h
195         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" ${DESTDIR}/usr/include/machine/ioctl_meteor.h
196         ${LN} -s nata.h ${DESTDIR}/usr/include/sys/ata.h
197 .if exists(${DESTDIR}/usr/lib/gcc2)
198         ldconfig -m ${DESTDIR}/usr/lib/gcc2
199 .endif
200 .for lib in ${COMPAT_LIBS:M*.so.*}
201 .if exists(${DESTDIR}/usr/lib/${lib})
202         chflags noschg ${DESTDIR}/usr/lib/${lib}
203         rm -f ${DESTDIR}/usr/lib/${lib}
204 .endif
205 .endfor
206 .if !defined(NO_OPENSSH)
207         cd ${.CURDIR}/../secure/lib/libssh; ${MAKE} -f Makefile.etc obj
208         cd ${.CURDIR}/../secure/lib/libssh; ${MAKE} -f Makefile.etc install
209 .endif
210 .if exists(${DESTDIR}/boot)
211 .if exists(${DESTDIR}/kernel)
212         chflags noschg ${DESTDIR}/kernel
213         mv ${DESTDIR}/kernel ${DESTDIR}/boot/kernel
214         chflags schg ${DESTDIR}/boot/kernel
215 .endif
216 .if exists(${DESTDIR}/modules)
217         mv ${DESTDIR}/modules ${DESTDIR}/boot/modules
218         rm -rf ${DESTDIR}/boot/modules/modules
219 .endif
220 .if exists(${DESTDIR}/kernel.old)
221         mv ${DESTDIR}/kernel.old ${DESTDIR}/boot/kernel.old
222 .endif
223 .if exists(${DESTDIR}/modules.old)
224         mv ${DESTDIR}/modules.old ${DESTDIR}/boot/modules.old
225         rm -rf ${DESTDIR}/boot/modules.old/modules.old
226 .endif
227 .endif
228 .if exists(${DESTDIR}/etc/settings.conf)
229         mv ${DESTDIR}/etc/settings.conf ${DESTDIR}/etc/pkg_radd.conf
230 .endif
231         for ext in a so.0; do \
232                 f=${DESTDIR}/usr/lib/libpthread.$$ext; \
233                 dest=$$(readlink "$$f"); \
234                 case "$$dest" in \
235                 libthread_xu.*|libc_r.*) \
236                         ln -fs thread/$$dest $$f ;; \
237                 esac; \
238         done
239         ldconfig -R
240         mkdir -p ${DESTDIR}/dev
241
242 # The existence of cleartext_pass_ok means pam config files are out of date.
243         @set - `fgrep cleartext_pass_ok ${DESTDIR}/etc/pam.d/*`; \
244         if [ $$# -gt 0 ] ; \
245         then \
246                 echo "It appears your PAM configuration files need to be updated"; \
247                 echo "This can be done by manually editing the files or:"; \
248                 echo "  cd ${UPGRADE_SRCDIR}/pam.d"; \
249                 echo "  make install"; \
250         fi
251
252 distribution:
253         cd ${.CURDIR}; \
254             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
255                 ${BINUPDATE} ${DESTDIR}/etc; \
256             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
257                 ${BIN1} ${DESTDIR}/etc; \
258             cap_mkdb ${DESTDIR}/etc/login.conf; \
259             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 555 \
260                 ${BIN2} ${DESTDIR}/etc; \
261             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
262                 master.passwd nsmb.conf opieaccess ${DESTDIR}/etc; \
263             pwd_mkdb -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
264         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
265             ${DEFAULTS} ${DESTDIR}/etc/defaults
266         cd ${.CURDIR}/pam.d; ${MAKE} install
267         cd ${.CURDIR}/bluetooth; ${MAKE} install
268         cd ${.CURDIR}/periodic; ${MAKE} install
269         cd ${.CURDIR}/rc.d; ${MAKE} install 
270         cd ${.CURDIR}/devd; ${MAKE} install
271         cd ${.CURDIR}/../share/termcap; ${MAKE} etc-termcap
272         cd ${.CURDIR}/../usr.sbin/rmt; ${MAKE} etc-rmt
273         cd ${.CURDIR}; \
274             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
275                 Makefile.usr ${DESTDIR}/usr/Makefile
276 .for dir in ${DIRS}
277 .if exists(${.CURDIR}/../${dir}/Makefile.etc)
278         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc obj
279         cd ${.CURDIR}/../${dir}; ${MAKE} -f Makefile.etc install
280 .endif
281 .endfor
282         mkdir -p ${DESTDIR}/dev
283         cd ${.CURDIR}/root; \
284             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
285                 dot.cshrc ${DESTDIR}/root/.cshrc; \
286             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
287                 dot.klogin ${DESTDIR}/root/.klogin; \
288             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
289                 dot.login ${DESTDIR}/root/.login; \
290             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
291                 dot.profile ${DESTDIR}/root/.profile; \
292             rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
293         cd ${.CURDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
294             ${MTREE} ${DESTDIR}/etc/mtree
295         cd ${.CURDIR}/ppp; ${INSTALL} -o root -g ${BINGRP} -m 600 \
296             ${PPPCNF} ${DESTDIR}/etc/ppp
297         cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
298             ${ETCMAIL} ${DESTDIR}/etc/mail
299         @if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
300               ! -f ${DESTDIR}/etc/aliases ]; then \
301                 set -x; \
302                 ${LN} -s mail/aliases ${DESTDIR}/etc/aliases; \
303         fi
304         ${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
305             ${DESTDIR}/etc/dumpdates
306         ${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
307             ${DESTDIR}/var/db/locate.database
308         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
309             ${DESTDIR}/var/log/auth.log
310         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
311             ${DESTDIR}/var/log/cron
312         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
313             ${DESTDIR}/var/log/daemon
314         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
315             ${DESTDIR}/var/log/lpd-errs
316         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
317             ${DESTDIR}/var/log/maillog
318         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
319             ${DESTDIR}/var/log/lastlog
320         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
321             ${DESTDIR}/var/log/lastlogx
322         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
323             ${DESTDIR}/var/log/messages
324         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
325             ${DESTDIR}/var/log/security
326         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
327             ${DESTDIR}/var/log/slip.log
328         ${INSTALL} -o ${BINOWN} -g network -m 640 /dev/null \
329             ${DESTDIR}/var/log/ppp.log
330         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
331             ${DESTDIR}/var/log/wtmp
332         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
333             ${DESTDIR}/var/log/wtmpx
334         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
335             ${DESTDIR}/var/run/utmp
336         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
337             ${DESTDIR}/var/run/utmpx
338         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
339             ${DESTDIR}/var/crash
340         cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
341             COPYRIGHT ${DESTDIR}/
342         rm -f ${DESTDIR}/usr/include/machine/ioctl_bt848.h
343         rm -f ${DESTDIR}/usr/include/machine/ioctl_meteor.h
344         rm -f ${DESTDIR}/usr/include/sys/ata.h
345         ${LN} -s "../dev/video/bktr/ioctl_bt848.h" ${DESTDIR}/usr/include/machine/ioctl_bt848.h
346         ${LN} -s "../dev/video/meteor/ioctl_meteor.h" ${DESTDIR}/usr/include/machine/ioctl_meteor.h
347         ${LN} -s nata.h ${DESTDIR}/usr/include/sys/ata.h
348 .if !defined(NOMAN)
349         cd ${.CURDIR}/../share/man; ${MAKE} makedb
350 .endif
351
352 distrib-dirs:
353         mtree -deU -f ${.CURDIR}/mtree/BSD.root.dist -p ${DESTDIR}/
354         mtree -deU -f ${.CURDIR}/mtree/BSD.var.dist -p ${DESTDIR}/var
355         mtree -deU -f ${.CURDIR}/mtree/BSD.usr.dist -p ${DESTDIR}/usr
356         mtree -deU -f ${.CURDIR}/mtree/BSD.include.dist \
357                 -p ${DESTDIR}/usr/include
358         cd ${DESTDIR}/; test -e sys || (rm -f sys;  ${LN} -s usr/src/sys sys)
359         cd ${DESTDIR}/usr/share/nls; \
360         set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
361         while [ $$# -gt 0 ] ; \
362         do \
363                 rm -rf "$$1"; \
364                 ${LN} -s "$$2" "$$1"; \
365                 shift; shift; \
366         done
367
368 etc-examples:
369         cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
370             ${BINUPDATE} ${BIN1} ${BIN2} nsmb.conf opieaccess \
371             ${DESTDIR}/usr/share/examples/etc
372         cd ${.CURDIR}/defaults; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
373             ${DEFAULTS} ${DESTDIR}/usr/share/examples/etc/defaults
374
375 .include <bsd.prog.mk>