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