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