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