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