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