Makefile revision 1.306.2.10
1#	$NetBSD: Makefile,v 1.306.2.10 2006/08/25 11:28:54 ghen 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, but can be overridden.
16#   KERNCONFDIR is where the configuration files for kernels are found;
17#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
18#   MKCRYPTO; if not `no', install crypto-related configuration
19#   MKPOSTFIX; if not `no', install postfix configuration
20#   MKSENDMAIL; if not `no', install sendmail configuration
21#   MKUNPRIVED; if not `no', allow non-root installs.
22#   MKUPDATE; if not `no', don't do a 'make clean' before kernel compile
23#
24# Targets:
25#    distribution: makes a full NetBSD distribution in DESTDIR. If
26#	INSTALL_DONE is set, it will not do a `make install.'
27#	if DISTRIBUTION_DONE is set, it will not do anything.
28#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
29#	Called by distribution.
30#    snapshot: calls distribution, above, and then tars up the files
31#	into a release(7) format in RELEASEDIR/${RELEASEMACHINEDIR}.
32#	Any port-dependent stuff for this target is found in
33#	etc.${MACHINE}/Makefile.inc.
34#    release: a synonym for `snapshot'
35#
36
37# For MK* vars
38.include <bsd.own.mk>
39
40.include <bsd.sys.mk>		# for HOST_SH
41.include <bsd.kernobj.mk>	# For KERNSRCDIR, KERNOBJDIR, ...
42.include <bsd.endian.mk>	# For TARGET_ENDIANNESS
43
44
45.MAKEOVERRIDES+=	USETOOLS
46
47TZDIR=		/usr/share/zoneinfo
48LOCALTIME?=	UTC
49CKSUM?=		${TOOL_CKSUM}
50MAKESUMS=	CKSUM=${CKSUM:Q} ${HOST_SH} ${NETBSDSRCDIR}/distrib/sets/makesums
51DISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
52
53# Flags for creating ISO CDROM image
54# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
55# Note: At least mkisofs 2.0 should be used.
56#
57MKISOFS?=	mkisofs
58DISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
59# ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
60ISO_VOLID!=	echo NETBSD_${DISTRIBREV} | tr a-z A-Z
61MKISOFS_FLAGS+= -J -l -hide-joliet-trans-tbl -r -T \
62		-V ${ISO_VOLID} \
63		-P "The NetBSD Project" \
64		-m "${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom"
65.if ${MKISOFS_FLAGS:N-v}
66MKISOFS_FLAGS+=	-quiet
67.endif
68 
69
70# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
71# are empty, to preserve the old semantics of setting them below with "=".
72#
73BIN1=
74BIN2=
75BIN3=
76
77# Directories to build in ${RELEASEDIR}/${RELEASEMACHINEDIR}.
78# MD Makefile.inc files can add to this.
79# NOTE: Parent directories must be listed before subdirectories.
80#
81INSTALLATION_DIRS=	binary binary/sets binary/kernel installation
82
83.if exists(etc.${RELEASEMACHINE}/Makefile.inc)
84.include "etc.${RELEASEMACHINE}/Makefile.inc"
85.endif
86
87# -rw-r--r--
88BINOWN= root
89BINGRP= wheel
90UTMPGRP= utmp
91BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
92	daily.conf dm.conf floppytab ftpchroot ftpusers \
93	gettytab group hosts hosts.lpd inetd.conf lkm.conf locate.conf \
94	mailer.conf man.conf monthly monthly.conf mrouted.conf named.conf \
95	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
96	passwd.conf phones printcap profile protocols \
97	rbootd.conf rc rc.conf rc.lkm rc.local rc.subr rc.shutdown remote rpc \
98	security security.conf services shells sysctl.conf syslog.conf \
99	weekly weekly.conf wscons.conf
100
101# Use machine-specific disktab if it exists, or the MI one otherwise
102.if exists(etc.${MACHINE}/disktab)
103BIN1+=	etc.${MACHINE}/disktab
104.else
105BIN1+=	disktab
106.endif
107
108.if exists(etc.${MACHINE}/ld.so.conf)
109BIN1+=	etc.${MACHINE}/ld.so.conf
110.endif
111
112.if exists(etc.${MACHINE}/ttyaction)
113BIN1+=	etc.${MACHINE}/ttyaction
114.endif
115
116# -rw-rw-r--
117.if !empty(DISTRIBVER:M*.99.*)
118BIN2+=	motd.current
119FILESNAME_motd.current=	motd
120.elif !empty(DISTRIBVER:M*BETA*)
121BIN2+=	motd.beta
122FILESNAME_motd.beta=	motd
123.elif !empty(DISTRIBVER:M*RC*)
124BIN2+=	motd.rc
125FILESNAME_motd.rc=	motd
126.elif !empty(DISTRIBVER:M*STABLE*)
127BIN2+=	motd.stable
128FILESNAME_motd.stable=	motd
129.else
130BIN2+=	motd
131.endif
132
133# -rw-------
134BIN3+=	hosts.equiv
135
136SYSPKG=	etc
137ETC_PKG=-T etc_pkg
138BASE_PKG=-T base_pkg
139ETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
140ETC_INSTALL_OBJ_FILE=cd ${.OBJDIR} && ${INSTALL_FILE} ${ETC_PKG}
141
142.if ${TARGET_ENDIANNESS} == "1234"
143PWD_MKDB_ENDIAN=	-L
144.elif ${TARGET_ENDIANNESS} == "4321"
145PWD_MKDB_ENDIAN=	-B
146.else
147PWD_MKDB_ENDIAN=
148.endif
149
150
151# distribution --
152#	Build a distribution
153#
154distribution: .PHONY check_DESTDIR .WAIT distrib-dirs
155.if !defined(DISTRIBUTION_DONE)
156.if !defined(INSTALL_DONE)
157	${MAKEDIRTARGET} ${NETBSDSRCDIR} include _DISTRIB=
158	${MAKEDIRTARGET} ${NETBSDSRCDIR} install _DISTRIB=
159.endif	# !INSTALL_DONE
160	${MAKEDIRTARGET} . install-etc-files
161.if ${MKX11} != "no"
162	${MAKEDIRTARGET} ${NETBSDSRCDIR}/x11 distribution
163.endif
164	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets makesetfiles
165.endif	# !DISTRIBUTION_DONE
166
167
168CLEANFILES+=	MAKEDEV
169MAKEDEV: .EXEC
170	${_MKTARGET_CREATE}
171	MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
172	    NETBSDSRCDIR=${NETBSDSRCDIR:Q} \
173	    awk -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl > ${.TARGET}
174
175RELEASEVARS=	BSDOBJDIR BSDSRCDIR BUILDID \
176		DESTDIR EXTERNAL_TOOLCHAIN \
177		INSTALLWORLDDIR \
178		KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
179		MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
180		MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
181		MKBFD MKCATPAGES \
182		MKCRYPTO MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKCVS \
183		MKDOC MKDYNAMICROOT MKGCC MKGCCCMDS MKGDB \
184		MKHESIOD MKHOSTOBJ MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
185		MKKERBEROS4 MKKERBEROS MKLINKLIB MKLINT \
186		MKMAN MKMANZ MKNLS MKOBJ MKOBJDIRS \
187		MKPAM MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
188		MKSENDMAIL MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \
189		MKUNPRIVED MKUPDATE MKUUCP MKX11 MKYP \
190		NBUILDJOBS NETBSDSRCDIR \
191		NOCLEANDIR NODISTRIBDIRS NOINCLUDES \
192		OBJMACHINE \
193		RELEASEDIR TOOLCHAIN_MISSING TOOLDIR \
194		USETOOLS USR_OBJMACHINE \
195		X11SRCDIR
196
197params: .PHONY
198.for var in ${RELEASEVARS}
199.if defined(${var})
200	@printf "%20s = '%-s'\n" ${var} ${${var}:Q}
201.else
202	@printf "%20s = (undefined)\n" ${var}
203.endif
204.endfor
205
206CLEANFILES+=	etc-release
207etc-release: .EXEC
208	${_MKTARGET_CREATE}
209	@(	echo "NetBSD ${DISTRIBVER}/${MACHINE}"; \
210		echo ; \
211		cat ${NETBSDSRCDIR}/sys/conf/copyright; \
212		echo ; \
213		echo "Build settings:"; \
214		printf "%20s   %s\n"  "Build date" "$$(date -u)"; \
215		printf "%20s   %s\n"  "Built by" "$${USER-root}@$$(hostname)"; \
216		echo ; \
217		(cd ${.CURDIR}; ${MAKE} ${MFLAGS} -j1 params); \
218	) >${.OBJDIR}/${.TARGET}
219
220install-etc-release: .PHONY etc-release
221	${_MKMSG_INSTALL} etc/release
222	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 444 \
223	    etc-release ${DESTDIR}/etc/release
224
225
226FILESDIR=		/etc
227CONFIGFILES=
228CONFIGSYMLINKS=
229
230.for file in ${BIN1}
231CONFIGFILES+=		${file}
232FILESMODE_${file:T}=	644
233.endfor
234
235.for file in ${BIN2}
236CONFIGFILES+=		${file}
237FILESMODE_${file:T}=	664
238.endfor
239
240.for file in ${BIN3}
241CONFIGFILES+=		${file}
242FILESMODE_${file:T}=	600
243.endfor
244
245CONFIGFILES+=		aliases
246FILESDIR_aliases=	/etc/mail
247FILESMODE_aliases=	644
248
249CONFIGFILES+=		MAKEDEV.local
250FILESDIR_MAKEDEV.local=	/dev
251FILESMODE_MAKEDEV.local=${BINMODE}
252
253CONFIGFILES+=		crontab
254FILESDIR_crontab=	/var/cron/tabs
255FILESNAME_crontab=	root
256FILESMODE_crontab=	600
257
258CONFIGFILES+=		minfree
259FILESDIR_minfree=	/var/crash
260FILESMODE_minfree=	600
261
262CONFIGSYMLINKS+=	${TZDIR}/${LOCALTIME}	/etc/localtime \
263			/usr/sbin/rmt		/etc/rmt
264
265
266# install-etc-files --
267#	Install etc (config) files; not performed by "make build"
268#
269install-etc-files: .PHONY check_DESTDIR MAKEDEV
270	${_MKMSG_INSTALL} ${DESTDIR}/etc/master.passwd
271	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
272	    master.passwd ${DESTDIR}/etc
273	${TOOL_PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
274	    ${DESTDIR}/etc/master.passwd
275.if ${MKUNPRIVED} != "no"
276	( \
277		for metaent in passwd pwd.db spwd.db; do \
278	    		echo "./etc/$${metaent} type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
279		done; \
280	) | ${METALOG.add}
281.endif	# MKUNPRIVED != no
282	${_MKMSG_INSTALL} ${DESTDIR}/etc/ttys
283	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
284	    ${.CURDIR}/etc.${MACHINE}/ttys ${DESTDIR}/etc
285	${_MKMSG_INSTALL} ${DESTDIR}/dev/MAKEDEV
286	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
287	    MAKEDEV ${DESTDIR}/dev
288.for owner group mode file in \
289		${BINOWN} operator	664	/etc/dumpdates  \
290		${BINOWN} ${BINGRP}	644	/etc/mail/local-host-names \
291		${BINOWN} operator	600	/etc/skeykeys \
292		root wheel		600	/var/at/at.deny \
293		nobody ${BINGRP}	664	/var/db/locate.database \
294		uucp dialer		640	/var/log/aculog \
295		${BINOWN} ${BINGRP}	600	/var/log/authlog \
296		root wheel		600	/var/log/cron \
297		${BINOWN} ${UTMPGRP}	664	/var/log/lastlog \
298		${BINOWN} ${UTMPGRP}	664	/var/log/lastlogx \
299		${BINOWN} ${BINGRP}	640	/var/log/lpd-errs \
300		${BINOWN} ${BINGRP}	600	/var/log/maillog \
301		${BINOWN} ${BINGRP}	644	/var/log/messages \
302		${BINOWN} ${BINGRP}	600	/var/log/secure \
303		${BINOWN} ${BINGRP}	644	/var/log/sendmail.st \
304		${BINOWN} ${UTMPGRP}	664	/var/log/wtmp \
305		${BINOWN} ${UTMPGRP}	664	/var/log/wtmpx \
306		${BINOWN} ${BINGRP}	600	/var/log/xferlog \
307		daemon staff		664	/var/msgs/bounds \
308		${BINOWN} ${UTMPGRP}	664	/var/run/utmp \
309		${BINOWN} ${UTMPGRP}	664	/var/run/utmpx \
310		games games		664	/var/games/atc_score \
311		games games		664	/var/games/battlestar.log \
312		games games		664	/var/games/cfscores \
313		games games		664	/var/games/criblog \
314		games games		660	/var/games/hackdir/perm \
315		games games		660	/var/games/hackdir/record \
316		games games		664	/var/games/larn/llog12.0 \
317		games games		664	/var/games/larn/lscore12.0 \
318		games games		664	/var/games/larn/playerids \
319		games games		664	/var/games/robots_roll \
320		games games		664	/var/games/rogue.scores \
321		games games		664	/var/games/saillog \
322		games games		664	/var/games/snakerawscores \
323		games games		664	/var/games/snake.log \
324		games games		664	/var/games/tetris.scores
325	${_MKMSG_INSTALL} ${DESTDIR}${file}
326	${ETC_INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} \
327	    	/dev/null ${DESTDIR}${file}
328.endfor
329.for subdir in . defaults mtree namedb pam.d powerd rc.d root skel ssh
330	${MAKEDIRTARGET} ${subdir} configinstall
331.endfor
332	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/mail configinstall
333.if (${MKPF} != "no")
334	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.sbin/pf configinstall
335.endif
336.if (${MKCRYPTO} != "no")
337	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/ssh configinstall
338.endif
339.if (${MKPOSTFIX} != "no")
340	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/postfix configinstall
341.endif
342.if (${MKSENDMAIL} != "no")
343	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf configinstall
344.endif
345
346
347# install-obsolete-lists --
348#	Install var/db/obsolete set lists; this is performed by "make build"
349#
350OBSOLETE.dir=		${.OBJDIR}/obsolete.dir
351OBSOLETE.files=		base comp etc games man misc text
352.if ${MKX11} != "no"
353OBSOLETE.files+=	xbase xcomp xetc xfont xserver
354.endif
355
356install-obsolete-lists: .PHONY
357	mkdir -p ${OBSOLETE.dir}
358.if ${MKX11} != "no"
359	(cd ${NETBSDSRCDIR}/distrib/sets && \
360	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -b -t ${OBSOLETE.dir})
361.else
362	(cd ${NETBSDSRCDIR}/distrib/sets && \
363	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
364.endif
365.for file in ${OBSOLETE.files}
366	${_MKMSG_INSTALL} ${DESTDIR}/var/db/obsolete/${file}
367	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
368	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
369.endfor
370
371
372# distrib-dirs --
373#	Populate $DESTDIR with directories needed by NetBSD
374#
375.if ${MKUNPRIVED} == "no"
376TOOL_MTREE.unpriv=
377.else
378TOOL_MTREE.unpriv=	-W
379.endif
380
381distrib-dirs: .PHONY check_DESTDIR
382.if !defined(DISTRIBUTION_DONE)
383	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
384.endif
385	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
386	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
387
388
389# release, snapshot --
390#	Build a full distribution including kernels & install media.
391#
392release snapshot: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
393		    distribution .WAIT \
394		    snap_pre .WAIT snap_kern .WAIT \
395		    snap_post .WAIT snap_md_post
396	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets sets
397	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel '*.gz'
398
399
400# iso-image --
401#	Standalone target to create a CDROM image after the release
402#	was composed.  Should be run after "make release" in src and xsrc.
403#
404#	Note: At least mkisofs 2.0 should be used.
405#
406CDROM_NAME_ADD?=
407CDROM.image=${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom/netbsd-${MACHINE}${CDROM_NAME_ADD}.iso
408CDROM.dir=	cdrom.dir
409CDROM.pathlist=	cdrom.pathlist
410
411iso-image: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-md-post
412	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom '*.iso'
413	@echo "iso-image created as: ${CDROM.image}"
414
415iso-image-setup: .PHONY check_RELEASEDIR
416	rm -f ${CDROM.pathlist}
417.for extra in README SOURCE_DATE source
418.if exists(${RELEASEDIR}/${extra})
419	echo "${extra}=${RELEASEDIR}/${extra}" >> ${CDROM.pathlist}
420.endif
421.endfor
422	echo "${MACHINE}=${RELEASEDIR}/${RELEASEMACHINEDIR}" >> ${CDROM.pathlist}
423	mkdir -p ${CDROM.dir}
424	mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom
425
426# iso-image-mi --
427#	Create the image after the MD operations have completed.
428#
429iso-image-mi: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
430		iso-image-setup .WAIT iso-image-md-pre
431	@if ! ${MKISOFS} --version; then \
432		echo "install pkgsrc/sysutils/cdrecord and run 'make iso-image'." ; \
433		false; \
434	fi
435	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
436	    -o ${CDROM.image} ${CDROM.dir}
437
438# iso-image-md-pre --
439#	Setup ${CDROM.dir} to produce a bootable CD image.
440#	Overridden by etc.$MACHINE/Makefile.inc
441#
442iso-image-md-pre: .PHONY check_DESTDIR check_RELEASEDIR
443#	(empty -- look in the machine-dependent Makefile.inc)
444
445# iso-image-md-post --
446#	Fixup the CD-image to be bootable.
447#	Overridden by etc.$MACHINE/Makefile.inc
448#
449iso-image-md-post: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-mi
450#	(empty -- look in the machine-dependent Makefile.inc)
451
452
453# snap_pre --
454#	Create ${RELEASEDIR} and necessary subdirectories.
455#
456snap_pre: .PHONY check_DESTDIR check_RELEASEDIR
457	${INSTALL} -d -m 755 ${RELEASEDIR}
458.if ${MKUPDATE} == "no"
459# Could be a mount point, ignore the errors
460	-/bin/rm -rf ${RELEASEDIR}/${RELEASEMACHINEDIR}
461.endif
462	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}
463.for dir in ${INSTALLATION_DIRS}
464	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${dir}
465.endfor
466
467# snap_post --
468#	Build the install media and notes from distrib
469#
470snap_post: .PHONY check_DESTDIR check_RELEASEDIR
471.if ${MKUPDATE} == "no"
472	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
473.endif
474	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
475	    ${MAKE} release
476
477# snap_kern --
478#	This target builds the kernels specified by each port.
479#	A port may specify the following kernels:
480#
481#	KERNEL_SETS		The list of kernels that will be
482#				packaged into sets, named
483#				kern-${kernel}.tgz.  These kernels
484#				are also placed in the binary/kernel
485#				area of the release package as
486#				netbsd-${kernel}.gz.
487#
488#	EXTRA_KERNELS		Additional kernels to place in the
489#				binary/kernel area of the release
490#				package as netbsd-${kernel}.gz, but
491#				which are not placed into sets. This
492#				allows a port to provide e.g. a netbootable
493#				installation kernel containing a ramdisk.
494#
495#	BUILD_KERNELS		Additional kernels to build which are
496#				not placed into sets nor into the
497#				binary/kernel area of the release
498#				package.  These are typically kernels
499#				that are built for inclusion only in
500#				installation disk/CD-ROM/tape images.
501#
502#	A port may also specify KERNEL_SUFFIXES, which is an optional list
503#	of filename suffixes for kernels to include in the kernel sets and
504#	in the binary/kernel area of the release package (e.g. "netbsd" vs.
505#	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
506#	with these suffixes do not exist in the kernel build directory.
507#
508#
509# A list of all the kernels to build, which can be overridden from
510# external sources (such as make(1)'s environment or command line)
511#
512ALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
513
514GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
515		END{ if (found == 0) print "netbsd"; }'
516
517.if !target(snap_kern)						# {
518
519# build_kernels --
520#	Configure & compile kernels listed in ${ALL_KERNELS}
521#
522# The 'sync' is so that all writes during the build are pushed back
523# to the disk.  Not having it causes problems on some host systems
524# (e.g. Linux) when building on NFS.
525#
526.if !defined(KERNELS_DONE)						# {
527.for configfile in ${ALL_KERNELS}					# {
528_KERNELS_TO_BUILD+=kern-${configfile}
529kern-${configfile}: .PHONY
530	cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
531	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
532.if ${MKUPDATE} == "no"
533	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
534.endif
535	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
536	sync
537.endfor	# ALL_KERNELS							# }
538.endif	# KERNELS_DONE							# }
539
540build_kernels: .PHONY ${_KERNELS_TO_BUILD}
541
542# build_kernelsets --
543#	Create kernel sets from ${KERNEL_SETS} into
544#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
545#
546.for configfile in ${KERNEL_SETS}					# {
547_KERNELSETS_TO_BUILD+=kernset-${configfile}
548kernset-${configfile}: .PHONY
549	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
550	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
551	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
552	kern_tgz=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets/kern-${configfile}.tgz; \
553	pax_cmd="GZIP=-9 ${TOOL_PAX} -O -zw -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
554	cd $${kerndir} && { \
555		kernels=; newest=; \
556		for kernel in $${kernlist}; do \
557			for s in "" $${kernsuffixes}; do \
558				ks="$${kernel}$${s}"; \
559				[ -f $${ks} ] || continue; \
560				kernels="$${kernels} $${ks}"; \
561				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
562					newest=$${ks}; \
563			done; \
564		done; \
565		[ $${kern_tgz} -nt "$${newest}" ] || { \
566			echo "echo $${kernels} | $${pax_cmd}"; \
567			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
568			echo ". type=dir optional"; \
569			for kernel in $${kernels}; do \
570				echo "./$${kernel} type=file"; \
571			done ) | eval $${pax_cmd}; \
572		} \
573	}
574.endfor	# KERNEL_SETS							# }
575
576build_kernelsets: ${_KERNELSETS_TO_BUILD}
577
578# build_releasekernels --
579#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
580#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel
581#
582.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
583_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
584releasekern-${configfile}: .PHONY
585	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
586	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
587	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
588	cd $${kerndir} && {	\
589		for kernel in $${kernlist}; do \
590			for s in "" $${kernsuffixes}; do \
591				ks="$${kernel}$${s}"; \
592				[ ! -f $${ks} ] && continue; \
593				knl_gz="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel/$${ks}-${configfile:C/.*\///}.gz"; \
594				[ $${knl_gz} -nt $${ks} ] && continue; \
595				echo "gzip -c -9 < $${kerndir}/$${ks} > $${knl_gz}"; \
596				gzip -c -9 < $${ks} > $${knl_gz}; \
597			done; \
598		done; \
599	}
600.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
601
602build_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
603
604# snap_kern --
605#	build the kernels, then the sets & release kernels
606#
607snap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
608	    build_kernels .WAIT \
609	    build_kernelsets build_releasekernels
610
611.endif # !target(snap_kern)					# }
612
613
614# snap_md_post --
615#	Machine dependent distribution media operations.
616#	Overridden by etc.$MACHINE/Makefile.inc
617#
618snap_md_post: check_DESTDIR check_RELEASEDIR
619#	(empty -- look in the machine-dependent Makefile.inc)
620
621
622clean:
623	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
624
625.include <bsd.prog.mk>
626
627test:
628	@echo ${OBSOLETE.files}
629