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