xref: /freebsd/etc/Makefile (revision 780fb4a2fa9a9aee5ac48a60b790f567c0dc13e9)
1#	from: @(#)Makefile	5.11 (Berkeley) 5/21/91
2# $FreeBSD$
3
4.include <src.opts.mk>
5
6FILESGROUPS=	FILES
7
8# No need as it is empty and just causes rebuilds since this file does so much.
9UPDATE_DEPENDFILE=	no
10
11.if ${MK_SENDMAIL} != "no"
12SUBDIR+=sendmail
13.endif
14
15BIN1=	crontab \
16	devd.conf \
17	devfs.conf \
18	ddb.conf \
19	dhclient.conf \
20	disktab \
21	fbtab \
22	gettytab \
23	group \
24	hosts \
25	hosts.allow \
26	hosts.equiv \
27	libalias.conf \
28	libmap.conf \
29	login.access \
30	login.conf \
31	mac.conf \
32	motd \
33	netconfig \
34	network.subr \
35	networks \
36	newsyslog.conf \
37	nsswitch.conf \
38	phones \
39	profile \
40	protocols \
41	rc \
42	rc.bsdextended \
43	rc.firewall \
44	rc.initdiskless \
45	rc.shutdown \
46	rc.subr \
47	remote \
48	rpc \
49	services \
50	shells \
51	sysctl.conf \
52	syslog.conf \
53	termcap.small
54
55.if exists(${.CURDIR}/etc.${MACHINE}/ttys)
56BIN1+=	etc.${MACHINE}/ttys
57.elif exists(${.CURDIR}/etc.${MACHINE_ARCH}/ttys)
58BIN1+=	etc.${MACHINE_ARCH}/ttys
59.elif exists(${.CURDIR}/etc.${MACHINE_CPUARCH}/ttys)
60BIN1+=	etc.${MACHINE_CPUARCH}/ttys
61.else
62.error etc.MACHINE/ttys missing
63.endif
64
65OPENBSMDIR=			${SRCTOP}/contrib/openbsm
66BSM_ETC_OPEN_FILES=		${OPENBSMDIR}/etc/audit_class \
67				${OPENBSMDIR}/etc/audit_event
68BSM_ETC_RESTRICTED_FILES=	${OPENBSMDIR}/etc/audit_control \
69				${OPENBSMDIR}/etc/audit_user
70BSM_ETC_EXEC_FILES=		${OPENBSMDIR}/etc/audit_warn
71BSM_ETC_DIR=			${DESTDIR}/etc/security
72
73# NB: keep these sorted by MK_* knobs
74
75.if ${MK_AMD} != "no"
76BIN1+= amd.map
77.endif
78
79.if ${MK_APM} != "no"
80BIN1+= apmd.conf
81.endif
82
83.if ${MK_AUTOFS} != "no"
84BIN1+=	auto_master
85.endif
86
87.if ${MK_BLACKLIST} != "no"
88BIN1+= blacklistd.conf
89.endif
90
91.if ${MK_FREEBSD_UPDATE} != "no"
92BIN1+= freebsd-update.conf
93.endif
94
95.if ${MK_FTP} != "no"
96BIN1+= ftpusers
97.endif
98
99.if ${MK_INETD} != "no"
100BIN1+= inetd.conf
101.endif
102
103.if ${MK_LOCATE} != "no"
104BIN1+=	${SRCTOP}/usr.bin/locate/locate/locate.rc
105.endif
106
107.if ${MK_LPR} != "no"
108BIN1+=	hosts.lpd printcap
109.endif
110
111.if ${MK_MAIL} != "no"
112BIN1+=	${SRCTOP}/usr.bin/mail/misc/mail.rc
113.endif
114
115.if ${MK_NTP} != "no"
116BIN1+=	ntp.conf
117.endif
118
119.if ${MK_OPENSSH} != "no"
120SSH=	${SRCTOP}/crypto/openssh/ssh_config \
121	${SRCTOP}/crypto/openssh/sshd_config \
122	${SRCTOP}/crypto/openssh/moduli
123.endif
124.if ${MK_OPENSSL} != "no"
125SSL=	${SRCTOP}/crypto/openssl/apps/openssl.cnf
126.endif
127
128.if ${MK_NS_CACHING} != "no"
129BIN1+= nscd.conf
130.endif
131
132.if ${MK_PORTSNAP} != "no"
133BIN1+= portsnap.conf
134.endif
135
136.if ${MK_PF} != "no"
137BIN1+= pf.os
138.endif
139
140.if ${MK_SENDMAIL} != "no"
141BIN1+=	rc.sendmail
142.endif
143
144.if ${MK_TCSH} != "no"
145BIN1+= csh.cshrc csh.login csh.logout
146.endif
147
148.if ${MK_WIRELESS} != "no"
149BIN1+= regdomain.xml
150.endif
151
152# -rwxr-xr-x root:wheel, for the new cron root:wheel
153BIN2=	netstart pccard_ether rc.suspend rc.resume
154
155.if ${MK_SENDMAIL} == "no"
156ETCMAIL=mailer.conf aliases
157.else
158ETCMAIL=Makefile README mailer.conf access.sample virtusertable.sample \
159	mailertable.sample aliases
160.endif
161
162# Special top level files for FreeBSD
163FREEBSD=COPYRIGHT
164
165# Sanitize DESTDIR
166DESTDIR:=	${DESTDIR:C://*:/:g}
167
168afterinstall:
169.if ${MK_MAN} != "no"
170	${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
171.endif
172
173distribute:
174	# Avoid installing tests here; "make distribution" will do this and
175	# correctly place them in the right location.
176	${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
177	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
178	${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
179
180.include <bsd.endian.mk>
181
182.if defined(NO_ROOT)
183METALOG.add?=	cat -l >> ${METALOG}
184.endif
185
186distribution:
187.if !defined(DESTDIR)
188	@echo "set DESTDIR before running \"make ${.TARGET}\""
189	@false
190.endif
191	cd ${.CURDIR}; \
192	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
193		${BIN1} ${DESTDIR}/etc; \
194	    cap_mkdb ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf; \
195	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 755 \
196		${BIN2} ${DESTDIR}/etc; \
197	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
198		master.passwd nsmb.conf opieaccess ${DESTDIR}/etc;
199
200.if ${MK_SERVICESDB} != "no"
201	cd ${.CURDIR}; \
202	    services_mkdb ${CAP_MKDB_ENDIAN} -q -o ${DESTDIR}/var/db/services.db \
203		${DESTDIR}/etc/services;
204.endif
205
206.if ${MK_BSNMP} != "no"
207	cd ${.CURDIR}; \
208	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
209		snmpd.config ${DESTDIR}/etc;
210.endif
211.if ${MK_TCSH} == "no"
212	sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
213.endif
214	pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
215.if defined(NO_ROOT)
216	( \
217		echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel"; \
218		echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
219		echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
220		echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
221		echo "./var/db/services.db type=file mode=0644 uname=root gname=wheel"; \
222	) | ${METALOG.add}
223.endif
224.if ${MK_AUTOFS} != "no"
225	${_+_}cd ${.CURDIR}/autofs; ${MAKE} install
226.endif
227.if ${MK_BLUETOOTH} != "no"
228	${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install
229.endif
230	${_+_}cd ${.CURDIR}/cron.d; ${MAKE} install
231	${_+_}cd ${.CURDIR}/defaults; ${MAKE} install
232	${_+_}cd ${.CURDIR}/devd; ${MAKE} install
233	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
234	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
235	${_+_}cd ${.CURDIR}/newsyslog.conf.d; ${MAKE} install
236.if ${MK_NTP} != "no"
237	${_+_}cd ${.CURDIR}/ntp; ${MAKE} install
238.endif
239	${_+_}cd ${.CURDIR}/periodic; ${MAKE} install
240.if ${MK_PKGBOOTSTRAP} != "no"
241	${_+_}cd ${.CURDIR}/pkg; ${MAKE} install
242.endif
243	${_+_}cd ${.CURDIR}/rc.d; ${MAKE} install
244	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
245	${_+_}cd ${.CURDIR}/syslog.d; ${MAKE} install
246	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
247	${_+_}cd ${.CURDIR}/pam.d; ${MAKE} install
248	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0444 \
249	    ${BSM_ETC_OPEN_FILES} ${BSM_ETC_DIR}
250	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0600 \
251	    ${BSM_ETC_RESTRICTED_FILES} ${BSM_ETC_DIR}
252	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0500 \
253	    ${BSM_ETC_EXEC_FILES} ${BSM_ETC_DIR}
254.if ${MK_UNBOUND} != "no"
255	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
256		${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \
257	fi
258.endif
259.if ${MK_SENDMAIL} != "no"
260	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
261.endif
262.if ${MK_OPENSSH} != "no"
263	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
264	    ${SSH} ${DESTDIR}/etc/ssh
265.endif
266.if ${MK_OPENSSL} != "no"
267	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
268	    ${SSL} ${DESTDIR}/etc/ssl
269.endif
270.if ${MK_KERBEROS} != "no"
271	cd ${.CURDIR}/root; \
272	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
273		dot.k5login ${DESTDIR}/root/.k5login;
274.endif
275	cd ${.CURDIR}/root; \
276	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
277		dot.profile ${DESTDIR}/root/.profile; \
278	    rm -f ${DESTDIR}/.profile; \
279	    ${INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
280.if ${MK_TCSH} != "no"
281	cd ${.CURDIR}/root; \
282	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
283		dot.cshrc ${DESTDIR}/root/.cshrc; \
284	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
285		dot.login ${DESTDIR}/root/.login; \
286	    rm -f ${DESTDIR}/.cshrc; \
287	    ${INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
288.endif
289.if ${MK_MAIL} != "no"
290	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
291	    ${ETCMAIL} ${DESTDIR}/etc/mail
292	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
293	      ! -f ${DESTDIR}/etc/aliases ]; then \
294		${INSTALL_SYMLINK} mail/aliases ${DESTDIR}/etc/aliases; \
295	fi
296.endif
297	${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
298	    ${DESTDIR}/etc/dumpdates
299.if ${MK_LOCATE} != "no"
300	${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
301	    ${DESTDIR}/var/db/locate.database
302.endif
303	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
304	    ${DESTDIR}/var/crash
305	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
306		${FREEBSD} ${DESTDIR}/
307.if ${MK_BOOT} != "no"
308.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
309	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
310	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
311	    ${DESTDIR}/boot/device.hints
312.endif
313.endif
314.if ${MK_NIS} == "no"
315	sed -i "" -e 's/.*_compat:/# &/' -e 's/compat$$/files/' \
316		${DESTDIR}/etc/nsswitch.conf
317.endif
318
319MTREE_CMD?=	mtree
320
321MTREES=		mtree/BSD.root.dist		/		\
322		mtree/BSD.var.dist		/var		\
323		mtree/BSD.usr.dist		/usr		\
324		mtree/BSD.include.dist		/usr/include	\
325		mtree/BSD.debug.dist		/usr/lib
326.if ${MK_LIB32} != "no"
327MTREES+=	mtree/BSD.lib32.dist		/usr
328MTREES+=	mtree/BSD.lib32.dist		/usr/lib/debug/usr
329.endif
330.if ${MK_LIBSOFT} != "no"
331MTREES+=	mtree/BSD.libsoft.dist		/usr
332MTREES+=	mtree/BSD.libsoft.dist		/usr/lib/debug/usr
333.endif
334.if ${MK_TESTS} != "no"
335MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
336MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug/${TESTSBASE}
337.endif
338.if ${MK_SENDMAIL} != "no"
339MTREES+=	mtree/BSD.sendmail.dist		/
340.endif
341.for mtree in ${LOCAL_MTREE}
342MTREES+=	../${mtree}			/
343.endfor
344
345# Clean up some directories that where mistakenly created as files that
346# should not have been as part of the nvi update in r281994.
347# This should be removed after 11.0-RELEASE.
348DISTRIB_CLEANUP_SHARE_FILES=	${SHAREDIR}/doc/usd/10.exref ${SHAREDIR}/doc/usd/11.edit
349DISTRIB_CLEANUP_SHARE_FILES+=	${SHAREDIR}/doc/usd/12.vi ${SHAREDIR}/doc/usd/13.viref
350distrib-cleanup: .PHONY
351	for file in ${DISTRIB_CLEANUP_SHARE_FILES}; do \
352		if [ -f ${DESTDIR}/$${file} ]; then \
353			rm -f ${DESTDIR}/$${file}; \
354		fi; \
355	done
356
357distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
358	@set ${MTREES}; \
359	while test $$# -ge 2; do \
360		m=${.CURDIR}/$$1; \
361		shift; \
362		d=${DESTDIR}$$1; \
363		shift; \
364		test -d $$d || mkdir -p $$d; \
365		${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
366		    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
367		${MTREE_FILTER} $$m | \
368		${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
369		    -p $$d; \
370	done; true
371.if defined(NO_ROOT)
372	@set ${MTREES}; \
373	while test $$# -ge 2; do \
374		m=${.CURDIR}/$$1; \
375		shift; \
376		d=$$1; \
377		test "$$d" == "/" && d=""; \
378		d=${DISTBASE}$$d; \
379		shift; \
380		test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
381		${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
382		    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
383		${MTREE_FILTER} $$m | \
384		${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
385		    ${METALOG.add} ; \
386	done; true
387.endif
388.if ${MK_NLS} != "no"
389	set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
390	while [ $$# -gt 0 ] ; do \
391		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/nls/$$1"; \
392		shift; shift; \
393	done
394.endif
395
396etc-examples-install: ${META_DEPS}
397	cd ${.CURDIR}; ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 \
398	    ${BIN1} ${BIN2} nsmb.conf opieaccess \
399	    ${DESTDIR}${SHAREDIR}/examples/etc
400
401etc-examples: etc-examples-install
402	${_+_}cd ${.CURDIR}/defaults; \
403	    ${MAKE} ${${MK_STAGING} == "yes":?all:install} \
404	    DESTDIR=${DESTDIR}${SHAREDIR}/examples
405
406.include <bsd.prog.mk>
407
408.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
409MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
410	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
411	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
412	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
413	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
414.else
415MTREE_FILTER= cat
416.if !defined(NO_FSCHG)
417MTREE_FSCHG=	-i
418.endif
419.endif
420