Makefile revision 1.253
11.8.18.1Syamt#	$NetBSD: Makefile,v 1.253 2003/06/08 23:49:21 lukem Exp $
21.1Sgavan#	from: @(#)Makefile	8.7 (Berkeley) 5/25/95
31.1Sgavan
41.1Sgavan# Environment variables without default values:
51.1Sgavan#   DESTDIR must be set before anything in this file will work.
61.1Sgavan#   RELEASEDIR is where the tarred up stuff for a snapshot or
71.1Sgavan#	release will be placed.
81.1Sgavan#
91.1Sgavan# Environment variables with default values:
101.1Sgavan#   LOCALTIME will set the default local time for the system you
111.1Sgavan#	build; it determines what /etc/localtime is symlink'd to.
121.1Sgavan#   KERNSRCDIR points to kernel source; it is set by default to ../sys,
131.1Sgavan#	but can be overridden.
141.1Sgavan#   KERNOBJDIR is the kernel build directory, it defaults to
151.1Sgavan#	${KERNSRCDIR}/arch/${MACHINE}/compile, but can be overridden.
161.1Sgavan#   KERNCONFDIR is where the configuration files for kernels are found;
171.1Sgavan#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
181.1Sgavan#   UPDATE is normally undefined; if defined, don't do a 'make clean'
191.1Sgavan#	before kernel compile
201.1Sgavan#   NO_SENDMAIL is normally undefined; if defined, it will not do a
211.1Sgavan#	`make distribution' in the sendmail config file source directory.
221.1Sgavan#
231.1Sgavan# Targets:
241.1Sgavan#    distribution: makes a full NetBSD distribution in DESTDIR. If
251.1Sgavan#	INSTALL_DONE is set, it will not do a `make install.'
261.1Sgavan#	if DISTRIBUTION_DONE is set, it will not do anything.
271.1Sgavan#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
281.1Sgavan#	Called by distribution.
291.1Sgavan#    snapshot: calls distribution, above, and then tars up the files
301.1Sgavan#	into a release(7) format in RELEASEDIR/${MACHINE}.
311.1Sgavan#	Any port-dependent stuff for this target is found in
321.1Sgavan#	etc.${MACHINE}/Makefile.inc.
331.1Sgavan#    release: a synonym for `snapshot'
341.1Sgavan#
351.1Sgavan
361.1Sgavan# For NO_SENDMAIL, INSTPRIV, MKCRYPTO
371.1Sgavan#
381.1Sgavan.include <bsd.own.mk>
391.1Sgavan
401.1Sgavan# For KERNSRCDIR, KERNOBJDIR, ...
411.1Sgavan#
421.1Sgavan.include <bsd.kernobj.mk>
431.1Sgavan
441.1Sgavan# For TARGET_ENDIANNESS
451.8Sad#
461.8Sad.include <bsd.endian.mk>
471.1Sgavan
481.8Sad
491.8Sad.MAKEOVERRIDES+=	USETOOLS
501.8Sad
511.8SadTZDIR=		/usr/share/zoneinfo
521.1SgavanLOCALTIME?=	UTC
531.8SadPWD_MKDB?=	pwd_mkdb
541.1SgavanMAKESUMS=	CKSUM=${CKSUM:Q} sh ${NETBSDSRCDIR}/distrib/sets/makesums
551.1Sgavan
561.1Sgavan# Flags for creating ISO CDROM image
571.1Sgavan# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
581.1Sgavan# Note: At least mkisofs 2.0 should be used.
591.1Sgavan#
601.1SgavanMKISOFS?=	mkisofs
611.1SgavanDISTRIBREV!=	sh ${KERNSRCDIR}/conf/osrelease.sh -s
621.1Sgavan# ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
631.1SgavanISO_VOLID!=	echo NETBSD_${MACHINE}_${DISTRIBREV} | tr a-z A-Z
641.1SgavanMKISOFS_FLAGS+= -J -l \
651.1Sgavan		-r -T -v \
661.1Sgavan		-V ${ISO_VOLID} \
671.1Sgavan		-P "The NetBSD Project" \
681.1Sgavan		-m "${RELEASEDIR}/${MACHINE}/installation/cdrom"
691.1Sgavan
701.1Sgavan# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
711.1Sgavan# are empty, to preserve the old semantics of setting them below with "=".
721.1Sgavan#
731.1SgavanBIN1=
741.1SgavanBIN2=
751.1SgavanBIN3=
761.1Sgavan
771.1Sgavan# Directories to build in ${RELEASEDIR}/${MACHINE}.
781.1Sgavan# MD Makefile.inc files can add to this.
791.1Sgavan# NOTE: Parent directories must be listed before subdirectories.
801.1Sgavan#
811.1SgavanINSTALLATION_DIRS=	binary binary/sets binary/kernel installation
821.1Sgavan
831.1Sgavan.if exists(etc.${MACHINE}/Makefile.inc)
841.1Sgavan.include "etc.${MACHINE}/Makefile.inc"
851.1Sgavan.endif
861.1Sgavan
871.1Sgavan# -rw-r--r--
881.1SgavanBINOWN= root
891.1SgavanBINGRP= wheel
901.1SgavanUTMPGRP= utmp
911.3SperryBIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
921.1Sgavan	daily.conf dm.conf floppytab ftpchroot ftpusers \
931.1Sgavan	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
941.1Sgavan	mailer.conf man.conf monthly monthly.conf mrouted.conf \
951.1Sgavan	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
961.1Sgavan	passwd.conf phones printcap profile protocols rbootd.conf rc rc.conf \
971.1Sgavan	rc.lkm rc.local rc.subr rc.shutdown remote rpc \
981.3Sperry	security security.conf services shells sysctl.conf syslog.conf \
991.1Sgavan	weekly weekly.conf wscons.conf \
1001.1Sgavan	etc.${MACHINE}/ttys
1011.1Sgavan
1021.1Sgavan# Use machine-specific disktab if it exists, or the MI one otherwise
1031.1Sgavan.if exists(etc.${MACHINE}/disktab)
1041.1SgavanBIN1+=	etc.${MACHINE}/disktab
1051.1Sgavan.else
1061.1SgavanBIN1+=	disktab
1071.1Sgavan.endif
1081.1Sgavan
1091.1Sgavan.if exists(etc.${MACHINE}/ld.so.conf)
1101.1SgavanBIN1+=	etc.${MACHINE}/ld.so.conf
1111.1Sgavan.endif
1121.1Sgavan
1131.1Sgavan.if exists(etc.${MACHINE}/ttyaction)
1141.1SgavanBIN1+=	etc.${MACHINE}/ttyaction
1151.1Sgavan.endif
1161.1Sgavan
1171.1Sgavan# -rw-rw-r--
1181.1SgavanBIN2+=	motd
1191.1Sgavan
1201.1Sgavan# -rw-------
1211.1SgavanBIN3+=	hosts.equiv
1221.1Sgavan
1231.1SgavanETC_PKG=-T etc_pkg
1241.1SgavanBASE_PKG=-T base_pkg
1251.7SthorpejETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
1261.5SyamtETC_INSTALL_LINK=cd ${.CURDIR} && ${INSTALL_LINK} ${ETC_PKG}
1271.5SyamtETC_INSTALL_SYMLINK=cd ${.CURDIR} && ${INSTALL_SYMLINK} ${ETC_PKG}
1281.5Syamt
1291.5SyamtNAMEDB=	127 root.cache named.conf localhost loopback.v6
1301.5Syamt
1311.5Syamt.if ${TARGET_ENDIANNESS} == "1234"
1321.5SyamtPWD_MKDB_ENDIAN=	-L
1331.5Syamt.elif ${TARGET_ENDIANNESS} == "4321"
1341.5SyamtPWD_MKDB_ENDIAN=	-B
1351.5Syamt.else
1361.5SyamtPWD_MKDB_ENDIAN=
1371.5Syamt.endif
1381.5Syamt
1391.5Syamt
1401.5Syamt# distribution --
1411.5Syamt#	Build a distribution
1421.5Syamt#
1431.1Sgavandistribution: check_DESTDIR .WAIT distrib-dirs
1441.1Sgavan.if !defined(DISTRIBUTION_DONE)
1451.1Sgavan.if !defined(INSTALL_DONE)
1461.4Syamt	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= includes)
1471.1Sgavan	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= install)
1481.1Sgavan.endif	# !INSTALL_DONE
1491.1Sgavan	(cd ${.CURDIR}; ${MAKE} install-etc-files)
1501.1Sgavan.endif	# !DISTRIBUTION_DONE
1511.1Sgavan
1521.1Sgavan
153# install-etc-files --
154#	Install etc (config) files; not performed by "make build"
155#
156install-etc-files: check_DESTDIR
157	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
158	    ${BIN1} ${DESTDIR}/etc
159	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
160	    ${BIN2} ${DESTDIR}/etc
161	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
162	    ${BIN3} ${DESTDIR}/etc
163	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
164	    aliases ${DESTDIR}/etc/mail
165	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
166	    /dev/null ${DESTDIR}/etc/mail/local-host-names
167	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
168	    crontab ${DESTDIR}/var/cron/tabs/root
169	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
170	    master.passwd ${DESTDIR}/etc
171	${PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
172	    ${DESTDIR}/etc/master.passwd
173.if defined(UNPRIVED)
174	( \
175		for metaent in passwd pwd.db spwd.db; do \
176	    		echo "./etc/$${metaent} type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
177		done; \
178	) | ${METALOG.add}
179.endif	# UNPRIVED
180	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
181	    MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
182	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
183	    minfree ${DESTDIR}/var/crash
184.for file in cshrc login profile shrc
185	${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
186	    root/dot.${file} ${DESTDIR}/root/.${file}
187.endfor
188	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
189	    root/dot.klogin ${DESTDIR}/root/.klogin
190	rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile
191	${ETC_INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
192	${ETC_INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
193	(cd ${.CURDIR}/defaults; ${MAKE} install)
194	(cd ${.CURDIR}/mtree; ${MAKE} install)
195.for file in ${NAMEDB}
196	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
197	    namedb/${file} ${DESTDIR}/etc/namedb
198.endfor
199	(cd ${.CURDIR}/powerd; ${MAKE} install)
200	(cd ${.CURDIR}/rc.d; ${MAKE} install)
201	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
202	    postinstall ${DESTDIR}/etc
203	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
204	    ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
205	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
206	    /usr/sbin/rmt ${DESTDIR}/etc/rmt
207	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 664 \
208	    /dev/null ${DESTDIR}/etc/dumpdates
209	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 600 \
210	    /dev/null ${DESTDIR}/etc/skeykeys
211	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
212	    /dev/null ${DESTDIR}/var/at/at.deny
213	${ETC_INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 \
214	    /dev/null ${DESTDIR}/var/db/locate.database
215	${ETC_INSTALL_FILE} -o uucp -g dialer -m 640 \
216	    /dev/null ${DESTDIR}/var/log/aculog
217	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
218	    /dev/null ${DESTDIR}/var/log/authlog
219	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
220	    /dev/null ${DESTDIR}/var/log/cron
221	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
222	    /dev/null ${DESTDIR}/var/log/lastlog
223	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 \
224	    /dev/null ${DESTDIR}/var/log/lpd-errs
225	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
226	    /dev/null ${DESTDIR}/var/log/maillog
227	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
228	    /dev/null ${DESTDIR}/var/log/messages
229	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
230	    /dev/null ${DESTDIR}/var/log/secure
231	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
232	    /dev/null ${DESTDIR}/var/log/sendmail.st
233	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
234	    /dev/null ${DESTDIR}/var/log/wtmp
235	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
236	    /dev/null ${DESTDIR}/var/log/wtmpx
237	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
238	    /dev/null ${DESTDIR}/var/log/xferlog
239	${ETC_INSTALL_FILE} -o daemon -g staff -m 664 \
240	    /dev/null ${DESTDIR}/var/msgs/bounds
241	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
242	    /dev/null ${DESTDIR}/var/run/utmp
243	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
244	    /dev/null ${DESTDIR}/var/run/utmpx
245	${ETC_INSTALL_FILE} -o games -g games -m 664 \
246	    /dev/null ${DESTDIR}/var/games/atc_score
247	${ETC_INSTALL_FILE} -o games -g games -m 664 \
248	    /dev/null ${DESTDIR}/var/games/battlestar.log
249	${ETC_INSTALL_FILE} -o games -g games -m 664 \
250	    /dev/null ${DESTDIR}/var/games/cfscores
251	${ETC_INSTALL_FILE} -o games -g games -m 664 \
252	    /dev/null ${DESTDIR}/var/games/criblog
253	${ETC_INSTALL_FILE} -o games -g games -m 660 \
254	    /dev/null ${DESTDIR}/var/games/hackdir/perm
255	${ETC_INSTALL_FILE} -o games -g games -m 660 \
256	    /dev/null ${DESTDIR}/var/games/hackdir/record
257	${ETC_INSTALL_FILE} -o games -g games -m 664 \
258	    /dev/null ${DESTDIR}/var/games/larn/llog12.0
259	${ETC_INSTALL_FILE} -o games -g games -m 664 \
260	    /dev/null ${DESTDIR}/var/games/larn/lscore12.0
261	${ETC_INSTALL_FILE} -o games -g games -m 664 \
262	    /dev/null ${DESTDIR}/var/games/larn/playerids
263	${ETC_INSTALL_FILE} -o games -g games -m 664 \
264	    /dev/null ${DESTDIR}/var/games/robots_roll
265	${ETC_INSTALL_FILE} -o games -g games -m 664 \
266	    /dev/null ${DESTDIR}/var/games/rogue.scores
267	${ETC_INSTALL_FILE} -o games -g games -m 664 \
268	    /dev/null ${DESTDIR}/var/games/saillog
269	${ETC_INSTALL_FILE} -o games -g games -m 664 \
270	    /dev/null ${DESTDIR}/var/games/snakerawscores
271	${ETC_INSTALL_FILE} -o games -g games -m 664 \
272	    /dev/null ${DESTDIR}/var/games/snake.log
273	${ETC_INSTALL_FILE} -o games -g games -m 664 \
274	    /dev/null ${DESTDIR}/var/games/tetris.scores
275	(cd ${.CURDIR}/skel; ${MAKE} distribution)
276	(cd ${NETBSDSRCDIR}/usr.bin/mail; ${MAKE} distribution)
277	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/postfix/; ${MAKE} distribution)
278.if (${MKCRYPTO} != "no")
279	(cd ${NETBSDSRCDIR}/usr.bin/ssh; ${MAKE} distribution)
280.endif
281.if !defined(NO_SENDMAIL) || ${NO_SENDMAIL} == "no"
282	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
283.endif
284
285
286# install-obsolete-lists --
287#	Install var/db/obsolete set lists; this is performed by "make build"
288#
289OBSOLETE.dir=		${.OBJDIR}/obsolete.dir
290OBSOLETE.files=		base comp etc games man misc text
291
292install-obsolete-lists:
293	mkdir -p ${OBSOLETE.dir}
294	(cd ${NETBSDSRCDIR}/distrib/sets && \
295	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
296.for file in ${OBSOLETE.files}
297	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
298	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
299.endfor
300
301
302# distrib-dirs --
303#	Populate $DESTDIR with directories needed by NetBSD
304#
305distrib-dirs: check_DESTDIR
306	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
307	${MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
308	    -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
309
310
311# release, snapshot --
312#	Build a full distribution including kernels & install media.
313#
314release snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
315		    distribution .WAIT \
316		    snap_pre .WAIT snap_kern .WAIT \
317		    snap_post .WAIT snap_md_post
318	(cd ${NETBSDSRCDIR}/distrib/sets; ${MAKE} sets)
319	${MAKESUMS} -t ${RELEASEDIR}/${MACHINE}/binary/kernel '*.gz'
320
321
322# iso-image --
323#	Standalone target to create a CDROM image after the release
324#	was composed.  Should be run after "make release" in src and xsrc.
325#
326#	Note: At least mkisofs 2.0 should be used.
327#
328CDROM.image=${RELEASEDIR}/${MACHINE}/installation/cdrom/netbsd-${MACHINE}.iso
329CDROM.dir=	cdrom.dir
330CDROM.pathlist=	cdrom.pathlist
331
332iso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image-md-post
333	${MAKESUMS} -t ${RELEASEDIR}/${MACHINE}/installation/cdrom '*.iso'
334
335iso-image-setup: check_RELEASEDIR
336	rm -f ${CDROM.pathlist}
337	echo "${MACHINE}=${RELEASEDIR}/${MACHINE}" >> ${CDROM.pathlist}
338	mkdir -p ${CDROM.dir}
339	mkdir -p ${RELEASEDIR}/${MACHINE}/installation/cdrom
340
341# iso-image-mi --
342#	Create the image after the MD operations have completed.
343#
344iso-image-mi: check_DESTDIR check_RELEASEDIR .WAIT \
345		iso-image-setup .WAIT iso-image-md-pre
346	@if ! ${MKISOFS} --version; then \
347		echo "install pkgsrc/sysutils/cdrecord and run 'make iso-image'." ; \
348		false; \
349	fi
350	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
351	    -o ${CDROM.image} ${CDROM.dir}
352
353# iso-image-md-pre --
354#	Setup ${CDROM.dir} to produce a bootable CD image.
355#	Overridden by etc.$MACHINE/Makefile.inc
356#
357iso-image-md-pre: check_DESTDIR check_RELEASEDIR
358#	(empty -- look in the machine-dependent Makefile.inc)
359
360# iso-image-md-post --
361#	Fixup the CD-image to be bootable.
362#	Overridden by etc.$MACHINE/Makefile.inc
363#
364iso-image-md-post: check_DESTDIR check_RELEASEDIR .WAIT iso-image-mi
365#	(empty -- look in the machine-dependent Makefile.inc)
366
367
368# snap_pre --
369#	Create ${RELEASEDIR} and necessary subdirectories.
370#
371snap_pre: check_DESTDIR check_RELEASEDIR
372	${INSTALL} -d -m 755 ${RELEASEDIR}
373.ifndef UPDATE
374# Could be a mount point, ignore the errors
375	-/bin/rm -rf ${RELEASEDIR}/${MACHINE}
376.endif
377	${INSTALL} -d -m 755 ${RELEASEDIR}/${MACHINE}
378.for dir in ${INSTALLATION_DIRS}
379	${INSTALL} -d -m 755 ${RELEASEDIR}/${MACHINE}/${dir}
380.endfor
381
382# snap_post --
383#	Build the install media and notes from distrib
384#
385snap_post: check_DESTDIR check_RELEASEDIR
386.ifndef UPDATE
387	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
388.endif
389	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
390	    ${MAKE} release
391
392# snap_kern --
393#	This target builds the kernels specified by each port.
394#	A port may specify the following kernels:
395#
396#	KERNEL_SETS		The list of kernels that will be
397#				packaged into sets, named
398#				kern-${kernel}.tgz.  These kernels
399#				are also placed in the binary/kernel
400#				area of the release package as
401#				netbsd-${kernel}.gz.
402#
403#	EXTRA_KERNELS		Additional kernels to place in the
404#				binary/kernel area of the release
405#				package as netbsd-${kernel}.gz, but
406#				which are not placed into sets. This
407#				allows a port to provide e.g. a netbootable
408#				installation kernel containing a ramdisk.
409#
410#	BUILD_KERNELS		Additional kernels to build which are
411#				not placed into sets nor into the
412#				binary/kernel area of the release
413#				package.  These are typically kernels
414#				that are built for inclusion only in
415#				installation disk/CD-ROM/tape images.
416#
417#	A port may also specify KERNEL_SUFFIXES, which is an optional list
418#	of filename suffixes for kernels to include in the kernel sets and
419#	in the binary/kernel area of the release package (e.g. "netbsd" vs.
420#	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
421#	with these suffixes do not exist in the kernel build directory.
422#
423#
424# A list of all the kernels to build, which can be overridden from
425# external sources (such as make(1)'s environment or command line)
426#
427ALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
428
429GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
430		END{ if (found == 0) print "netbsd"; }'
431
432.if !target(snap_kern)						# {
433
434# build_kernels --
435#	Configure & compile kernels listed in ${ALL_KERNELS}
436#
437.if !defined(KERNELS_DONE)						# {
438.for configfile in ${ALL_KERNELS}					# {
439_KERNELS_TO_BUILD+=kern-${configfile}
440kern-${configfile}:
441	cd ${KERNCONFDIR} && ${CONFIG} -s ${KERNSRCDIR} \
442	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
443.if !defined(UPDATE)
444	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
445.endif
446	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
447.endfor	# ALL_KERNELS							# }
448.endif	# KERNELS_DONE							# }
449
450build_kernels: ${_KERNELS_TO_BUILD}
451
452# build_kernelsets --
453#	Create kernel sets from ${KERNEL_SETS} into
454#	${RELEASEDIR}/${MACHINE}/binary/sets
455#
456.for configfile in ${KERNEL_SETS}					# {
457_KERNELSETS_TO_BUILD+=kernset-${configfile}
458kernset-${configfile}:
459	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
460	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
461	kernsuffixes="${KERNEL_SUFFIXES}"; \
462	cd $${kerndir} && ( \
463		echo "/set uname=${BINOWN} gname=${BINGRP}"; \
464		echo ". type=dir optional"; \
465		for kernel in $${kernlist}; do \
466			echo "./$${kernel} type=file"; \
467			for s in $${kernsuffixes}; do \
468				if [ -f $${kernel}.$${s} ]; then \
469					echo "./$${kernel}.$${s} type=file"; \
470				fi; \
471			done; \
472		done ) | GZIP=-9 ${PAX} -O -zw \
473		    -M -N ${NETBSDSRCDIR}/etc \
474		    -f ${RELEASEDIR}/${MACHINE}/binary/sets/kern-${configfile}.tgz
475.endfor	# KERNEL_SETS							# }
476
477build_kernelsets: ${_KERNELSETS_TO_BUILD}
478
479# build_releasekernels --
480#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
481#	${RELEASEDIR}/${MACHINE}/binary/kernel
482#
483.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
484_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
485releasekern-${configfile}:
486	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
487	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
488	kernsuffixes="${KERNEL_SUFFIXES}"; \
489	cd $${kerndir} &&	\
490		gziplist=`for kernel in $${kernlist}; do \
491			echo "$${kernel}"; \
492			for s in $${kernsuffixes}; do \
493				if [ -f $${kernel}.$${s} ]; then \
494					echo "$${kernel}.$${s}"; \
495				fi; \
496			done; \
497		done`; \
498		for kernel in $${gziplist} ; do \
499		gzip -c -9 < $${kernel} > \
500		    ${RELEASEDIR}/${MACHINE}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
501.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
502
503build_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
504
505# snap_kern --
506#	build the kernels, then the sets & release kernels
507#
508snap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
509	    build_kernels .WAIT \
510	    build_kernelsets build_releasekernels
511
512.endif # !target(snap_kern)					# }
513
514
515# snap_md_post --
516#	Machine dependent distribution media operations.
517#	Overridden by etc.$MACHINE/Makefile.inc
518#
519snap_md_post: check_DESTDIR check_RELEASEDIR
520#	(empty -- look in the machine-dependent Makefile.inc)
521
522
523clean:
524	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
525
526.include <bsd.prog.mk>
527