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