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