xref: /freebsd/etc/Makefile (revision fc77abfd1e62751b0c76cd5d8ef3299b8ca398c6)
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 [ ! -e ${DESTDIR}/etc/unbound ]; then \
68		${INSTALL_SYMLINK} -T "package=unbound" \
69		../var/unbound ${DESTDIR}/etc/unbound; \
70	fi
71.endif
72.if ${MK_SENDMAIL} != "no"
73	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
74.endif
75.if ${MK_KERBEROS} != "no"
76	cd ${.CURDIR}/root; \
77	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
78		-T "package=runtime,config" \
79		dot.k5login ${DESTDIR}/root/.k5login;
80.endif
81
82.if ${MK_MAIL} != "no"
83	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
84	    -T "package=runtime,config" ${ETCMAIL} ${DESTDIR}/etc/mail
85	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
86	      ! -f ${DESTDIR}/etc/aliases ]; then \
87		${INSTALL_SYMLINK} -T "package=runtime" \
88		mail/aliases ${DESTDIR}/etc/aliases; \
89	fi
90.endif
91.if ${MK_SENDMAIL} != "no"
92	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
93		-T "package=sendmail" ${ETCMAIL_SENDMAIL} ${DESTDIR}/etc/mail
94.endif
95	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
96		-T "package=runtime" ${FREEBSD} ${DESTDIR}/
97.if ${MK_BOOT} != "no"
98.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
99	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
100	    -T "package=bootloader,config" \
101	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
102	    ${DESTDIR}/boot/device.hints
103.endif
104.endif
105
106MTREES=		mtree/BSD.root.dist		/		\
107		mtree/BSD.var.dist		/var		\
108		mtree/BSD.usr.dist		/usr		\
109		mtree/BSD.include.dist		/usr/include	\
110		mtree/BSD.debug.dist		/usr/lib
111.for LIBCOMPAT libcompat in ${_ALL_LIBCOMPATS_libcompats}
112.if ${MK_LIB${LIBCOMPAT}} != "no"
113MTREES+=	mtree/BSD.lib${libcompat}.dist	/usr
114MTREES+=	mtree/BSD.lib${libcompat}.dist	/usr/lib/debug/usr
115.endif
116.endfor
117.if ${MK_TESTS} != "no"
118MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
119MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug${TESTSBASE}
120.endif
121.if ${MK_SENDMAIL} != "no"
122MTREES+=	mtree/BSD.sendmail.dist		/
123.endif
124.for mtree in ${LOCAL_MTREE}
125MTREES+=	../${mtree}			/
126.endfor
127
128# Clean up files that have changed into directories, as mtree cannot handle this
129# scenario.
130DISTRIB_CLEANUP_FILES+=	${INCLUDEDIR}/c++/v1/__string
131DISTRIB_CLEANUP_FILES+=	${INCLUDEDIR}/c++/v1/__tuple
132DISTRIB_CLEANUP_FILES+=	${LIBEXECDIR}/kgdb
133distrib-cleanup: .PHONY
134	for file in ${DISTRIB_CLEANUP_FILES}; do \
135		if [ -f ${DESTDIR}/$${file} ]; then \
136			rm -f ${DESTDIR}/$${file}; \
137		fi; \
138	done
139
140distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
141.for _m _d in ${MTREES}
142	@m=${.CURDIR}/${_m}; \
143	d=${DESTDIR}${_d}; \
144	test -d $$d || mkdir -p $$d; \
145	${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
146	    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
147	${MTREE_FILTER} $$m | \
148	${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
149	    -p $$d
150.endfor
151.if defined(NO_ROOT)
152.for _m _d in ${MTREES}
153	@m=${.CURDIR}/${_m}; \
154	d=${_d}; \
155	test "$$d" = "/" && d=""; \
156	d=${DISTBASE}$$d; \
157	${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
158	    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
159	${MTREE_FILTER} $$m | \
160	${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
161	    ${METALOG.add}
162.endfor
163.endif
164.if ${MK_NLS} != "no"
165.for alias nls in ${NLS_ALIASES}
166	${INSTALL_SYMLINK} -T "package=utilities" \
167	    "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
168.endfor
169.endif
170
171.include <bsd.prog.mk>
172
173.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
174MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
175	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
176	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
177	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
178	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
179.else
180MTREE_FILTER= cat
181.if !defined(NO_FSCHG)
182MTREE_FSCHG=	-i
183.endif
184.endif
185