Makefile revision 1.147
1#	$NetBSD: Makefile,v 1.147 2000/05/03 10:55:19 itojun Exp $
2#	from: @(#)Makefile	8.7 (Berkeley) 5/25/95
3
4# Environment variables without default values:
5#   DESTDIR must be set before anything in this file will work.
6#   RELEASEDIR is where the tarred up stuff for a snapshot or
7#	release will be placed.
8#
9# Environment variables with default values:
10#   LOCALTIME will set the default local time for the system you
11#	build; it determines what /etc/localtime is symlink'd to.
12#   KERNSRCDIR points to kernel source; it is set by default to ../sys,
13#	but can be overridden.
14#   KERNOBJDIR is the kernel build directory, it defaults to
15#	${KERNSRCDIR}/arch/${MACHINE}/compile/KERNELNAME, but can be
16#	overridden.
17#   KERNCONFDIR is where the configuration files for kernels are found;
18#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
19#   UPDATE is normally undefined; if defined, don't do a 'make clean'
20#	before kernel compile
21#   NO_SENDMAIL is normally undefined; if defined, it will not do a
22#	`make distribution' in the sendmail config file source directory.
23#   EXTRA_KERNELS has a machine-dependent list of kernels to build added
24#	to it, but you may also set this to have extra ones built.
25#   BUILD_KERNELS are a machine-dependent list of kernels that should just
26#	be built in place but not made into sets or installed, e.g., an
27#	INSTALL kernel used later in src/distrib/.
28#   CRYPTOPATH is automatically defined by bsd.crypto.mk to be either
29#	../crypto-us or ../crypto-intl.  It controls the building of
30#	the secr set, which can be disabled by setting CRYPTOPATH to
31#	"none".
32# 
33# Targets:
34#    distribution: makes a full NetBSD distribution in DESTDIR. If
35#	INSTALL_DONE is set, it will not do a `make install.'
36#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
37#	Called by distribution.
38#    snapshot: calls distribution, above, and then tars up the files
39#	into a release(7) format in RELEASEDIR. Any port-dependent
40#	stuff for this target is found in etc.${MACHINE}/Makefile.inc.
41#    release: a synonym for `snapshot'
42
43# do this before bsd.own.mk so we get correct SRCDIR
44.include "../Makefile.inc"
45
46# For NO_SENDMAIL and INSTPRIV and CRYPTOPATH
47.include <bsd.own.mk>
48SRCTOP= ..
49.include <bsd.crypto.mk>
50
51TZDIR=		/usr/share/zoneinfo
52LOCALTIME?=	US/Pacific
53
54# setting NOOBJ prevents "make obj" from doing anything;
55# an objdir would break the installation stuff below
56MKOBJ=	no
57
58# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
59# are empty, to preserve the old semantics of setting them below with "=".
60BIN1=	
61BIN2=
62BIN3=
63
64# Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
65# add to this.
66# NOTE: Parent directories must be listed before subdirectories.
67INSTALLATION_DIRS= \
68	binary binary/sets binary/kernel binary/security installation
69
70.if exists(etc.${MACHINE}/Makefile.inc)
71.include "etc.${MACHINE}/Makefile.inc"
72.endif
73
74# Use multiple jobs for kernel builds, if NBUILDJOBS set.
75# (Taken from src/Makefile.)
76.if defined(NBUILDJOBS)
77_J= -j${NBUILDJOBS}
78.endif
79
80# -rw-r--r--
81BINOWN= root
82BINGRP= wheel
83BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
84	daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
85	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
86	mailer.conf man.conf monthly monthly.conf mrouted.conf \
87	netstart networks newsyslog.conf nsswitch.conf ntp.conf \
88	phones printcap profile protocols rbootd.conf rc rc.conf \
89	rc.lkm rc.local rc.subr rc.shutdown rc.wscons remote rpc \
90	security security.conf services shells sysctl.conf syslog.conf \
91	weekly weekly.conf wscons.conf \
92	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
93
94.if	(${MACHINE_ARCH} == "m68k") || \
95	(${MACHINE_ARCH} == "ns32k") || \
96	(${MACHINE_ARCH} == "vax") || \
97	(${MACHINE_ARCH} == "arm32")
98BIN1+=	ld.so.conf
99.elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
100BIN1+=	etc.${MACHINE_ARCH}/ld.so.conf
101.endif
102
103# IPv6
104BIN1+=	rtadvd.conf
105
106# -rw-rw-r--
107BIN2+=	motd
108
109# -rw-------
110BIN3+=	hosts.equiv
111
112NAMEDB=	127 root.cache named.conf localhost loopback.v6
113PCS=	pcs750.bin
114
115all clean cleandir depend distclean etc includes install lint:
116
117.ifndef DESTDIR
118distribution distrib-dirs release snapshot:
119	@echo setenv DESTDIR before doing that!
120	@false
121.else
122distribution: distrib-dirs
123.if !defined(INSTALL_DONE)
124	(cd ..; ${MAKE} _DISTRIB= includes)
125	(cd ..; ${MAKE} _DISTRIB= install)
126.endif
127	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
128	    ${DESTDIR}/etc
129	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
130	    ${DESTDIR}/etc
131	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
132	    ${DESTDIR}/etc
133	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
134	    ${DESTDIR}/etc/mail
135	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
136	    ${DESTDIR}/var/cron/tabs/root
137	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
138	    ${DESTDIR}/etc
139	pwd_mkdb -p -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
140	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
141	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
142	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
143	    ${DESTDIR}/var/crash
144	(cd root; \
145		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
146		    ${DESTDIR}/root/.cshrc; \
147		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
148		    ${DESTDIR}/root/.klogin; \
149		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
150		    ${DESTDIR}/root/.login; \
151		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
152		    ${DESTDIR}/root/.profile; \
153		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
154		    ${DESTDIR}/root/.shrc; \
155		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
156		ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
157		ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
158	(cd mtree; ${MAKE} install)
159	(cd namedb; \
160		${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
161		    ${NAMEDB} ${DESTDIR}/etc/namedb)
162	(cd rc.d; ${MAKE} install)
163	/bin/rm -f ${DESTDIR}/etc/localtime
164	ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
165	/bin/rm -f ${DESTDIR}/etc/rmt
166	ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
167	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
168		${DESTDIR}/etc/dumpdates
169	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
170		${DESTDIR}/etc/skeykeys
171	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
172		${DESTDIR}/var/at/at.deny
173	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
174		${DESTDIR}/var/cron/log
175	${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
176		${DESTDIR}/var/db/locate.database
177	${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
178		${DESTDIR}/var/log/aculog
179	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
180		${DESTDIR}/var/log/authlog
181	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
182		${DESTDIR}/var/log/lastlog
183	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
184		${DESTDIR}/var/log/lpd-errs
185	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
186		${DESTDIR}/var/log/maillog
187	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
188		${DESTDIR}/var/log/messages
189	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
190		${DESTDIR}/var/log/secure
191	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
192		${DESTDIR}/var/log/sendmail.st
193	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
194		${DESTDIR}/var/log/wtmp
195	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
196		${DESTDIR}/var/log/xferlog
197	${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
198		${DESTDIR}/var/msgs/bounds
199	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
200		${DESTDIR}/var/run/utmp
201	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
202		${DESTDIR}/var/games/atc_scores
203	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
204		${DESTDIR}/var/games/battlestar.log
205	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
206		${DESTDIR}/var/games/cfscores
207	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
208		${DESTDIR}/var/games/criblog
209	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
210		${DESTDIR}/var/games/robots_roll
211	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
212		${DESTDIR}/var/games/rogue.scores
213	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
214		${DESTDIR}/var/games/saillog
215	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
216		${DESTDIR}/var/games/snakerawscores
217	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
218		${DESTDIR}/var/games/snake.log
219	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
220		${DESTDIR}/var/games/tetris.scores
221	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
222		${DESTDIR}/var/games/larn/llog12.0
223	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
224		${DESTDIR}/var/games/larn/lscore12.0
225	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
226		${DESTDIR}/var/games/larn/playerids
227	(cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
228	    -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
229	(cd ${DESTDIR}/dev; ./MAKEDEV all)
230	(cd ../usr.bin/mail; ${MAKE} distribution)
231	(cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
232.ifndef NO_SENDMAIL
233	(cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
234	${DESTDIR}/usr/libexec/sendmail/sendmail -C ${DESTDIR}/mail/etc/sendmail.cf -O AliasFile=${DESTDIR}/etc/mail/aliases -O DontBlameSendmail=groupwritabledirpathsafe -bi
235.endif
236
237distrib-dirs:
238	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
239	-mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
240	cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
241
242.if !defined(RELEASEDIR)
243release snapshot snap_pre snap_md_pre snap_md_post:
244	@echo setenv RELEASEDIR before doing that!
245	@false
246.else
247release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
248	(cd ../distrib/sets; ${MAKE} sets)
249	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
250
251cryptoset: distribution snap_pre snap_md_pre snap_kern snap_md_post
252	(cd ../distrib/sets; ${MAKE} cryptoset)
253
254snap_pre:
255	/bin/rm -rf ${RELEASEDIR}
256	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
257.for dir in ${INSTALLATION_DIRS}
258	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
259.endfor
260
261.include <bsd.kernobj.mk>
262
263# This target builds the GENERIC kernel (which must exist for all
264# ports) and puts it in binary/sets/kern.tgz, and also builds any
265# kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
266# system can create more than one kernel from a single configuration
267# we figure out how many there are, what they're named, and move them
268# to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
269# simply be "netbsd". If we don't find the "config" line, assume the
270# kernel will be "netbsd" (some config files are simple additions on
271# GENERIC, and just include it).
272#
273GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
274		END{ if (found == 0) print "netbsd"; }'
275#
276.if !target(snap_kern)
277snap_kern:
278.ifndef KERNELS_DONE
279	mkdir -p ${KERNOBJDIR}
280.for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
281	cd ${KERNCONFDIR} && ${CONFIG} \
282		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
283.ifndef UPDATE
284	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
285.endif
286	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
287.endfor # kernels
288	cd ${KERNOBJDIR}/GENERIC &&	\
289		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
290		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
291.for configfile in GENERIC ${EXTRA_KERNELS}
292	cd ${KERNOBJDIR}/${configfile} &&	\
293		for kernel in `${GETKERNELAWK} \
294			${KERNCONFDIR}/${configfile}` ; {   \
295		gzip -c -9 < $${kernel} > \
296			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
297.endfor # EXTRA_KERNELS
298.endif # KERNELS_DONE
299.endif # no target(snap_kern)
300
301.endif # RELEASEDIR check
302
303snap_md_pre:
304# nothing here -- look in the machine-dependent Makefile.inc
305
306snap_md_post:
307# nothing here -- look in the machine-dependent Makefile.inc
308
309.endif	# DESTDIR check
310
311.include <bsd.prog.mk>
312