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