xref: /freebsd/etc/Makefile (revision 397e83df75e0fcd0d3fcb95ae4d794cb7600fc89)
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_SENDMAIL+=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=runtime,config" ${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=runtime" \
85		mail/aliases ${DESTDIR}/etc/aliases; \
86	fi
87.endif
88.if ${MK_SENDMAIL} != "no"
89	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
90		-T "package=sendmail" ${ETCMAIL_SENDMAIL} ${DESTDIR}/etc/mail
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_FILES+=	${LIBEXECDIR}/kgdb
130distrib-cleanup: .PHONY
131	for file in ${DISTRIB_CLEANUP_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	${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
155	    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
156	${MTREE_FILTER} $$m | \
157	${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
158	    ${METALOG.add}
159.endfor
160.endif
161.if ${MK_NLS} != "no"
162.for alias nls in ${NLS_ALIASES}
163	${INSTALL_SYMLINK} -T "package=utilities" \
164	    "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
165.endfor
166.endif
167
168.include <bsd.prog.mk>
169
170.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
171MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
172	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
173	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
174	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
175	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
176.else
177MTREE_FILTER= cat
178.if !defined(NO_FSCHG)
179MTREE_FSCHG=	-i
180.endif
181.endif
182