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