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