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