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