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