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