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