Makefile revision 1.298
1#	$NetBSD: Makefile,v 1.298 2004/11/16 03:51:30 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#   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 MKINFO \
167		MKKERBEROS4 MKKERBEROS MKLINKLIB MKLINT \
168		MKMAN MKMANZ MKNLS MKOBJ MKOBJDIRS \
169		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 powerd rc.d root skel ssh
314	${MAKEDIRTARGET} ${subdir} configinstall
315.endfor
316	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/mail configinstall
317	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.sbin/pf configinstall
318	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/postfix configinstall
319.if (${MKCRYPTO} != "no")
320	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/ssh configinstall
321.endif
322.if (${MKSENDMAIL} != "no")
323	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf configinstall
324.endif
325
326
327# install-obsolete-lists --
328#	Install var/db/obsolete set lists; this is performed by "make build"
329#
330OBSOLETE.dir=		${.OBJDIR}/obsolete.dir
331OBSOLETE.files=		base comp etc games man misc text
332
333install-obsolete-lists: .PHONY
334	mkdir -p ${OBSOLETE.dir}
335	(cd ${NETBSDSRCDIR}/distrib/sets && \
336	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
337.for file in ${OBSOLETE.files}
338	${_MKMSG_INSTALL} ${DESTDIR}/var/db/obsolete/${file}
339	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
340	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
341.endfor
342
343
344# distrib-dirs --
345#	Populate $DESTDIR with directories needed by NetBSD
346#
347.if ${MKUNPRIVED} == "no"
348TOOL_MTREE.unpriv=
349.else
350TOOL_MTREE.unpriv=	-W
351.endif
352
353distrib-dirs: .PHONY check_DESTDIR
354.if !defined(DISTRIBUTION_DONE)
355	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
356.endif
357	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
358	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
359
360
361# release, snapshot --
362#	Build a full distribution including kernels & install media.
363#
364release snapshot: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
365		    distribution .WAIT \
366		    snap_pre .WAIT snap_kern .WAIT \
367		    snap_post .WAIT snap_md_post
368	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets sets
369	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel '*.gz'
370
371
372# iso-image --
373#	Standalone target to create a CDROM image after the release
374#	was composed.  Should be run after "make release" in src and xsrc.
375#
376#	Note: At least mkisofs 2.0 should be used.
377#
378CDROM_NAME_ADD?=
379CDROM.image=${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom/netbsd-${MACHINE}${CDROM_NAME_ADD}.iso
380CDROM.dir=	cdrom.dir
381CDROM.pathlist=	cdrom.pathlist
382
383iso-image: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-md-post
384	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom '*.iso'
385	@echo "iso-image created as: ${CDROM.image}"
386
387iso-image-setup: .PHONY check_RELEASEDIR
388	rm -f ${CDROM.pathlist}
389	echo "${MACHINE}=${RELEASEDIR}/${RELEASEMACHINEDIR}" >> ${CDROM.pathlist}
390	mkdir -p ${CDROM.dir}
391	mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom
392
393# iso-image-mi --
394#	Create the image after the MD operations have completed.
395#
396iso-image-mi: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
397		iso-image-setup .WAIT iso-image-md-pre
398	@if ! ${MKISOFS} --version; then \
399		echo "install pkgsrc/sysutils/cdrecord and run 'make iso-image'." ; \
400		false; \
401	fi
402	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
403	    -o ${CDROM.image} ${CDROM.dir}
404
405# iso-image-md-pre --
406#	Setup ${CDROM.dir} to produce a bootable CD image.
407#	Overridden by etc.$MACHINE/Makefile.inc
408#
409iso-image-md-pre: .PHONY check_DESTDIR check_RELEASEDIR
410#	(empty -- look in the machine-dependent Makefile.inc)
411
412# iso-image-md-post --
413#	Fixup the CD-image to be bootable.
414#	Overridden by etc.$MACHINE/Makefile.inc
415#
416iso-image-md-post: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-mi
417#	(empty -- look in the machine-dependent Makefile.inc)
418
419
420# snap_pre --
421#	Create ${RELEASEDIR} and necessary subdirectories.
422#
423snap_pre: .PHONY check_DESTDIR check_RELEASEDIR
424	${INSTALL} -d -m 755 ${RELEASEDIR}
425.if ${MKUPDATE} == "no"
426# Could be a mount point, ignore the errors
427	-/bin/rm -rf ${RELEASEDIR}/${RELEASEMACHINEDIR}
428.endif
429	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}
430.for dir in ${INSTALLATION_DIRS}
431	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${dir}
432.endfor
433
434# snap_post --
435#	Build the install media and notes from distrib
436#
437snap_post: .PHONY check_DESTDIR check_RELEASEDIR
438.if ${MKUPDATE} == "no"
439	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
440.endif
441	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
442	    ${MAKE} release
443
444# snap_kern --
445#	This target builds the kernels specified by each port.
446#	A port may specify the following kernels:
447#
448#	KERNEL_SETS		The list of kernels that will be
449#				packaged into sets, named
450#				kern-${kernel}.tgz.  These kernels
451#				are also placed in the binary/kernel
452#				area of the release package as
453#				netbsd-${kernel}.gz.
454#
455#	EXTRA_KERNELS		Additional kernels to place in the
456#				binary/kernel area of the release
457#				package as netbsd-${kernel}.gz, but
458#				which are not placed into sets. This
459#				allows a port to provide e.g. a netbootable
460#				installation kernel containing a ramdisk.
461#
462#	BUILD_KERNELS		Additional kernels to build which are
463#				not placed into sets nor into the
464#				binary/kernel area of the release
465#				package.  These are typically kernels
466#				that are built for inclusion only in
467#				installation disk/CD-ROM/tape images.
468#
469#	A port may also specify KERNEL_SUFFIXES, which is an optional list
470#	of filename suffixes for kernels to include in the kernel sets and
471#	in the binary/kernel area of the release package (e.g. "netbsd" vs.
472#	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
473#	with these suffixes do not exist in the kernel build directory.
474#
475#
476# A list of all the kernels to build, which can be overridden from
477# external sources (such as make(1)'s environment or command line)
478#
479ALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
480
481GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
482		END{ if (found == 0) print "netbsd"; }'
483
484.if !target(snap_kern)						# {
485
486# build_kernels --
487#	Configure & compile kernels listed in ${ALL_KERNELS}
488#
489# The 'sync' is so that all writes during the build are pushed back
490# to the disk.  Not having it causes problems on some host systems
491# (e.g. Linux) when building on NFS.
492#
493.if !defined(KERNELS_DONE)						# {
494.for configfile in ${ALL_KERNELS}					# {
495_KERNELS_TO_BUILD+=kern-${configfile}
496kern-${configfile}: .PHONY
497	cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
498	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
499.if ${MKUPDATE} == "no"
500	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
501.endif
502	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
503	sync
504.endfor	# ALL_KERNELS							# }
505.endif	# KERNELS_DONE							# }
506
507build_kernels: .PHONY ${_KERNELS_TO_BUILD}
508
509# build_kernelsets --
510#	Create kernel sets from ${KERNEL_SETS} into
511#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
512#
513.for configfile in ${KERNEL_SETS}					# {
514_KERNELSETS_TO_BUILD+=kernset-${configfile}
515kernset-${configfile}: .PHONY
516	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
517	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
518	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
519	kern_tgz=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets/kern-${configfile}.tgz; \
520	pax_cmd="GZIP=-9 ${TOOL_PAX} -O -zw -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
521	cd $${kerndir} && { \
522		kernels=; newest=; \
523		for kernel in $${kernlist}; do \
524			for s in "" $${kernsuffixes}; do \
525				ks="$${kernel}$${s}"; \
526				[ -f $${ks} ] || continue; \
527				kernels="$${kernels} $${ks}"; \
528				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
529					newest=$${ks}; \
530			done; \
531		done; \
532		[ $${kern_tgz} -nt "$${newest}" ] || { \
533			echo "echo $${kernels} | $${pax_cmd}"; \
534			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
535			echo ". type=dir optional"; \
536			for kernel in $${kernels}; do \
537				echo "./$${kernel} type=file"; \
538			done ) | eval $${pax_cmd}; \
539		} \
540	}
541.endfor	# KERNEL_SETS							# }
542
543build_kernelsets: ${_KERNELSETS_TO_BUILD}
544
545# build_releasekernels --
546#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
547#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel
548#
549.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
550_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
551releasekern-${configfile}: .PHONY
552	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
553	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
554	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
555	cd $${kerndir} && {	\
556		for kernel in $${kernlist}; do \
557			for s in "" $${kernsuffixes}; do \
558				ks="$${kernel}$${s}"; \
559				[ ! -f $${ks} ] && continue; \
560				knl_gz="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel/$${ks}-${configfile:C/.*\///}.gz"; \
561				[ $${knl_gz} -nt $${ks} ] && continue; \
562				echo "gzip -c -9 < $${kerndir}/$${ks} > $${knl_gz}"; \
563				gzip -c -9 < $${ks} > $${knl_gz}; \
564			done; \
565		done; \
566	}
567.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
568
569build_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
570
571# snap_kern --
572#	build the kernels, then the sets & release kernels
573#
574snap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
575	    build_kernels .WAIT \
576	    build_kernelsets build_releasekernels
577
578.endif # !target(snap_kern)					# }
579
580
581# snap_md_post --
582#	Machine dependent distribution media operations.
583#	Overridden by etc.$MACHINE/Makefile.inc
584#
585snap_md_post: check_DESTDIR check_RELEASEDIR
586#	(empty -- look in the machine-dependent Makefile.inc)
587
588
589clean:
590	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
591
592.include <bsd.prog.mk>
593