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