xref: /freebsd/etc/Makefile (revision e0c4386e)
1
2.include <src.opts.mk>
3.include <src.tools.mk>
4
5.include <bsd.compat.pre.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
14SUBDIR+=termcap
15.if ${MK_SENDMAIL} != "no"
16SUBDIR+=sendmail
17.endif
18
19# NB: keep these sorted by MK_* knobs
20
21ETCMAIL=aliases
22.if ${MK_SENDMAIL} != "no"
23ETCMAIL+=Makefile README access.sample virtusertable.sample \
24	mailertable.sample
25.endif
26
27# Special top level files for FreeBSD
28FREEBSD=COPYRIGHT
29
30# Sanitize DESTDIR
31DESTDIR:=	${DESTDIR:C://*:/:g}
32
33afterinstall:
34.if ${MK_MAN} != "no"
35	${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
36.endif
37
38distribute:
39	# Avoid installing tests here; "make distribution" will do this and
40	# correctly place them in the right location.
41	${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
42	    DISTBASE=/${DISTRIBUTION} DESTDIR=${DISTDIR}/${DISTRIBUTION}
43	${_+_}cd ${.CURDIR} ; ${MAKE} distribution \
44	    DISTBASE=/${DISTRIBUTION} DESTDIR=${DISTDIR}/${DISTRIBUTION}
45
46.include <bsd.endian.mk>
47
48.if defined(NO_ROOT)
49METALOG.add?=	cat -l >> ${METALOG}
50.endif
51
52distribution:
53.if !defined(DESTDIR)
54	@echo "set DESTDIR before running \"make ${.TARGET}\""
55	@false
56.endif
57	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
58	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
59	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
60	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
61	${INSTALL_SYMLINK} -T "package=runtime" ../var/run/os-release \
62		${DESTDIR}/etc/os-release
63.if ${MK_UNBOUND} != "no"
64	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
65		${INSTALL_SYMLINK} -T "package=unbound" \
66		../var/unbound ${DESTDIR}/etc/unbound; \
67	fi
68.endif
69.if ${MK_SENDMAIL} != "no"
70	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
71.endif
72.if ${MK_KERBEROS} != "no"
73	cd ${.CURDIR}/root; \
74	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
75		-T "package=runtime" \
76		dot.k5login ${DESTDIR}/root/.k5login;
77.endif
78
79.if ${MK_MAIL} != "no"
80	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
81	    -T "package=sendmail" ${ETCMAIL} ${DESTDIR}/etc/mail
82	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
83	      ! -f ${DESTDIR}/etc/aliases ]; then \
84		${INSTALL_SYMLINK} -T "package=sendmail" \
85		mail/aliases ${DESTDIR}/etc/aliases; \
86	fi
87.endif
88.if ${MK_LOCATE} != "no"
89	${INSTALL} -o nobody -g ${BINGRP} -m 644 -T "package=runtime"\
90	    /dev/null ${DESTDIR}/var/db/locate.database
91.endif
92	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
93		-T "package=runtime" ${FREEBSD} ${DESTDIR}/
94.if ${MK_BOOT} != "no"
95.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
96	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
97	    -T "package=bootloader,config" \
98	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
99	    ${DESTDIR}/boot/device.hints
100.endif
101.endif
102
103MTREES=		mtree/BSD.root.dist		/		\
104		mtree/BSD.var.dist		/var		\
105		mtree/BSD.usr.dist		/usr		\
106		mtree/BSD.include.dist		/usr/include	\
107		mtree/BSD.debug.dist		/usr/lib
108.for LIBCOMPAT libcompat in ${_ALL_LIBCOMPATS_libcompats}
109.if ${MK_LIB${LIBCOMPAT}} != "no"
110MTREES+=	mtree/BSD.lib${libcompat}.dist	/usr
111MTREES+=	mtree/BSD.lib${libcompat}.dist	/usr/lib/debug/usr
112.endif
113.endfor
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 files that have changed into directories, as mtree cannot handle this
126# scenario.
127DISTRIB_CLEANUP_FILES+=	${INCLUDEDIR}/c++/v1/__string
128DISTRIB_CLEANUP_FILES+=	${INCLUDEDIR}/c++/v1/__tuple
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