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