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