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