xref: /freebsd/etc/Makefile (revision 09cd3decf0fae4b769b04c1e900ed5935c40957e)
1.include <src.opts.mk>
2.include <src.tools.mk>
3
4.include <bsd.compat.pre.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
13SUBDIR+=termcap
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_SENDMAIL+=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	    DISTBASE=/${DISTRIBUTION} DESTDIR=${DISTDIR}/${DISTRIBUTION}
42	${_+_}cd ${.CURDIR} ; ${MAKE} distribution \
43	    DISTBASE=/${DISTRIBUTION} DESTDIR=${DISTDIR}/${DISTRIBUTION}
44
45.include <bsd.endian.mk>
46
47.if defined(NO_ROOT)
48METALOG.add?=	cat -l >> ${METALOG}
49.endif
50
51distribution:
52.if !defined(DESTDIR)
53	@echo "set DESTDIR before running \"make ${.TARGET}\""
54	@false
55.endif
56.if ${MK_MITKRB5} != "no"
57	${_+_}cd ${.CURDIR}/gss-krb5; ${MAKE} install
58.else
59	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
60.endif
61	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
62	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
63	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
64	${INSTALL_SYMLINK} -T "package=runtime" ../var/run/os-release \
65		${DESTDIR}/etc/os-release
66.if ${MK_UNBOUND} != "no"
67# If NO_ROOT is defined, we are doing a stage install and always need to
68# install the /etc/unbound symlink, otherwise, don't overwrite the user's
69# existing symlink.
70	if [ "${NO_ROOT:Dtrue}" = true -o ! -e ${DESTDIR}/etc/unbound ]; then \
71		${INSTALL_SYMLINK} -Tpackage=unbound ../var/unbound \
72			${DESTDIR}/etc/unbound; \
73	fi
74.endif
75.if ${MK_SENDMAIL} != "no"
76	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
77.endif
78.if ${MK_KERBEROS} != "no"
79	cd ${.CURDIR}/root; \
80	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
81		-T "package=runtime,config" \
82		dot.k5login ${DESTDIR}/root/.k5login;
83.endif
84
85.if ${MK_MAIL} != "no"
86	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
87	    -T "package=runtime,config" ${ETCMAIL} ${DESTDIR}/etc/mail
88# If NO_ROOT is defined, we are doing a stage install and always need to
89# install the /etc/aliases symlink, otherwise, don't overwrite the user's
90# existing symlink.
91	if [ "${NO_ROOT:Dtrue}" = true -o \( -f ${DESTDIR}/etc/mail/aliases -a \
92	   ! -f ${DESTDIR}/etc/aliases \) ]; then \
93		${INSTALL_SYMLINK} -Tpackage=runtime mail/aliases \
94			${DESTDIR}/etc/aliases; \
95	fi
96.endif	# ${MK_MAIL} != "no"
97
98.if ${MK_SENDMAIL} != "no"
99	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
100		-T "package=sendmail" ${ETCMAIL_SENDMAIL} ${DESTDIR}/etc/mail
101.endif
102	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
103		-T "package=runtime" ${FREEBSD} ${DESTDIR}/
104.if ${MK_BOOT} != "no"
105.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
106	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
107	    -T "package=bootloader,config" \
108	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
109	    ${DESTDIR}/boot/device.hints
110.endif
111.endif
112
113MTREES=		mtree/BSD.root.dist		/		\
114		mtree/BSD.var.dist		/var		\
115		mtree/BSD.usr.dist		/usr		\
116		mtree/BSD.include.dist		/usr/include	\
117		mtree/BSD.debug.dist		/usr/lib
118.for LIBCOMPAT libcompat in ${_ALL_LIBCOMPATS_libcompats}
119.if ${MK_LIB${LIBCOMPAT}} != "no"
120MTREES+=	mtree/BSD.lib${libcompat}.dist	/usr
121MTREES+=	mtree/BSD.lib${libcompat}.dist	/usr/lib/debug/usr
122.endif
123.endfor
124.if ${MK_TESTS} != "no"
125MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
126MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug${TESTSBASE}
127.endif
128.if ${MK_SENDMAIL} != "no"
129MTREES+=	mtree/BSD.sendmail.dist		/
130.endif
131.for mtree in ${LOCAL_MTREE}
132MTREES+=	../${mtree}			/
133.endfor
134
135# Clean up files that have changed into directories, as mtree cannot handle this
136# scenario.
137DISTRIB_CLEANUP_FILES+=	${INCLUDEDIR}/c++/v1/__string
138DISTRIB_CLEANUP_FILES+=	${INCLUDEDIR}/c++/v1/__tuple
139DISTRIB_CLEANUP_FILES+=	${LIBEXECDIR}/kgdb
140distrib-cleanup: .PHONY
141	for file in ${DISTRIB_CLEANUP_FILES}; do \
142		if [ -f ${DESTDIR}/$${file} ]; then \
143			rm -f ${DESTDIR}/$${file}; \
144		fi; \
145	done
146
147distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
148.for _m _d in ${MTREES}
149	@m=${.CURDIR}/${_m}; \
150	d=${DESTDIR}${_d}; \
151	test -d $$d || mkdir -p $$d; \
152	${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
153	    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
154	${MTREE_FILTER} $$m | \
155	${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
156	    -p $$d
157.endfor
158.if defined(NO_ROOT)
159.for _m _d in ${MTREES}
160	@m=${.CURDIR}/${_m}; \
161	d=${_d}; \
162	test "$$d" = "/" && d=""; \
163	d=${DISTBASE}$$d; \
164	${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
165	    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
166	${MTREE_FILTER} $$m | \
167	${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
168	    ${METALOG.add}
169.endfor
170.endif
171.if ${MK_NLS} != "no"
172.for alias nls in ${NLS_ALIASES}
173	${INSTALL_SYMLINK} -T "package=utilities" \
174	    "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
175.endfor
176.endif
177
178.include <bsd.prog.mk>
179
180.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
181MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
182	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
183	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
184	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
185	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
186.else
187MTREE_FILTER= cat
188.if !defined(NO_FSCHG)
189MTREE_FSCHG=	-i
190.endif
191.endif
192