xref: /freebsd/etc/Makefile (revision da2d1e9d2582eece6aad948897489ca0b5d64d73)
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
10
11.if ${MK_SENDMAIL} != "no"
12SUBDIR+=sendmail
13.endif
14
15BIN1=	crontab \
16	dhclient.conf \
17	disktab \
18	fbtab \
19	gettytab \
20	group \
21	hosts \
22	hosts.allow \
23	hosts.equiv \
24	libalias.conf \
25	libmap.conf \
26	login.access \
27	login.conf \
28	mac.conf \
29	motd \
30	netconfig \
31	networks \
32	nsswitch.conf \
33	phones \
34	protocols \
35	rc.bsdextended \
36	rc.firewall \
37	remote \
38	rpc \
39	termcap.small
40
41.if exists(${.CURDIR}/etc.${MACHINE}/ttys)
42BIN1+=	etc.${MACHINE}/ttys
43.elif exists(${.CURDIR}/etc.${MACHINE_ARCH}/ttys)
44BIN1+=	etc.${MACHINE_ARCH}/ttys
45.elif exists(${.CURDIR}/etc.${MACHINE_CPUARCH}/ttys)
46BIN1+=	etc.${MACHINE_CPUARCH}/ttys
47.else
48.error etc.MACHINE/ttys missing
49.endif
50
51# NB: keep these sorted by MK_* knobs
52
53.if ${MK_AMD} != "no"
54BIN1+= amd.map
55.endif
56
57.if ${MK_LOCATE} != "no"
58BIN1+=	${SRCTOP}/usr.bin/locate/locate/locate.rc
59.endif
60
61.if ${MK_LPR} != "no"
62BIN1+=	hosts.lpd printcap
63.endif
64
65.if ${MK_MAIL} != "no"
66BIN1+=	${SRCTOP}/usr.bin/mail/misc/mail.rc
67.endif
68
69.if ${MK_OPENSSL} != "no"
70SSL=	${SRCTOP}/crypto/openssl/apps/openssl.cnf
71.endif
72
73.if ${MK_SENDMAIL} != "no"
74BIN1+=	rc.sendmail
75.endif
76
77.if ${MK_WIRELESS} != "no"
78BIN1+= regdomain.xml
79.endif
80
81.if ${MK_SENDMAIL} == "no"
82ETCMAIL=mailer.conf aliases
83.else
84ETCMAIL=Makefile README mailer.conf access.sample virtusertable.sample \
85	mailertable.sample aliases
86.endif
87
88# Special top level files for FreeBSD
89FREEBSD=COPYRIGHT
90
91# Sanitize DESTDIR
92DESTDIR:=	${DESTDIR:C://*:/:g}
93
94afterinstall:
95.if ${MK_MAN} != "no"
96	${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
97.endif
98
99distribute:
100	# Avoid installing tests here; "make distribution" will do this and
101	# correctly place them in the right location.
102	${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
103	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
104	${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
105
106.include <bsd.endian.mk>
107
108.if defined(NO_ROOT)
109METALOG.add?=	cat -l >> ${METALOG}
110.endif
111
112distribution:
113.if !defined(DESTDIR)
114	@echo "set DESTDIR before running \"make ${.TARGET}\""
115	@false
116.endif
117	cd ${.CURDIR}; \
118	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
119		${BIN1} ${DESTDIR}/etc; \
120	    cap_mkdb ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf; \
121	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
122		master.passwd nsmb.conf opieaccess ${DESTDIR}/etc;
123
124.if ${MK_TCSH} == "no"
125	sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
126.endif
127	pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
128.if defined(NO_ROOT)
129	( \
130		echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel"; \
131		echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
132		echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
133		echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
134	) | ${METALOG.add}
135.endif
136	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
137	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
138	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
139	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
140	${_+_}cd ${.CURDIR}/pam.d; ${MAKE} install
141.if ${MK_UNBOUND} != "no"
142	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
143		${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \
144	fi
145.endif
146.if ${MK_SENDMAIL} != "no"
147	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
148.endif
149.if ${MK_OPENSSL} != "no"
150	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
151	    ${SSL} ${DESTDIR}/etc/ssl
152.endif
153.if ${MK_KERBEROS} != "no"
154	cd ${.CURDIR}/root; \
155	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
156		dot.k5login ${DESTDIR}/root/.k5login;
157.endif
158
159.if ${MK_MAIL} != "no"
160	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
161	    ${ETCMAIL} ${DESTDIR}/etc/mail
162	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
163	      ! -f ${DESTDIR}/etc/aliases ]; then \
164		${INSTALL_SYMLINK} mail/aliases ${DESTDIR}/etc/aliases; \
165	fi
166.endif
167.if ${MK_LOCATE} != "no"
168	${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
169	    ${DESTDIR}/var/db/locate.database
170.endif
171	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
172		${FREEBSD} ${DESTDIR}/
173.if ${MK_BOOT} != "no"
174.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
175	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
176	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
177	    ${DESTDIR}/boot/device.hints
178.endif
179.endif
180.if ${MK_NIS} == "no"
181	sed -i "" -e 's/.*_compat:/# &/' -e 's/compat$$/files/' \
182		${DESTDIR}/etc/nsswitch.conf
183.endif
184
185MTREE_CMD?=	mtree
186
187MTREES=		mtree/BSD.root.dist		/		\
188		mtree/BSD.var.dist		/var		\
189		mtree/BSD.usr.dist		/usr		\
190		mtree/BSD.include.dist		/usr/include	\
191		mtree/BSD.debug.dist		/usr/lib
192.if ${MK_LIB32} != "no"
193MTREES+=	mtree/BSD.lib32.dist		/usr
194MTREES+=	mtree/BSD.lib32.dist		/usr/lib/debug/usr
195.endif
196.if ${MK_LIBSOFT} != "no"
197MTREES+=	mtree/BSD.libsoft.dist		/usr
198MTREES+=	mtree/BSD.libsoft.dist		/usr/lib/debug/usr
199.endif
200.if ${MK_TESTS} != "no"
201MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
202MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug/${TESTSBASE}
203.endif
204.if ${MK_SENDMAIL} != "no"
205MTREES+=	mtree/BSD.sendmail.dist		/
206.endif
207.for mtree in ${LOCAL_MTREE}
208MTREES+=	../${mtree}			/
209.endfor
210
211# Clean up some directories that where mistakenly created as files that
212# should not have been as part of the nvi update in r281994.
213# This should be removed after 11.0-RELEASE.
214DISTRIB_CLEANUP_SHARE_FILES=	${SHAREDIR}/doc/usd/10.exref ${SHAREDIR}/doc/usd/11.edit
215DISTRIB_CLEANUP_SHARE_FILES+=	${SHAREDIR}/doc/usd/12.vi ${SHAREDIR}/doc/usd/13.viref
216distrib-cleanup: .PHONY
217	for file in ${DISTRIB_CLEANUP_SHARE_FILES}; do \
218		if [ -f ${DESTDIR}/$${file} ]; then \
219			rm -f ${DESTDIR}/$${file}; \
220		fi; \
221	done
222
223distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
224	@set ${MTREES}; \
225	while test $$# -ge 2; do \
226		m=${.CURDIR}/$$1; \
227		shift; \
228		d=${DESTDIR}$$1; \
229		shift; \
230		test -d $$d || mkdir -p $$d; \
231		${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
232		    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
233		${MTREE_FILTER} $$m | \
234		${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
235		    -p $$d; \
236	done; true
237.if defined(NO_ROOT)
238	@set ${MTREES}; \
239	while test $$# -ge 2; do \
240		m=${.CURDIR}/$$1; \
241		shift; \
242		d=$$1; \
243		test "$$d" == "/" && d=""; \
244		d=${DISTBASE}$$d; \
245		shift; \
246		test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
247		${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
248		    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
249		${MTREE_FILTER} $$m | \
250		${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
251		    ${METALOG.add} ; \
252	done; true
253.endif
254.if ${MK_NLS} != "no"
255	set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
256	while [ $$# -gt 0 ] ; do \
257		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/nls/$$1"; \
258		shift; shift; \
259	done
260.endif
261
262etc-examples: ${META_DEPS}
263	cd ${.CURDIR}; ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 \
264	    ${BIN1} ${BIN2} nsmb.conf opieaccess \
265	    ${DESTDIR}${SHAREDIR}/examples/etc
266
267.include <bsd.prog.mk>
268
269.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
270MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
271	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
272	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
273	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
274	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
275.else
276MTREE_FILTER= cat
277.if !defined(NO_FSCHG)
278MTREE_FSCHG=	-i
279.endif
280.endif
281