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