xref: /freebsd/etc/Makefile (revision 2008043f386721d58158e37e0d7e50df8095942d)
1#	from: @(#)Makefile	5.11 (Berkeley) 5/21/91
2
3.include <src.opts.mk>
4.include <src.tools.mk>
5
6.include <bsd.compat.pre.mk>
7
8FILESGROUPS=	FILES
9NLS_ALIASES=	POSIX C \
10		en_US.US_ASCII C
11
12# No need as it is empty and just causes rebuilds since this file does so much.
13UPDATE_DEPENDFILE=	no
14
15SUBDIR+=termcap
16.if ${MK_SENDMAIL} != "no"
17SUBDIR+=sendmail
18.endif
19
20# NB: keep these sorted by MK_* knobs
21
22ETCMAIL=aliases
23.if ${MK_SENDMAIL} != "no"
24ETCMAIL+=Makefile README access.sample virtusertable.sample \
25	mailertable.sample
26.endif
27
28# Special top level files for FreeBSD
29FREEBSD=COPYRIGHT
30
31# Sanitize DESTDIR
32DESTDIR:=	${DESTDIR:C://*:/:g}
33
34afterinstall:
35.if ${MK_MAN} != "no"
36	${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
37.endif
38
39distribute:
40	# Avoid installing tests here; "make distribution" will do this and
41	# correctly place them in the right location.
42	${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
43	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
44	${_+_}cd ${.CURDIR} ; ${MAKE} 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: .PHONY
129	for file in ${DISTRIB_CLEANUP_FILES}; do \
130		if [ -f ${DESTDIR}/$${file} ]; then \
131			rm -f ${DESTDIR}/$${file}; \
132		fi; \
133	done
134
135distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
136.for _m _d in ${MTREES}
137	@m=${.CURDIR}/${_m}; \
138	d=${DESTDIR}${_d}; \
139	test -d $$d || mkdir -p $$d; \
140	${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
141	    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
142	${MTREE_FILTER} $$m | \
143	${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
144	    -p $$d
145.endfor
146.if defined(NO_ROOT)
147.for _m _d in ${MTREES}
148	@m=${.CURDIR}/${_m}; \
149	d=${_d}; \
150	test "$$d" = "/" && d=""; \
151	d=${DISTBASE}$$d; \
152	${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
153	    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
154	${MTREE_FILTER} $$m | \
155	${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
156	    ${METALOG.add}
157.endfor
158.endif
159.if ${MK_NLS} != "no"
160.for alias nls in ${NLS_ALIASES}
161	${INSTALL_SYMLINK} -T "package=utilities" \
162	    "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
163.endfor
164.endif
165
166.include <bsd.prog.mk>
167
168.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
169MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
170	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
171	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
172	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
173	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
174.else
175MTREE_FILTER= cat
176.if !defined(NO_FSCHG)
177MTREE_FSCHG=	-i
178.endif
179.endif
180