xref: /freebsd/etc/Makefile (revision 1f8b431d185416f70e96f03b8fd69b98442b1913)
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 ${MACHINE} == "i386"
80.if ${MK_APM} != "no"
81BIN1+= apmd.conf
82.endif
83.endif
84
85.if ${MK_AUTOFS} != "no"
86BIN1+=	auto_master
87.endif
88
89.if ${MK_BLACKLIST} != "no"
90BIN1+= blacklistd.conf
91.endif
92
93.if ${MK_FREEBSD_UPDATE} != "no"
94BIN1+= freebsd-update.conf
95.endif
96
97.if ${MK_FTP} != "no"
98BIN1+= ftpusers
99.endif
100
101.if ${MK_INETD} != "no"
102BIN1+= inetd.conf
103.endif
104
105.if ${MK_LOCATE} != "no"
106BIN1+=	${SRCTOP}/usr.bin/locate/locate/locate.rc
107.endif
108
109.if ${MK_LPR} != "no"
110BIN1+=	hosts.lpd printcap
111.endif
112
113.if ${MK_MAIL} != "no"
114BIN1+=	${SRCTOP}/usr.bin/mail/misc/mail.rc
115.endif
116
117.if ${MK_NTP} != "no"
118BIN1+=	ntp.conf
119.endif
120
121.if ${MK_OPENSSH} != "no"
122SSH=	${SRCTOP}/crypto/openssh/ssh_config \
123	${SRCTOP}/crypto/openssh/sshd_config \
124	${SRCTOP}/crypto/openssh/moduli
125.endif
126.if ${MK_OPENSSL} != "no"
127SSL=	${SRCTOP}/crypto/openssl/apps/openssl.cnf
128.endif
129
130.if ${MK_NS_CACHING} != "no"
131BIN1+= nscd.conf
132.endif
133
134.if ${MK_PORTSNAP} != "no"
135BIN1+= portsnap.conf
136.endif
137
138.if ${MK_PF} != "no"
139BIN1+= pf.os
140.endif
141
142.if ${MK_SENDMAIL} != "no"
143BIN1+=	rc.sendmail
144.endif
145
146.if ${MK_TCSH} != "no"
147BIN1+= csh.cshrc csh.login csh.logout
148.endif
149
150.if ${MK_WIRELESS} != "no"
151BIN1+= regdomain.xml
152.endif
153
154# -rwxr-xr-x root:wheel, for the new cron root:wheel
155BIN2=	netstart pccard_ether rc.suspend rc.resume
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
184.if defined(NO_ROOT)
185METALOG.add?=	cat -l >> ${METALOG}
186.endif
187
188distribution:
189.if !defined(DESTDIR)
190	@echo "set DESTDIR before running \"make ${.TARGET}\""
191	@false
192.endif
193	cd ${.CURDIR}; \
194	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
195		${BIN1} ${DESTDIR}/etc; \
196	    cap_mkdb ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf; \
197	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 755 \
198		${BIN2} ${DESTDIR}/etc; \
199	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
200		master.passwd nsmb.conf opieaccess ${DESTDIR}/etc;
201
202.if ${MK_SERVICESDB} != "no"
203	cd ${.CURDIR}; \
204	    services_mkdb ${CAP_MKDB_ENDIAN} -q -o ${DESTDIR}/var/db/services.db \
205		${DESTDIR}/etc/services;
206.endif
207
208.if ${MK_BSNMP} != "no"
209	cd ${.CURDIR}; \
210	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
211		snmpd.config ${DESTDIR}/etc;
212.endif
213.if ${MK_TCSH} == "no"
214	sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
215.endif
216	pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
217.if defined(NO_ROOT)
218	( \
219		echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel"; \
220		echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
221		echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
222		echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
223		echo "./var/db/services.db type=file mode=0644 uname=root gname=wheel"; \
224	) | ${METALOG.add}
225.endif
226.if ${MK_AUTOFS} != "no"
227	${_+_}cd ${.CURDIR}/autofs; ${MAKE} install
228.endif
229.if ${MK_BLUETOOTH} != "no"
230	${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install
231.endif
232	${_+_}cd ${.CURDIR}/cron.d; ${MAKE} install
233	${_+_}cd ${.CURDIR}/defaults; ${MAKE} install
234	${_+_}cd ${.CURDIR}/devd; ${MAKE} install
235	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
236	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
237	${_+_}cd ${.CURDIR}/newsyslog.conf.d; ${MAKE} install
238.if ${MK_NTP} != "no"
239	${_+_}cd ${.CURDIR}/ntp; ${MAKE} install
240.endif
241	${_+_}cd ${.CURDIR}/periodic; ${MAKE} install
242.if ${MK_PKGBOOTSTRAP} != "no"
243	${_+_}cd ${.CURDIR}/pkg; ${MAKE} install
244.endif
245	${_+_}cd ${.CURDIR}/rc.d; ${MAKE} install
246	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
247	${_+_}cd ${.CURDIR}/syslog.d; ${MAKE} install
248	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
249	${_+_}cd ${.CURDIR}/pam.d; ${MAKE} install
250	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0444 \
251	    ${BSM_ETC_OPEN_FILES} ${BSM_ETC_DIR}
252	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0600 \
253	    ${BSM_ETC_RESTRICTED_FILES} ${BSM_ETC_DIR}
254	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0500 \
255	    ${BSM_ETC_EXEC_FILES} ${BSM_ETC_DIR}
256.if ${MK_UNBOUND} != "no"
257	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
258		${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \
259	fi
260.endif
261.if ${MK_SENDMAIL} != "no"
262	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
263.endif
264.if ${MK_OPENSSH} != "no"
265	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
266	    ${SSH} ${DESTDIR}/etc/ssh
267.endif
268.if ${MK_OPENSSL} != "no"
269	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
270	    ${SSL} ${DESTDIR}/etc/ssl
271.endif
272.if ${MK_KERBEROS} != "no"
273	cd ${.CURDIR}/root; \
274	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
275		dot.k5login ${DESTDIR}/root/.k5login;
276.endif
277	cd ${.CURDIR}/root; \
278	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
279		dot.profile ${DESTDIR}/root/.profile; \
280	    rm -f ${DESTDIR}/.profile; \
281	    ${INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
282.if ${MK_TCSH} != "no"
283	cd ${.CURDIR}/root; \
284	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
285		dot.cshrc ${DESTDIR}/root/.cshrc; \
286	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
287		dot.login ${DESTDIR}/root/.login; \
288	    rm -f ${DESTDIR}/.cshrc; \
289	    ${INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
290.endif
291.if ${MK_MAIL} != "no"
292	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
293	    ${ETCMAIL} ${DESTDIR}/etc/mail
294	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
295	      ! -f ${DESTDIR}/etc/aliases ]; then \
296		${INSTALL_SYMLINK} mail/aliases ${DESTDIR}/etc/aliases; \
297	fi
298.endif
299	${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
300	    ${DESTDIR}/etc/dumpdates
301.if ${MK_LOCATE} != "no"
302	${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
303	    ${DESTDIR}/var/db/locate.database
304.endif
305	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
306	    ${DESTDIR}/var/crash
307	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
308		${FREEBSD} ${DESTDIR}/
309.if ${MK_BOOT} != "no"
310.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
311	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
312	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
313	    ${DESTDIR}/boot/device.hints
314.endif
315.endif
316.if ${MK_NIS} == "no"
317	sed -i "" -e 's/.*_compat:/# &/' -e 's/compat$$/files/' \
318		${DESTDIR}/etc/nsswitch.conf
319.endif
320
321MTREE_CMD?=	mtree
322
323MTREES=		mtree/BSD.root.dist		/		\
324		mtree/BSD.var.dist		/var		\
325		mtree/BSD.usr.dist		/usr		\
326		mtree/BSD.include.dist		/usr/include	\
327		mtree/BSD.debug.dist		/usr/lib
328.if ${MK_LIB32} != "no"
329MTREES+=	mtree/BSD.lib32.dist		/usr
330MTREES+=	mtree/BSD.lib32.dist		/usr/lib/debug/usr
331.endif
332.if ${MK_LIBSOFT} != "no"
333MTREES+=	mtree/BSD.libsoft.dist		/usr
334MTREES+=	mtree/BSD.libsoft.dist		/usr/lib/debug/usr
335.endif
336.if ${MK_TESTS} != "no"
337MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
338MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug/${TESTSBASE}
339.endif
340.if ${MK_SENDMAIL} != "no"
341MTREES+=	mtree/BSD.sendmail.dist		/
342.endif
343.for mtree in ${LOCAL_MTREE}
344MTREES+=	../${mtree}			/
345.endfor
346
347# Clean up some directories that where mistakenly created as files that
348# should not have been as part of the nvi update in r281994.
349# This should be removed after 11.0-RELEASE.
350DISTRIB_CLEANUP_SHARE_FILES=	${SHAREDIR}/doc/usd/10.exref ${SHAREDIR}/doc/usd/11.edit
351DISTRIB_CLEANUP_SHARE_FILES+=	${SHAREDIR}/doc/usd/12.vi ${SHAREDIR}/doc/usd/13.viref
352distrib-cleanup: .PHONY
353	for file in ${DISTRIB_CLEANUP_SHARE_FILES}; do \
354		if [ -f ${DESTDIR}/$${file} ]; then \
355			rm -f ${DESTDIR}/$${file}; \
356		fi; \
357	done
358
359distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
360	@set ${MTREES}; \
361	while test $$# -ge 2; do \
362		m=${.CURDIR}/$$1; \
363		shift; \
364		d=${DESTDIR}$$1; \
365		shift; \
366		test -d $$d || mkdir -p $$d; \
367		${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
368		    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
369		${MTREE_FILTER} $$m | \
370		${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
371		    -p $$d; \
372	done; true
373.if defined(NO_ROOT)
374	@set ${MTREES}; \
375	while test $$# -ge 2; do \
376		m=${.CURDIR}/$$1; \
377		shift; \
378		d=$$1; \
379		test "$$d" == "/" && d=""; \
380		d=${DISTBASE}$$d; \
381		shift; \
382		test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
383		${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
384		    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
385		${MTREE_FILTER} $$m | \
386		${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
387		    ${METALOG.add} ; \
388	done; true
389.endif
390.if ${MK_NLS} != "no"
391	set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
392	while [ $$# -gt 0 ] ; do \
393		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/nls/$$1"; \
394		shift; shift; \
395	done
396.endif
397
398etc-examples-install: ${META_DEPS}
399	cd ${.CURDIR}; ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 \
400	    ${BIN1} ${BIN2} nsmb.conf opieaccess \
401	    ${DESTDIR}${SHAREDIR}/examples/etc
402
403etc-examples: etc-examples-install
404	${_+_}cd ${.CURDIR}/defaults; \
405	    ${MAKE} ${${MK_STAGING} == "yes":?all:install} \
406	    DESTDIR=${DESTDIR}${SHAREDIR}/examples
407
408.include <bsd.prog.mk>
409
410.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
411MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
412	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
413	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
414	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
415	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
416.else
417MTREE_FILTER= cat
418.if !defined(NO_FSCHG)
419MTREE_FSCHG=	-i
420.endif
421.endif
422