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