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