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