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