xref: /freebsd/etc/Makefile (revision f0f0053abc00d77ccdc7b738c1f12eb03ce180a7)
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
9
10# No need as it is empty and just causes rebuilds since this file does so much.
11UPDATE_DEPENDFILE=	no
12
13.if ${MK_SENDMAIL} != "no"
14SUBDIR+=sendmail
15.endif
16
17BIN1=	\
18	login.access \
19	rc.bsdextended \
20	termcap.small
21
22# NB: keep these sorted by MK_* knobs
23
24.if ${MK_SENDMAIL} != "no"
25BIN1+=	rc.sendmail
26.endif
27
28.if ${MK_SENDMAIL} == "no"
29ETCMAIL=mailer.conf aliases
30.else
31ETCMAIL=Makefile README mailer.conf access.sample virtusertable.sample \
32	mailertable.sample aliases
33.endif
34
35# Special top level files for FreeBSD
36FREEBSD=COPYRIGHT
37
38# Sanitize DESTDIR
39DESTDIR:=	${DESTDIR:C://*:/:g}
40
41afterinstall:
42.if ${MK_MAN} != "no"
43	${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
44.endif
45
46distribute:
47	# Avoid installing tests here; "make distribution" will do this and
48	# correctly place them in the right location.
49	${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
50	    DESTDIR=${DISTDIR}/${DISTRIBUTION}
51	${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
52
53.include <bsd.endian.mk>
54
55.if defined(NO_ROOT)
56METALOG.add?=	cat -l >> ${METALOG}
57.endif
58
59distribution:
60.if !defined(DESTDIR)
61	@echo "set DESTDIR before running \"make ${.TARGET}\""
62	@false
63.endif
64	cd ${.CURDIR}; \
65	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
66		${BIN1} ${DESTDIR}/etc
67	${_+_}cd ${.CURDIR}/gss; ${MAKE} install
68	${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
69	${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
70	${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
71.if ${MK_UNBOUND} != "no"
72	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
73		${INSTALL_SYMLINK} ../var/unbound ${DESTDIR}/etc/unbound; \
74	fi
75.endif
76.if ${MK_SENDMAIL} != "no"
77	${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
78.endif
79.if ${MK_KERBEROS} != "no"
80	cd ${.CURDIR}/root; \
81	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
82		dot.k5login ${DESTDIR}/root/.k5login;
83.endif
84
85.if ${MK_MAIL} != "no"
86	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
87	    ${ETCMAIL} ${DESTDIR}/etc/mail
88	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
89	      ! -f ${DESTDIR}/etc/aliases ]; then \
90		${INSTALL_SYMLINK} mail/aliases ${DESTDIR}/etc/aliases; \
91	fi
92.endif
93.if ${MK_LOCATE} != "no"
94	${INSTALL} -o nobody -g ${BINGRP} -m 644 /dev/null \
95	    ${DESTDIR}/var/db/locate.database
96.endif
97	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
98		${FREEBSD} ${DESTDIR}/
99.if ${MK_BOOT} != "no"
100.if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
101	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
102	    ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
103	    ${DESTDIR}/boot/device.hints
104.endif
105.endif
106
107MTREE_CMD?=	mtree
108
109MTREES=		mtree/BSD.root.dist		/		\
110		mtree/BSD.var.dist		/var		\
111		mtree/BSD.usr.dist		/usr		\
112		mtree/BSD.include.dist		/usr/include	\
113		mtree/BSD.debug.dist		/usr/lib
114.if ${MK_LIB32} != "no"
115MTREES+=	mtree/BSD.lib32.dist		/usr
116MTREES+=	mtree/BSD.lib32.dist		/usr/lib/debug/usr
117.endif
118.if ${MK_LIBSOFT} != "no"
119MTREES+=	mtree/BSD.libsoft.dist		/usr
120MTREES+=	mtree/BSD.libsoft.dist		/usr/lib/debug/usr
121.endif
122.if ${MK_TESTS} != "no"
123MTREES+=	mtree/BSD.tests.dist		${TESTSBASE}
124MTREES+=	mtree/BSD.tests.dist		/usr/lib/debug/${TESTSBASE}
125.endif
126.if ${MK_SENDMAIL} != "no"
127MTREES+=	mtree/BSD.sendmail.dist		/
128.endif
129.for mtree in ${LOCAL_MTREE}
130MTREES+=	../${mtree}			/
131.endfor
132
133# Clean up some directories that where mistakenly created as files that
134# should not have been as part of the nvi update in r281994.
135# This should be removed after 11.0-RELEASE.
136DISTRIB_CLEANUP_SHARE_FILES=	${SHAREDIR}/doc/usd/10.exref ${SHAREDIR}/doc/usd/11.edit
137DISTRIB_CLEANUP_SHARE_FILES+=	${SHAREDIR}/doc/usd/12.vi ${SHAREDIR}/doc/usd/13.viref
138distrib-cleanup: .PHONY
139	for file in ${DISTRIB_CLEANUP_SHARE_FILES}; do \
140		if [ -f ${DESTDIR}/$${file} ]; then \
141			rm -f ${DESTDIR}/$${file}; \
142		fi; \
143	done
144
145distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
146.for _m _d in ${MTREES}
147	@m=${.CURDIR}/${_m}; \
148	d=${DESTDIR}${_d}; \
149	test -d $$d || mkdir -p $$d; \
150	${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
151	    ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
152	${MTREE_FILTER} $$m | \
153	${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
154	    -p $$d
155.endfor
156.if defined(NO_ROOT)
157.for _m _d in ${MTREES}
158	@m=${.CURDIR}/${_m}; \
159	d=${_d}; \
160	test "$$d" == "/" && d=""; \
161	d=${DISTBASE}$$d; \
162	test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
163	${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
164	    "sed s#^\.#.$$d# | ${METALOG.add}" ; \
165	${MTREE_FILTER} $$m | \
166	${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
167	    ${METALOG.add}
168.endfor
169.endif
170.if ${MK_NLS} != "no"
171.for alias nls in ${NLS_ALIASES}
172	${INSTALL_SYMLINK} "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
173.endfor
174.endif
175
176etc-examples: ${META_DEPS}
177	cd ${.CURDIR}; ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 \
178	    ${BIN1} ${BIN2} \
179	    ${DESTDIR}${SHAREDIR}/examples/etc
180
181.include <bsd.prog.mk>
182
183.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
184MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
185	-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
186	-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
187	-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
188	-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
189.else
190MTREE_FILTER= cat
191.if !defined(NO_FSCHG)
192MTREE_FSCHG=	-i
193.endif
194.endif
195