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