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