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