1#	from: @(#)Makefile	5.11 (Berkeley) 5/21/91
2# $FreeBSD: stable/10/etc/Makefile 321251 2017-07-19 21:06:05Z ngie $
3
4.include <bsd.own.mk>
5
6.if ${MK_SENDMAIL} != "no"
7SUBDIR+=sendmail
8.endif
9
10BIN1=	crontab \
11	devd.conf \
12	devfs.conf \
13	ddb.conf \
14	dhclient.conf \
15	disktab \
16	fbtab \
17	gettytab \
18	group \
19	hosts \
20	hosts.allow \
21	hosts.equiv \
22	libalias.conf \
23	libmap.conf \
24	login.access \
25	login.conf \
26	mac.conf \
27	motd \
28	netconfig \
29	network.subr \
30	networks \
31	newsyslog.conf \
32	nsswitch.conf \
33	phones \
34	profile \
35	protocols \
36	rc \
37	rc.bsdextended \
38	rc.firewall \
39	rc.initdiskless \
40	rc.shutdown \
41	rc.subr \
42	remote \
43	rpc \
44	services \
45	shells \
46	sysctl.conf \
47	syslog.conf \
48	termcap.small \
49
50.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64"
51BIN1+=	libmap32.conf
52.endif
53
54.if exists(${.CURDIR}/etc.${MACHINE}/ttys)
55BIN1+=	etc.${MACHINE}/ttys
56.elif exists(${.CURDIR}/etc.${MACHINE_ARCH}/ttys)
57BIN1+=	etc.${MACHINE_ARCH}/ttys
58.elif exists(${.CURDIR}/etc.${MACHINE_CPUARCH}/ttys)
59BIN1+=	etc.${MACHINE_CPUARCH}/ttys
60.else
61.error etc.MACHINE/ttys missing
62.endif
63
64OPENBSMDIR=			${.CURDIR}/../contrib/openbsm
65BSM_ETC_OPEN_FILES=		${OPENBSMDIR}/etc/audit_class \
66				${OPENBSMDIR}/etc/audit_event
67BSM_ETC_RESTRICTED_FILES=	${OPENBSMDIR}/etc/audit_control \
68				${OPENBSMDIR}/etc/audit_user
69BSM_ETC_EXEC_FILES=		${OPENBSMDIR}/etc/audit_warn
70BSM_ETC_DIR=			${DESTDIR}/etc/security
71
72# NB: keep these sorted by MK_* knobs
73
74.if ${MK_AMD} != "no"
75BIN1+= amd.map
76.endif
77
78.if ${MK_APM} != "no"
79BIN1+= apmd.conf
80.endif
81
82.if ${MK_AUTOFS} != "no"
83BIN1+= auto_master
84.endif
85
86.if ${MK_FREEBSD_UPDATE} != "no"
87BIN1+= freebsd-update.conf
88.endif
89
90.if ${MK_FTP} != "no"
91BIN1+= ftpusers
92.endif
93
94.if ${MK_INETD} != "no"
95BIN1+= inetd.conf
96.endif
97
98.if ${MK_LOCATE} != "no"
99BIN1+=	${.CURDIR}/../usr.bin/locate/locate/locate.rc
100.endif
101
102.if ${MK_LPR} != "no"
103BIN1+=	hosts.lpd printcap
104.endif
105
106.if ${MK_MAIL} != "no"
107BIN1+=	${.CURDIR}/../usr.bin/mail/misc/mail.rc
108.endif
109
110.if ${MK_NTP} != "no"
111BIN1+=	ntp.conf
112.endif
113
114.if ${MK_OPENSSH} != "no"
115SSH=	${.CURDIR}/../crypto/openssh/ssh_config \
116	${.CURDIR}/../crypto/openssh/sshd_config \
117	${.CURDIR}/../crypto/openssh/moduli
118.endif
119.if ${MK_OPENSSL} != "no"
120SSL=	${.CURDIR}/../crypto/openssl/apps/openssl.cnf
121.endif
122
123.if ${MK_NS_CACHING} != "no"
124BIN1+= nscd.conf
125.endif
126
127.if ${MK_PORTSNAP} != "no"
128BIN1+= portsnap.conf
129.endif
130
131.if ${MK_PF} != "no"
132BIN1+= pf.os
133.endif
134
135.if ${MK_SENDMAIL} != "no"
136BIN1+=	rc.sendmail
137.endif
138
139.if ${MK_TCSH} != "no"
140BIN1+= csh.cshrc csh.login csh.logout
141.endif
142
143.if ${MK_WIRELESS} != "no"
144BIN1+= regdomain.xml
145.endif
146
147# -rwxr-xr-x root:wheel, for the new cron root:wheel
148BIN2=	netstart pccard_ether rc.suspend rc.resume
149
150MTREE=	BSD.debug.dist BSD.include.dist BSD.root.dist BSD.usr.dist BSD.var.dist
151.if ${MK_TESTS} != "no"
152MTREE+=	BSD.tests.dist
153.endif
154.if ${MK_SENDMAIL} != "no"
155MTREE+=	BSD.sendmail.dist
156.endif
157
158PPPCNF=	ppp.conf
159
160.if ${MK_SENDMAIL} == "no"
161ETCMAIL=mailer.conf aliases
162.else
163ETCMAIL=Makefile README mailer.conf access.sample virtusertable.sample \
164	mailertable.sample aliases
165.endif
166
167# Special top level files for FreeBSD
168FREEBSD=COPYRIGHT
169
170# Sanitize DESTDIR
171DESTDIR:=	${DESTDIR:C://*:/:g}
172
173afterinstall:
174.if ${MK_MAN} != "no"
175	${_+_}cd ${.CURDIR}/../share/man; ${MAKE} makedb
176.endif
177
178distribute:
179	# Avoid installing tests here; "make distribution" will do this and
180	# correctly place them in the right location.
181	${_+_}cd ${.CURDIR} ; ${MAKE} -DNO_TESTS install \
182	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
183	${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
184
185.include <bsd.endian.mk>
186.if ${TARGET_ENDIANNESS} == "1234"
187CAP_MKDB_ENDIAN?= -l
188PWD_MKDB_ENDIAN?= -L
189.elif ${TARGET_ENDIANNESS} == "4321"
190CAP_MKDB_ENDIAN?= -b
191PWD_MKDB_ENDIAN?= -B
192.else
193CAP_MKDB_ENDIAN?=
194PWD_MKDB_ENDIAN?=
195.endif
196
197.if defined(NO_ROOT)
198METALOG.add?=	cat -l >> ${METALOG}
199.endif
200
201distribution:
202.if !defined(DESTDIR)
203	@echo "set DESTDIR before running \"make ${.TARGET}\""
204	@false
205.endif
206	cd ${.CURDIR}; \
207	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
208		${BIN1} ${DESTDIR}/etc; \
209	    cap_mkdb ${CAP_MKDB_ENDIAN} ${DESTDIR}/etc/login.conf; \
210	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 755 \
211		${BIN2} ${DESTDIR}/etc; \
212	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
213		master.passwd nsmb.conf opieaccess ${DESTDIR}/etc;
214.if ${MK_BSNMP} != "no"
215	cd ${.CURDIR}; \
216	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
217		snmpd.config ${DESTDIR}/etc;
218.endif
219.if ${MK_AT} == "no"
220	sed -i "" -e 's;.*/usr/libexec/atrun;#&;' ${DESTDIR}/etc/crontab
221.endif
222.if ${MK_TCSH} == "no"
223	sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
224.endif
225	pwd_mkdb ${PWD_MKDB_ENDIAN} -i -p -d ${DESTDIR}/etc \
226	    ${DESTDIR}/etc/master.passwd
227.if defined(NO_ROOT)
228	( \
229		echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel"; \
230		echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
231		echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
232		echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
233	) | ${METALOG.add}
234.endif
235.if ${MK_AUTOFS} != "no"
236	${_+_}cd ${.CURDIR}/autofs; ${MAKE} install
237.endif
238.if ${MK_BLUETOOTH} != "no"
239	${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install
240.endif
241	${_+_}cd ${.CURDIR}/defaults; ${MAKE} install
242	${_+_}cd ${.CURDIR}/devd; ${MAKE} install
243	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
244	${_+_}cd ${.CURDIR}/newsyslog.conf.d; ${MAKE} install
245.if ${MK_NTP} != "no"
246	${_+_}cd ${.CURDIR}/ntp; ${MAKE} install
247.endif
248	${_+_}cd ${.CURDIR}/periodic; ${MAKE} install
249.if ${MK_PKGBOOTSTRAP} != "no"
250	${_+_}cd ${.CURDIR}/pkg; ${MAKE} install
251.endif
252	${_+_}cd ${.CURDIR}/rc.d; ${MAKE} install
253	${_+_}cd ${.CURDIR}/../share/termcap; ${MAKE} etc-termcap
254	${_+_}cd ${.CURDIR}/../usr.sbin/rmt; ${MAKE} etc-rmt
255	${_+_}cd ${.CURDIR}/pam.d; ${MAKE} install
256	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0444 \
257	    ${BSM_ETC_OPEN_FILES} ${BSM_ETC_DIR}
258	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0600 \
259	    ${BSM_ETC_RESTRICTED_FILES} ${BSM_ETC_DIR}
260	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 0500 \
261	    ${BSM_ETC_EXEC_FILES} ${BSM_ETC_DIR}
262.if ${MK_UNBOUND} != "no"
263	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
264		${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \
265	fi
266.endif
267.if ${MK_SENDMAIL} != "no"
268	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
269.endif
270.if ${MK_OPENSSH} != "no"
271	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
272	    ${SSH} ${DESTDIR}/etc/ssh
273.endif
274.if ${MK_OPENSSL} != "no"
275	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
276	    ${SSL} ${DESTDIR}/etc/ssl
277.endif
278.if ${MK_KERBEROS} != "no"
279	cd ${.CURDIR}/root; \
280	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
281		dot.k5login ${DESTDIR}/root/.k5login;
282.endif
283	cd ${.CURDIR}/root; \
284	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
285		dot.profile ${DESTDIR}/root/.profile; \
286	    rm -f ${DESTDIR}/.profile; \
287	    ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile
288.if ${MK_TCSH} != "no"
289	cd ${.CURDIR}/root; \
290	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
291		dot.cshrc ${DESTDIR}/root/.cshrc; \
292	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
293		dot.login ${DESTDIR}/root/.login; \
294	    rm -f ${DESTDIR}/.cshrc; \
295	    ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
296.endif
297	cd ${.CURDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
298	    ${MTREE} ${DESTDIR}/etc/mtree
299.if ${MK_PPP} != "no"
300	cd ${.CURDIR}/ppp; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
301	    ${PPPCNF} ${DESTDIR}/etc/ppp
302.endif
303.if ${MK_MAIL} != "no"
304	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
305	    ${ETCMAIL} ${DESTDIR}/etc/mail
306	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
307	      ! -f ${DESTDIR}/etc/aliases ]; then \
308		ln -s mail/aliases ${DESTDIR}/etc/aliases; \
309	fi
310.endif
311	${INSTALL} -o ${BINOWN} -g operator -m 664 /dev/null \
312	    ${DESTDIR}/etc/dumpdates
313.if ${MK_LOCATE} != "no"
314	${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
315	    ${DESTDIR}/var/db/locate.database
316.endif
317	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 ${.CURDIR}/minfree \
318	    ${DESTDIR}/var/crash
319	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
320		${FREEBSD} ${DESTDIR}/
321.if ${MK_BOOT} != "no"
322.if exists(${.CURDIR}/../sys/${MACHINE}/conf/GENERIC.hints)
323	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
324	    ${.CURDIR}/../sys/${MACHINE}/conf/GENERIC.hints \
325	    ${DESTDIR}/boot/device.hints
326.endif
327.endif
328.if ${MK_NIS} == "no"
329	sed -i "" -e 's/.*_compat:/# &/' -e 's/compat$$/files/' \
330		${DESTDIR}/etc/nsswitch.conf
331.endif
332
333MTREE_CMD?=	mtree
334
335MTREES=		mtree/BSD.root.dist		/		\
336		mtree/BSD.var.dist		/var		\
337		mtree/BSD.usr.dist		/usr		\
338		mtree/BSD.include.dist		/usr/include	\
339		mtree/BSD.debug.dist		/usr/lib
340.if ${MK_GROFF} != "no"
341MTREES+=	mtree/BSD.groff.dist		/usr
342.endif
343.if ${MK_TESTS} != "no"
344MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
345.endif
346.if ${MK_SENDMAIL} != "no"
347MTREES+=	mtree/BSD.sendmail.dist		/
348.endif
349.for mtree in ${LOCAL_MTREE}
350MTREES+=	../${mtree}			/
351.endfor
352
353distrib-dirs: ${MTREES:N/*}
354	@set ${MTREES}; \
355	while test $$# -ge 2; do \
356		m=${.CURDIR}/$$1; \
357		shift; \
358		d=${DESTDIR}$$1; \
359		shift; \
360		test -d $$d || mkdir -p $$d; \
361		${ECHO} ${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} \
362		    -f $$m -p $$d; \
363		${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
364	done; true
365.if defined(NO_ROOT)
366	@set ${MTREES}; \
367	while test $$# -ge 2; do \
368		m=${.CURDIR}/$$1; \
369		shift; \
370		d=$$1; \
371		test "$$d" == "/" && d=""; \
372		d=${DISTBASE}$$d; \
373		shift; \
374		test -d $$d || mkdir -p $$d; \
375		${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K uname,gname | " \
376		    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
377		${MTREE_CMD:N-W} -C -f $$m -K uname,gname | sed s#^\.#.$$d# | \
378		    ${METALOG.add} ; \
379	done; true
380.endif
381	${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
382.if ${MK_MAN} != "no"
383	cd ${DESTDIR}${SHAREDIR}/man; \
384	for mandir in man*; do \
385		${INSTALL_SYMLINK} ../$$mandir \
386		    ${DESTDIR}${SHAREDIR}/man/en.ISO8859-1/; \
387		${INSTALL_SYMLINK} ../$$mandir \
388		    ${DESTDIR}${SHAREDIR}/man/en.UTF-8/; \
389	done
390.if ${MK_OPENSSL} != "no"
391	cd ${DESTDIR}${SHAREDIR}/openssl/man; \
392	for mandir in man*; do \
393		${INSTALL_SYMLINK} ../$$mandir \
394		    ${DESTDIR}${SHAREDIR}/openssl/man/en.ISO8859-1/; \
395	done
396.endif
397	set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \
398	while [ $$# -gt 0 ] ; do \
399		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/man/$$1"; \
400		if [ "${MK_OPENSSL}" != "no" ]; then \
401			${INSTALL_SYMLINK} "$$2" \
402			    "${DESTDIR}${SHAREDIR}/openssl/man/$$1"; \
403		fi; \
404		shift; shift; \
405	done
406.endif
407.if ${MK_NLS} != "no"
408	set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
409	while [ $$# -gt 0 ] ; do \
410		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/nls/$$1"; \
411		shift; shift; \
412	done
413.endif
414
415etc-examples:
416	cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
417	    ${BIN1} ${BIN2} nsmb.conf opieaccess \
418	    ${DESTDIR}${SHAREDIR}/examples/etc
419	${_+_}cd ${.CURDIR}/defaults; ${MAKE} install \
420	    DESTDIR=${DESTDIR}${SHAREDIR}/examples
421
422.include <bsd.prog.mk>
423