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