xref: /freebsd/etc/Makefile (revision 5ac766ab8ec23e780f108b7903d46e553d5e39d1)
1#	from: @(#)Makefile	5.11 (Berkeley) 5/21/91
2# $FreeBSD$
3
4.include <src.opts.mk>
5.include <src.tools.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
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+=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	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
42	${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
43
44.include <bsd.endian.mk>
45
46.if defined(NO_ROOT)
47METALOG.add?=	cat -l >> ${METALOG}
48.endif
49
50distribution:
51.if !defined(DESTDIR)
52	@echo "set DESTDIR before running \"make ${.TARGET}\""
53	@false
54.endif
55	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
56	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
57	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
58	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
59	${INSTALL_SYMLINK} -T "package=runtime" ../var/run/os-release \
60		${DESTDIR}/etc/os-release
61.if ${MK_UNBOUND} != "no"
62	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
63		${INSTALL_SYMLINK} -T "package=unbound" \
64		../var/unbound ${DESTDIR}/etc/unbound; \
65	fi
66.endif
67.if ${MK_SENDMAIL} != "no"
68	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
69.endif
70.if ${MK_KERBEROS} != "no"
71	cd ${.CURDIR}/root; \
72	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
73		-T "package=runtime" \
74		dot.k5login ${DESTDIR}/root/.k5login;
75.endif
76
77.if ${MK_MAIL} != "no"
78	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
79	    -T "package=sendmail" ${ETCMAIL} ${DESTDIR}/etc/mail
80	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
81	      ! -f ${DESTDIR}/etc/aliases ]; then \
82		${INSTALL_SYMLINK} -T "package=sendmail" \
83		mail/aliases ${DESTDIR}/etc/aliases; \
84	fi
85.endif
86.if ${MK_LOCATE} != "no"
87	${INSTALL} -o nobody -g ${BINGRP} -m 644 -T "package=runtime"\
88	    /dev/null ${DESTDIR}/var/db/locate.database
89.endif
90	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
91		-T "package=runtime" ${FREEBSD} ${DESTDIR}/
92.if ${MK_BOOT} != "no"
93.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
94	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
95	    -T "package=bootloader,config" \
96	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
97	    ${DESTDIR}/boot/device.hints
98.endif
99.endif
100
101MTREES=		mtree/BSD.root.dist		/		\
102		mtree/BSD.var.dist		/var		\
103		mtree/BSD.usr.dist		/usr		\
104		mtree/BSD.include.dist		/usr/include	\
105		mtree/BSD.debug.dist		/usr/lib
106.if ${MK_LIB32} != "no"
107MTREES+=	mtree/BSD.lib32.dist		/usr
108MTREES+=	mtree/BSD.lib32.dist		/usr/lib/debug/usr
109.endif
110.if ${MK_TESTS} != "no"
111MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
112MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug/${TESTSBASE}
113.endif
114.if ${MK_SENDMAIL} != "no"
115MTREES+=	mtree/BSD.sendmail.dist		/
116.endif
117.for mtree in ${LOCAL_MTREE}
118MTREES+=	../${mtree}			/
119.endfor
120
121# Clean up some directories that where mistakenly created as files that
122# should not have been as part of the nvi update in r281994.
123# This should be removed after 11.0-RELEASE.
124DISTRIB_CLEANUP_SHARE_FILES=	${SHAREDIR}/doc/usd/10.exref ${SHAREDIR}/doc/usd/11.edit
125DISTRIB_CLEANUP_SHARE_FILES+=	${SHAREDIR}/doc/usd/12.vi ${SHAREDIR}/doc/usd/13.viref
126distrib-cleanup: .PHONY
127	for file in ${DISTRIB_CLEANUP_SHARE_FILES}; do \
128		if [ -f ${DESTDIR}/$${file} ]; then \
129			rm -f ${DESTDIR}/$${file}; \
130		fi; \
131	done
132
133distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
134.for _m _d in ${MTREES}
135	@m=${.CURDIR}/${_m}; \
136	d=${DESTDIR}${_d}; \
137	test -d $$d || mkdir -p $$d; \
138	${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
139	    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
140	${MTREE_FILTER} $$m | \
141	${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
142	    -p $$d
143.endfor
144.if defined(NO_ROOT)
145.for _m _d in ${MTREES}
146	@m=${.CURDIR}/${_m}; \
147	d=${_d}; \
148	test "$$d" == "/" && d=""; \
149	d=${DISTBASE}$$d; \
150	test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
151	${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
152	    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
153	${MTREE_FILTER} $$m | \
154	${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
155	    ${METALOG.add}
156.endfor
157.endif
158.if ${MK_NLS} != "no"
159.for alias nls in ${NLS_ALIASES}
160	${INSTALL_SYMLINK} -T "package=utilities" \
161	    "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
162.endfor
163.endif
164
165.include <bsd.prog.mk>
166
167.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
168MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
169	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
170	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
171	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
172	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
173.else
174MTREE_FILTER= cat
175.if !defined(NO_FSCHG)
176MTREE_FSCHG=	-i
177.endif
178.endif
179