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=	\
16	group \
17	login.access \
18	rc.bsdextended \
19	rc.firewall \
20	termcap.small
21
22# NB: keep these sorted by MK_* knobs
23
24.if ${MK_SENDMAIL} != "no"
25BIN1+=	rc.sendmail
26.endif
27
28ETCMAIL=aliases
29.if ${MK_SENDMAIL} != "no"
30ETCMAIL+=Makefile README access.sample virtusertable.sample \
31	mailertable.sample
32.endif
33
34# Special top level files for FreeBSD
35FREEBSD=COPYRIGHT
36
37# Sanitize DESTDIR
38DESTDIR:=	${DESTDIR:C://*:/:g}
39
40afterinstall:
41.if ${MK_MAN} != "no"
42	${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
43.endif
44
45distribute:
46	# Avoid installing tests here; "make distribution" will do this and
47	# correctly place them in the right location.
48	${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
49	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
50	${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
51
52.include <bsd.endian.mk>
53
54.if defined(NO_ROOT)
55METALOG.add?=	cat -l >> ${METALOG}
56.endif
57
58distribution:
59.if !defined(DESTDIR)
60	@echo "set DESTDIR before running \"make ${.TARGET}\""
61	@false
62.endif
63	cd ${.CURDIR}; \
64	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
65		${BIN1} ${DESTDIR}/etc; \
66	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
67		master.passwd ${DESTDIR}/etc;
68
69.if ${MK_TCSH} == "no"
70	sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
71.endif
72	pwd_mkdb -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
73.if defined(NO_ROOT)
74	( \
75		echo "./etc/passwd type=file mode=0644 uname=root gname=wheel"; \
76		echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
77		echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
78	) | ${METALOG.add}
79.endif
80	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
81	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
82	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
83	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
84	${INSTALL_SYMLINK} ../var/run/os-release \
85		${DESTDIR}/etc/os-release
86.if ${MK_UNBOUND} != "no"
87	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
88		${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \
89	fi
90.endif
91.if ${MK_SENDMAIL} != "no"
92	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
93.endif
94.if ${MK_KERBEROS} != "no"
95	cd ${.CURDIR}/root; \
96	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
97		dot.k5login ${DESTDIR}/root/.k5login;
98.endif
99
100.if ${MK_MAIL} != "no"
101	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
102	    ${ETCMAIL} ${DESTDIR}/etc/mail
103	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
104	      ! -f ${DESTDIR}/etc/aliases ]; then \
105		${INSTALL_SYMLINK} mail/aliases ${DESTDIR}/etc/aliases; \
106	fi
107.endif
108.if ${MK_LOCATE} != "no"
109	${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
110	    ${DESTDIR}/var/db/locate.database
111.endif
112	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
113		${FREEBSD} ${DESTDIR}/
114.if ${MK_BOOT} != "no"
115.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
116	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
117	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
118	    ${DESTDIR}/boot/device.hints
119.endif
120.endif
121
122MTREE_CMD?=	mtree
123
124MTREES=		mtree/BSD.root.dist		/		\
125		mtree/BSD.var.dist		/var		\
126		mtree/BSD.usr.dist		/usr		\
127		mtree/BSD.include.dist		/usr/include	\
128		mtree/BSD.debug.dist		/usr/lib
129.if ${MK_LIB32} != "no"
130MTREES+=	mtree/BSD.lib32.dist		/usr
131MTREES+=	mtree/BSD.lib32.dist		/usr/lib/debug/usr
132.endif
133.if ${MK_LIBSOFT} != "no"
134MTREES+=	mtree/BSD.libsoft.dist		/usr
135MTREES+=	mtree/BSD.libsoft.dist		/usr/lib/debug/usr
136.endif
137.if ${MK_TESTS} != "no"
138MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
139MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug/${TESTSBASE}
140.endif
141.if ${MK_SENDMAIL} != "no"
142MTREES+=	mtree/BSD.sendmail.dist		/
143.endif
144.for mtree in ${LOCAL_MTREE}
145MTREES+=	../${mtree}			/
146.endfor
147
148# Clean up some directories that where mistakenly created as files that
149# should not have been as part of the nvi update in r281994.
150# This should be removed after 11.0-RELEASE.
151DISTRIB_CLEANUP_SHARE_FILES=	${SHAREDIR}/doc/usd/10.exref ${SHAREDIR}/doc/usd/11.edit
152DISTRIB_CLEANUP_SHARE_FILES+=	${SHAREDIR}/doc/usd/12.vi ${SHAREDIR}/doc/usd/13.viref
153distrib-cleanup: .PHONY
154	for file in ${DISTRIB_CLEANUP_SHARE_FILES}; do \
155		if [ -f ${DESTDIR}/$${file} ]; then \
156			rm -f ${DESTDIR}/$${file}; \
157		fi; \
158	done
159
160distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
161	@set ${MTREES}; \
162	while test $$# -ge 2; do \
163		m=${.CURDIR}/$$1; \
164		shift; \
165		d=${DESTDIR}$$1; \
166		shift; \
167		test -d $$d || mkdir -p $$d; \
168		${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
169		    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
170		${MTREE_FILTER} $$m | \
171		${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
172		    -p $$d; \
173	done; true
174.if defined(NO_ROOT)
175	@set ${MTREES}; \
176	while test $$# -ge 2; do \
177		m=${.CURDIR}/$$1; \
178		shift; \
179		d=$$1; \
180		test "$$d" == "/" && d=""; \
181		d=${DISTBASE}$$d; \
182		shift; \
183		test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
184		${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
185		    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
186		${MTREE_FILTER} $$m | \
187		${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
188		    ${METALOG.add} ; \
189	done; true
190.endif
191.if ${MK_NLS} != "no"
192	set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
193	while [ $$# -gt 0 ] ; do \
194		${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/nls/$$1"; \
195		shift; shift; \
196	done
197.endif
198
199etc-examples: ${META_DEPS}
200	cd ${.CURDIR}; ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 \
201	    ${BIN1} ${BIN2} \
202	    ${DESTDIR}${SHAREDIR}/examples/etc
203
204.include <bsd.prog.mk>
205
206.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
207MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
208	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
209	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
210	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
211	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
212.else
213MTREE_FILTER= cat
214.if !defined(NO_FSCHG)
215MTREE_FSCHG=	-i
216.endif
217.endif
218