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