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