xref: /freebsd/etc/Makefile (revision d93a896e)
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
155PPPCNF=	ppp.conf
156
157.if ${MK_SENDMAIL} == "no"
158ETCMAIL=mailer.conf aliases
159.else
160ETCMAIL=Makefile README mailer.conf access.sample virtusertable.sample \
161	mailertable.sample aliases
162.endif
163
164# Special top level files for FreeBSD
165FREEBSD=COPYRIGHT
166
167# Sanitize DESTDIR
168DESTDIR:=	${DESTDIR:C://*:/:g}
169
170afterinstall:
171.if ${MK_MAN} != "no"
172	${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
173.endif
174
175distribute:
176	# Avoid installing tests here; "make distribution" will do this and
177	# correctly place them in the right location.
178	${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
179	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
180	${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
181
182.include <bsd.endian.mk>
183.if ${TARGET_ENDIANNESS} == "1234"
184CAP_MKDB_ENDIAN?= -l
185.elif ${TARGET_ENDIANNESS} == "4321"
186CAP_MKDB_ENDIAN?= -b
187.else
188CAP_MKDB_ENDIAN?=
189.endif
190
191.if defined(NO_ROOT)
192METALOG.add?=	cat -l >> ${METALOG}
193.endif
194
195distribution:
196.if !defined(DESTDIR)
197	@echo "set DESTDIR before running \"make ${.TARGET}\""
198	@false
199.endif
200	cd ${.CURDIR}; \
201	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
202		${BIN1} ${DESTDIR}/etc; \
203	    cap_mkdb ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf; \
204	    services_mkdb ${CAP_MKDB_ENDIAN} -q -o ${DESTDIR}/var/db/services.db \
205		${DESTDIR}/etc/services; \
206	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 755 \
207		${BIN2} ${DESTDIR}/etc; \
208	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
209		master.passwd nsmb.conf opieaccess ${DESTDIR}/etc;
210.if ${MK_BSNMP} != "no"
211	cd ${.CURDIR}; \
212	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
213		snmpd.config ${DESTDIR}/etc;
214.endif
215.if ${MK_AT} == "no"
216	sed -i "" -e 's;.*/usr/libexec/atrun;#&;' ${DESTDIR}/etc/crontab
217.endif
218.if ${MK_TCSH} == "no"
219	sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
220.endif
221	pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
222.if defined(NO_ROOT)
223	( \
224		echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel"; \
225		echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
226		echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
227		echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
228	) | ${METALOG.add}
229.endif
230.if ${MK_AUTOFS} != "no"
231	${_+_}cd ${.CURDIR}/autofs; ${MAKE} install
232.endif
233.if ${MK_BLUETOOTH} != "no"
234	${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install
235.endif
236.if ${MK_CASPER} != "no"
237	${_+_}cd ${.CURDIR}/casper; ${MAKE} install
238.endif
239	${_+_}cd ${.CURDIR}/cron.d; ${MAKE} install
240	${_+_}cd ${.CURDIR}/defaults; ${MAKE} install
241	${_+_}cd ${.CURDIR}/devd; ${MAKE} install
242	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
243	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
244	${_+_}cd ${.CURDIR}/newsyslog.conf.d; ${MAKE} install
245.if ${MK_NTP} != "no"
246	${_+_}cd ${.CURDIR}/ntp; ${MAKE} install
247.endif
248	${_+_}cd ${.CURDIR}/periodic; ${MAKE} install
249.if ${MK_PKGBOOTSTRAP} != "no"
250	${_+_}cd ${.CURDIR}/pkg; ${MAKE} install
251.endif
252	${_+_}cd ${.CURDIR}/rc.d; ${MAKE} install
253	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
254	${_+_}cd ${.CURDIR}/syslog.d; ${MAKE} install
255	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
256	${_+_}cd ${.CURDIR}/pam.d; ${MAKE} install
257	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0444 \
258	    ${BSM_ETC_OPEN_FILES} ${BSM_ETC_DIR}
259	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0600 \
260	    ${BSM_ETC_RESTRICTED_FILES} ${BSM_ETC_DIR}
261	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0500 \
262	    ${BSM_ETC_EXEC_FILES} ${BSM_ETC_DIR}
263.if ${MK_UNBOUND} != "no"
264	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
265		${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \
266	fi
267.endif
268.if ${MK_SENDMAIL} != "no"
269	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
270.endif
271.if ${MK_OPENSSH} != "no"
272	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
273	    ${SSH} ${DESTDIR}/etc/ssh
274.endif
275.if ${MK_OPENSSL} != "no"
276	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
277	    ${SSL} ${DESTDIR}/etc/ssl
278.endif
279.if ${MK_KERBEROS} != "no"
280	cd ${.CURDIR}/root; \
281	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
282		dot.k5login ${DESTDIR}/root/.k5login;
283.endif
284	cd ${.CURDIR}/root; \
285	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
286		dot.profile ${DESTDIR}/root/.profile; \
287	    rm -f ${DESTDIR}/.profile; \
288	    ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile
289.if ${MK_TCSH} != "no"
290	cd ${.CURDIR}/root; \
291	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
292		dot.cshrc ${DESTDIR}/root/.cshrc; \
293	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
294		dot.login ${DESTDIR}/root/.login; \
295	    rm -f ${DESTDIR}/.cshrc; \
296	    ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
297.endif
298.if ${MK_MAIL} != "no"
299	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
300	    ${ETCMAIL} ${DESTDIR}/etc/mail
301	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
302	      ! -f ${DESTDIR}/etc/aliases ]; then \
303		ln -s mail/aliases ${DESTDIR}/etc/aliases; \
304	fi
305.endif
306	${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
307	    ${DESTDIR}/etc/dumpdates
308.if ${MK_LOCATE} != "no"
309	${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
310	    ${DESTDIR}/var/db/locate.database
311.endif
312	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
313	    ${DESTDIR}/var/crash
314	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
315		${FREEBSD} ${DESTDIR}/
316.if ${MK_BOOT} != "no"
317.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
318	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
319	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
320	    ${DESTDIR}/boot/device.hints
321.endif
322.endif
323.if ${MK_NIS} == "no"
324	sed -i "" -e 's/.*_compat:/# &/' -e 's/compat$$/files/' \
325		${DESTDIR}/etc/nsswitch.conf
326.endif
327
328MTREE_CMD?=	mtree
329
330MTREES=		mtree/BSD.root.dist		/		\
331		mtree/BSD.var.dist		/var		\
332		mtree/BSD.usr.dist		/usr		\
333		mtree/BSD.include.dist		/usr/include	\
334		mtree/BSD.debug.dist		/usr/lib
335.if ${MK_LIB32} != "no"
336MTREES+=	mtree/BSD.lib32.dist		/usr
337MTREES+=	mtree/BSD.lib32.dist		/usr/lib/debug/usr
338.endif
339.if ${MK_LIBSOFT} != "no"
340MTREES+=	mtree/BSD.libsoft.dist		/usr
341MTREES+=	mtree/BSD.libsoft.dist		/usr/lib/debug/usr
342.endif
343.if ${MK_TESTS} != "no"
344MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
345MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug/${TESTSBASE}
346.endif
347.if ${MK_SENDMAIL} != "no"
348MTREES+=	mtree/BSD.sendmail.dist		/
349.endif
350.for mtree in ${LOCAL_MTREE}
351MTREES+=	../${mtree}			/
352.endfor
353
354# Clean up some directories that where mistakenly created as files that
355# should not have been as part of the nvi update in r281994.
356# This should be removed after 11.0-RELEASE.
357DISTRIB_CLEANUP_SHARE_FILES=	${SHAREDIR}/doc/usd/10.exref ${SHAREDIR}/doc/usd/11.edit
358DISTRIB_CLEANUP_SHARE_FILES+=	${SHAREDIR}/doc/usd/12.vi ${SHAREDIR}/doc/usd/13.viref
359distrib-cleanup: .PHONY
360	for file in ${DISTRIB_CLEANUP_SHARE_FILES}; do \
361		if [ -f ${DESTDIR}/$${file} ]; then \
362			rm -f ${DESTDIR}/$${file}; \
363		fi; \
364	done
365
366distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
367	@set ${MTREES}; \
368	while test $$# -ge 2; do \
369		m=${.CURDIR}/$$1; \
370		shift; \
371		d=${DESTDIR}$$1; \
372		shift; \
373		test -d $$d || mkdir -p $$d; \
374		${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
375		    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
376		${MTREE_FILTER} $$m | \
377		${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
378		    -p $$d; \
379	done; true
380.if defined(NO_ROOT)
381	@set ${MTREES}; \
382	while test $$# -ge 2; do \
383		m=${.CURDIR}/$$1; \
384		shift; \
385		d=$$1; \
386		test "$$d" == "/" && d=""; \
387		d=${DISTBASE}$$d; \
388		shift; \
389		test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
390		${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K uname,gname | " \
391		    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
392		${MTREE_FILTER} $$m | \
393		${MTREE_CMD:N-W} -C -K uname,gname | sed s#^\.#.$$d# | \
394		    ${METALOG.add} ; \
395	done; true
396.endif
397	${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
398.if ${MK_MAN} != "no"
399	cd ${DESTDIR}${SHAREDIR}/man; \
400	for mandir in man*; do \
401		${INSTALL_SYMLINK} ../$$mandir \
402		    ${DESTDIR}${SHAREDIR}/man/en.ISO8859-1/; \
403		${INSTALL_SYMLINK} ../$$mandir \
404		    ${DESTDIR}${SHAREDIR}/man/en.UTF-8/; \
405	done
406.if ${MK_OPENSSL} != "no"
407	cd ${DESTDIR}${SHAREDIR}/openssl/man; \
408	for mandir in man*; do \
409		${INSTALL_SYMLINK} ../$$mandir \
410		    ${DESTDIR}${SHAREDIR}/openssl/man/en.ISO8859-1/; \
411	done
412.endif
413	set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \
414	while [ $$# -gt 0 ] ; do \
415		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/man/$$1"; \
416		if [ "${MK_OPENSSL}" != "no" ]; then \
417			${INSTALL_SYMLINK} "$$2" \
418			    "${DESTDIR}${SHAREDIR}/openssl/man/$$1"; \
419		fi; \
420		shift; shift; \
421	done
422.endif
423.if ${MK_NLS} != "no"
424	set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
425	while [ $$# -gt 0 ] ; do \
426		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/nls/$$1"; \
427		shift; shift; \
428	done
429.endif
430
431etc-examples-install: ${META_DEPS}
432	cd ${.CURDIR}; ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 \
433	    ${BIN1} ${BIN2} nsmb.conf opieaccess \
434	    ${DESTDIR}${SHAREDIR}/examples/etc
435
436etc-examples: etc-examples-install
437	${_+_}cd ${.CURDIR}/defaults; \
438	    ${MAKE} ${${MK_STAGING} == "yes":?all:install} \
439	    DESTDIR=${DESTDIR}${SHAREDIR}/examples
440
441.include <bsd.prog.mk>
442
443.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
444MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
445	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
446	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
447	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
448	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
449.else
450MTREE_FILTER= cat
451.if !defined(NO_FSCHG)
452MTREE_FSCHG=	-i
453.endif
454.endif
455