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