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