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