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