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