Makefile revision 1.236
11.236Sjdolecek#	$NetBSD: Makefile,v 1.236 2002/12/19 20:03:46 jdolecek Exp $
21.66Smikel#	from: @(#)Makefile	8.7 (Berkeley) 5/25/95
31.1Scgd
41.96Scjs# Environment variables without default values:
51.96Scjs#   DESTDIR must be set before anything in this file will work.
61.96Scjs#   RELEASEDIR is where the tarred up stuff for a snapshot or
71.96Scjs#	release will be placed.
81.96Scjs#
91.96Scjs# Environment variables with default values:
101.96Scjs#   LOCALTIME will set the default local time for the system you
111.96Scjs#	build; it determines what /etc/localtime is symlink'd to.
121.96Scjs#   KERNSRCDIR points to kernel source; it is set by default to ../sys,
131.96Scjs#	but can be overridden.
141.96Scjs#   KERNOBJDIR is the kernel build directory, it defaults to
151.172Sjlam#	${KERNSRCDIR}/arch/${MACHINE}/compile, but can be overridden.
161.96Scjs#   KERNCONFDIR is where the configuration files for kernels are found;
171.96Scjs#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
181.97Scjs#   UPDATE is normally undefined; if defined, don't do a 'make clean'
191.97Scjs#	before kernel compile
201.96Scjs#   NO_SENDMAIL is normally undefined; if defined, it will not do a
211.96Scjs#	`make distribution' in the sendmail config file source directory.
221.154Sthorpej#
231.96Scjs# Targets:
241.96Scjs#    distribution: makes a full NetBSD distribution in DESTDIR. If
251.96Scjs#	INSTALL_DONE is set, it will not do a `make install.'
261.182Schs#	if DISTRIBUTION_DONE is set, it will not do anything.
271.96Scjs#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
281.96Scjs#	Called by distribution.
291.96Scjs#    snapshot: calls distribution, above, and then tars up the files
301.96Scjs#	into a release(7) format in RELEASEDIR. Any port-dependent
311.96Scjs#	stuff for this target is found in etc.${MACHINE}/Makefile.inc.
321.106Scjs#    release: a synonym for `snapshot'
331.96Scjs
341.199Stv# setting NOOBJ prevents "make obj" from doing anything;
351.199Stv# an objdir would break the installation stuff below
361.199StvNOOBJ=		# defined
371.199Stv
381.155Sthorpej# For NO_SENDMAIL, INSTPRIV, MKCRYPTO
391.90Skim.include <bsd.own.mk>
401.187Sjmc
411.211Slukem# For KERNSRCDIR, KERNOBJDIR, ...
421.211Slukem.include <bsd.kernobj.mk>
431.211Slukem
441.211Slukem
451.187Sjmc.MAKEOVERRIDES+=	USETOOLS
461.90Skim
471.23ScgdTZDIR=		/usr/share/zoneinfo
481.157SkleinkLOCALTIME?=	UTC
491.198SjmcPWD_MKDB?=	pwd_mkdb
501.233SlukemMAKESUMS=	CKSUM=${CKSUM:Q} sh ${NETBSDSRCDIR}/distrib/sets/makesums
511.19Sderaadt
521.161Shubertf# Flags for creating ISO CDROM image
531.161Shubertf# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
541.161ShubertfMKISOFS?=	mkisofs
551.233SlukemDISTRIBREV!=	sh ${KERNSRCDIR}/conf/osrelease.sh -s
561.224Sbjh21# ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
571.224Sbjh21ISO_VOLID!=	echo NETBSD_${MACHINE}_${DISTRIBREV} | tr a-z A-Z
581.161ShubertfMKISOFS_FLAGS+= -J -l \
591.161Shubertf		-r -T -v \
601.224Sbjh21		-V ${ISO_VOLID} \
611.161Shubertf		-P "The NetBSD Project" \
621.164Shubertf		-m "${RELEASEDIR}/installation/cdrom"
631.1Scgd
641.80Sjonathan# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
651.80Sjonathan# are empty, to preserve the old semantics of setting them below with "=".
661.200SlukemBIN1=
671.80SjonathanBIN2=
681.80SjonathanBIN3=
691.80Sjonathan
701.117Ssimonb# Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
711.117Ssimonb# add to this.
721.117Ssimonb# NOTE: Parent directories must be listed before subdirectories.
731.217SlukemINSTALLATION_DIRS=	binary binary/sets binary/kernel installation
741.117Ssimonb
751.71Scjs.if exists(etc.${MACHINE}/Makefile.inc)
761.71Scjs.include "etc.${MACHINE}/Makefile.inc"
771.71Scjs.endif
781.32Sjtc
791.21Scgd# -rw-r--r--
801.21ScgdBINOWN= root
811.21ScgdBINGRP= wheel
821.227SperryUTMPGRP= utmp
831.184SlukemBIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
841.223Sfredette	daily.conf dm.conf floppytab ftpchroot ftpusers \
851.131Sveego	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
861.131Sveego	mailer.conf man.conf monthly monthly.conf mrouted.conf \
871.151Sfvdl	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
881.213Sperry	passwd.conf phones printcap profile protocols rbootd.conf rc rc.conf \
891.159Slukem	rc.lkm rc.local rc.subr rc.shutdown remote rpc \
901.142Stsarna	security security.conf services shells sysctl.conf syslog.conf \
911.142Stsarna	weekly weekly.conf wscons.conf \
921.236Sjdolecek	etc.${MACHINE}/ttys
931.236Sjdolecek
941.236Sjdolecek# use machine-specific disktab if it exists, or the MI one otherwise
951.236Sjdolecek.if exists(etc.${MACHINE}/disktab)
961.236SjdolecekBIN1+=	etc.${MACHINE}/disktab
971.236Sjdolecek.else
981.236SjdolecekBIN1+=	disktab
991.236Sjdolecek.endif
1001.105Smycroft
1011.234Sjdolecek.if exists(etc.${MACHINE}/ld.so.conf)
1021.234SjdolecekBIN1+=	etc.${MACHINE}/ld.so.conf
1031.152Sperry.endif
1041.152Sperry
1051.234Sjdolecek.if exists(etc.${MACHINE}/ttyaction)
1061.234SjdolecekBIN1+=	etc.${MACHINE}/ttyaction
1071.105Smycroft.endif
1081.1Scgd
1091.46Sderaadt# -rw-rw-r--
1101.80SjonathanBIN2+=	motd
1111.1Scgd
1121.77Smycroft# -rw-------
1131.80SjonathanBIN3+=	hosts.equiv
1141.77Smycroft
1151.230SperryETC_PKG=-T etc_pkg
1161.230SperryBASE_PKG=-T base_pkg
1171.230SperryETC_INSTALL_FILE=${INSTALL_FILE} ${ETC_PKG}
1181.230SperryETC_INSTALL_LINK=${INSTALL_LINK} ${ETC_PKG}
1191.230SperryETC_INSTALL_SYMLINK=${INSTALL_SYMLINK} ${ETC_PKG}
1201.230Sperry
1211.144SthorpejNAMEDB=	127 root.cache named.conf localhost loopback.v6
1221.1Scgd
1231.220Sitojun.if make(install-etc-files)						# {
1241.221Sitojun.include <bsd.endian.mk>
1251.191Stv.if ${TARGET_ENDIANNESS} == "1234"
1261.221SitojunTARGET_ENDIANNESS=	-L
1271.191Stv.elif ${TARGET_ENDIANNESS} == "4321"
1281.221SitojunTARGET_ENDIANNESS=	-B
1291.170Sjdolecek.else
1301.170SjdolecekTARGET_ENDIANNESS=
1311.191Stv.endif
1321.220Sitojun.endif	# install-etc-files						# }
1331.149Ssjg
1341.149Ssjgobj:
1351.149Ssjg	mkdir -p ${KERNOBJDIR}
1361.149Ssjg
1371.204Slukemdistribution: check_DESTDIR .WAIT distrib-dirs
1381.182Schs.if !defined(DISTRIBUTION_DONE)
1391.87Sperry.if !defined(INSTALL_DONE)
1401.233Slukem	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= includes)
1411.233Slukem	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= install)
1421.200Slukem.endif	# !INSTALL_DONE
1431.193Sthorpej	${MAKE} install-etc-files
1441.200Slukem.endif	# !DISTRIBUTION_DONE
1451.193Sthorpej
1461.204Slukeminstall-etc-files: check_DESTDIR
1471.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1481.230Sperry	    ${BIN1} ${DESTDIR}/etc
1491.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
1501.230Sperry	    ${BIN2} ${DESTDIR}/etc
1511.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
1521.230Sperry	    ${BIN3} ${DESTDIR}/etc
1531.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1541.230Sperry	    aliases ${DESTDIR}/etc/mail
1551.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1561.230Sperry	    /dev/null ${DESTDIR}/etc/mail/local-host-names
1571.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1581.230Sperry	    crontab ${DESTDIR}/var/cron/tabs/root
1591.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1601.230Sperry	    master.passwd ${DESTDIR}/etc
1611.198Sjmc	${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
1621.230Sperry	    ${DESTDIR}/etc/master.passwd
1631.194Sperry.if defined(UNPRIVED)
1641.222Slukem	( \
1651.230Sperry	    echo "/etc/passwd type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
1661.230Sperry	    echo "/etc/pwd.db type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
1671.230Sperry	    echo "/etc/spwd.db type=file mode=0600 uname=root gname=wheel tags=etc_pkg"; \
1681.222Slukem	) | \
1691.222Slukem	    sed -e "s|^/|./${DESTDIR}/|g" -e "s|//|/|g" | ${CAT} -l >>${METALOG}
1701.200Slukem.endif	# UNPRIVED
1711.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
1721.230Sperry	    MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
1731.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1741.230Sperry	    minfree ${DESTDIR}/var/crash
1751.1Scgd	(cd root; \
1761.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1771.230Sperry		    dot.cshrc ${DESTDIR}/root/.cshrc; \
1781.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1791.230Sperry		    dot.klogin ${DESTDIR}/root/.klogin; \
1801.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1811.230Sperry		    dot.login ${DESTDIR}/root/.login; \
1821.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1831.230Sperry		    dot.profile ${DESTDIR}/root/.profile; \
1841.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1851.230Sperry		    dot.shrc ${DESTDIR}/root/.shrc; \
1861.189Sperry		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
1871.230Sperry		${ETC_INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
1881.230Sperry		${ETC_INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
1891.162Slukem	(cd defaults; ${MAKE} install)
1901.83Smrg	(cd mtree; ${MAKE} install)
1911.63Smikel	(cd namedb; \
1921.230Sperry		${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1931.124Ssimonb		    ${NAMEDB} ${DESTDIR}/etc/namedb)
1941.140Slukem	(cd rc.d; ${MAKE} install)
1951.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1961.230Sperry	    postinstall ${DESTDIR}/etc
1971.230Sperry	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
1981.230Sperry	    ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
1991.230Sperry	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
2001.230Sperry	    /usr/sbin/rmt ${DESTDIR}/etc/rmt
2011.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 664 \
2021.230Sperry	    /dev/null ${DESTDIR}/etc/dumpdates
2031.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 600 \
2041.230Sperry	    /dev/null ${DESTDIR}/etc/skeykeys
2051.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2061.230Sperry	    /dev/null ${DESTDIR}/var/at/at.deny
2071.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2081.230Sperry	    /dev/null ${DESTDIR}/var/cron/log
2091.230Sperry	${ETC_INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 \
2101.230Sperry	    /dev/null ${DESTDIR}/var/db/locate.database
2111.230Sperry	${ETC_INSTALL_FILE} -o uucp -g dialer -m 640 \
2121.230Sperry	    /dev/null ${DESTDIR}/var/log/aculog
2131.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2141.230Sperry	    /dev/null ${DESTDIR}/var/log/authlog
2151.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
2161.230Sperry	    /dev/null ${DESTDIR}/var/log/lastlog
2171.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 \
2181.230Sperry	    /dev/null ${DESTDIR}/var/log/lpd-errs
2191.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2201.230Sperry	    /dev/null ${DESTDIR}/var/log/maillog
2211.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2221.230Sperry	    /dev/null ${DESTDIR}/var/log/messages
2231.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2241.230Sperry	    /dev/null ${DESTDIR}/var/log/secure
2251.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2261.230Sperry	    /dev/null ${DESTDIR}/var/log/sendmail.st
2271.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2281.230Sperry	    /dev/null ${DESTDIR}/var/log/wtmp
2291.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2301.230Sperry	    /dev/null ${DESTDIR}/var/log/wtmpx
2311.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2321.230Sperry	    /dev/null ${DESTDIR}/var/log/xferlog
2331.230Sperry	${ETC_INSTALL_FILE} -o daemon -g staff -m 664 \
2341.230Sperry	    /dev/null ${DESTDIR}/var/msgs/bounds
2351.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
2361.230Sperry	    /dev/null ${DESTDIR}/var/run/utmp
2371.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
2381.230Sperry	    /dev/null ${DESTDIR}/var/run/utmpx
2391.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2401.230Sperry	    /dev/null ${DESTDIR}/var/games/atc_scores
2411.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2421.230Sperry	    /dev/null ${DESTDIR}/var/games/battlestar.log
2431.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2441.230Sperry	    /dev/null ${DESTDIR}/var/games/cfscores
2451.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2461.230Sperry	    /dev/null ${DESTDIR}/var/games/criblog
2471.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 660 \
2481.231Sperry	    /dev/null ${DESTDIR}/var/games/hackdir/perm
2491.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 660 \
2501.231Sperry	    /dev/null ${DESTDIR}/var/games/hackdir/record
2511.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2521.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/llog12.0
2531.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2541.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/lscore12.0
2551.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2561.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/playerids
2571.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2581.230Sperry	    /dev/null ${DESTDIR}/var/games/robots_roll
2591.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2601.230Sperry	    /dev/null ${DESTDIR}/var/games/rogue.scores
2611.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2621.230Sperry	    /dev/null ${DESTDIR}/var/games/saillog
2631.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2641.230Sperry	    /dev/null ${DESTDIR}/var/games/snakerawscores
2651.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2661.230Sperry	    /dev/null ${DESTDIR}/var/games/snake.log
2671.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2681.230Sperry	    /dev/null ${DESTDIR}/var/games/tetris.scores
2691.165Ssimonb	(cd skel; ${MAKE} distribution)
2701.233Slukem	(cd ${NETBSDSRCDIR}/usr.bin/mail; ${MAKE} distribution)
2711.233Slukem	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/postfix/; ${MAKE} distribution)
2721.155Sthorpej.if (${MKCRYPTO} != "no")
2731.233Slukem	(cd ${NETBSDSRCDIR}/usr.bin/ssh; ${MAKE} distribution)
2741.155Sthorpej.endif
2751.200Slukem.if !defined(NO_SENDMAIL)
2761.233Slukem	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
2771.90Skim.endif
2781.1Scgd
2791.204Slukemdistrib-dirs: check_DESTDIR
2801.230Sperry	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
2811.235Slukem	${MTREE} -def mtree/NetBSD.dist -N ${.CURDIR} \
2821.235Slukem	    -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
2831.189Sperry	rm -f ${DESTDIR}/sys
2841.230Sperry	${INSTALL_SYMLINK} -o root -g wheel -m 755 ${BASE_PKG} \
2851.230Sperry	    usr/src/sys ${DESTDIR}/sys
2861.200Slukem
2871.204Slukemrelease snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
2881.233Slukem		    distribution .WAIT \
2891.233Slukem		    snap_pre .WAIT snap_kern .WAIT \
2901.233Slukem		    snap_post .WAIT snap_md_post
2911.233Slukem	(cd ${NETBSDSRCDIR}/distrib/sets; ${MAKE} sets)
2921.206Sbjh21	${MAKESUMS} -t ${RELEASEDIR}/binary/kernel '*.gz'
2931.161Shubertf
2941.161Shubertf# Standalone target to create a CDROM image after the release
2951.161Shubertf# was composed. Should be run after "make build" in both src and xsrc
2961.204Slukemiso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_post
2971.233Slukem#	empty target
2981.161Shubertf
2991.204Slukemiso-image_mi: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_pre
3001.161Shubertf	@if ${MKISOFS} --version; then \
3011.161Shubertf		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
3021.161Shubertf		${MKISOFS} ${MKISOFS_FLAGS} \
3031.230Sperry		    -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
3041.230Sperry		    ${RELEASEDIR} ; \
3051.206Sbjh21		${MAKESUMS} -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
3061.161Shubertf	else \
3071.161Shubertf		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
3081.161Shubertf	fi
3091.161Shubertf
3101.161Shubertf# Setup the $RELEASEDIR to produce a bootable CD image:
3111.204Slukemiso-image_md_pre: check_DESTDIR check_RELEASEDIR
3121.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
3131.161Shubertf
3141.161Shubertf# Fixup the  CD-image to be bootable
3151.204Slukemiso-image_md_post: check_DESTDIR check_RELEASEDIR .WAIT iso-image_mi
3161.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
3171.41Scgd
3181.204Slukemsnap_pre: check_DESTDIR check_RELEASEDIR
3191.168Sjmc# Could be a mount point, ignore the errors
3201.167Sjmc	-/bin/rm -rf ${RELEASEDIR}
3211.202Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}
3221.117Ssimonb.for dir in ${INSTALLATION_DIRS}
3231.202Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}/${dir}
3241.117Ssimonb.endfor
3251.96Scjs
3261.233Slukemsnap_post: check_DESTDIR check_RELEASEDIR
3271.233Slukem.ifndef UPDATE
3281.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
3291.233Slukem.endif
3301.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
3311.233Slukem	    ${MAKE} release
3321.233Slukem
3331.232Slukem# snap_kern --
3341.232Slukem# This target builds the kernels specified by each port.
3351.232Slukem# A port may specify the following kernels:
3361.196Sthorpej#
3371.196Sthorpej#	KERNEL_SETS		The list of kernels that will be
3381.196Sthorpej#				packaged into sets, named
3391.196Sthorpej#				kern-${kernel}.tgz.  These kernels
3401.203Schs#				are also placed in the binary/kernel
3411.196Sthorpej#				area of the release package as
3421.196Sthorpej#				netbsd-${kernel}.gz.
3431.196Sthorpej#
3441.196Sthorpej#	EXTRA_KERNELS		Additional kernels to place in the
3451.203Schs#				binary/kernel area of the release
3461.196Sthorpej#				package as netbsd-${kernel}.gz, but
3471.196Sthorpej#				which are not placed into sets. This
3481.196Sthorpej#				allows a port to provide e.g. a netbootable
3491.196Sthorpej#				installation kernel containing a ramdisk.
3501.196Sthorpej#
3511.196Sthorpej#	BUILD_KERNELS		Additional kernels to build which are
3521.196Sthorpej#				not placed into sets nor into the
3531.203Schs#				binary/kernel area of the release
3541.196Sthorpej#				package.  These are typically kernels
3551.196Sthorpej#				that are built for inclusion only in
3561.196Sthorpej#				installation disk/CD-ROM/tape images.
3571.116Sfair#
3581.197Sthorpej# A port may also specify KERNEL_SUFFIXES, which is an optional list
3591.197Sthorpej# of filename suffixes for kernels to include in the kernel sets and
3601.203Schs# in the binary/kernel area of the release package (e.g. "netbsd" vs.
3611.197Sthorpej# "netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
3621.197Sthorpej# with these suffixes do not exist in the kernel build directory.
3631.197Sthorpej#
3641.229Slukem#
3651.229Slukem# A list of all the kernels to build, which can be overridden from
3661.229Slukem# external sources (such as make(1)'s environment or command line)
3671.229Slukem#
3681.229SlukemALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
3691.229Slukem#
3701.116SfairGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
3711.116Sfair		END{ if (found == 0) print "netbsd"; }'
3721.96Scjs#
3731.232Slukem.if !target(snap_kern)						# {
3741.232Slukem
3751.232Slukem# build_kernels --
3761.232Slukem#	Configure & compile kernels listed in ${ALL_KERNELS}
3771.232Slukem#
3781.201Slukem.if !defined(KERNELS_DONE)						# {
3791.232Slukem.for configfile in ${ALL_KERNELS}					# {
3801.232Slukem_KERNELS_TO_BUILD+=kern-${configfile}
3811.232Slukemkern-${configfile}:
3821.232Slukem	cd ${KERNCONFDIR} && ${CONFIG} -s ${KERNSRCDIR} \
3831.232Slukem	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
3841.201Slukem.if !defined(UPDATE)
3851.200Slukem	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
3861.96Scjs.endif
3871.218Ssommerfe	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
3881.232Slukem.endfor	# ALL_KERNELS							# }
3891.232Slukem.endif	# KERNELS_DONE							# }
3901.232Slukem
3911.232Slukembuild_kernels: ${_KERNELS_TO_BUILD}
3921.232Slukem
3931.232Slukem# build_kernelsets --
3941.232Slukem#	Create kernel sets from ${KERNEL_SETS} into ${RELEASEDIR}/binary/sets
3951.232Slukem#
3961.232Slukem.for configfile in ${KERNEL_SETS}					# {
3971.232Slukem_KERNELSETS_TO_BUILD+=kernset-${configfile}
3981.232Slukemkernset-${configfile}:
3991.197Sthorpej	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
4001.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
4011.207Sbjh21	kernsuffixes="${KERNEL_SUFFIXES}"; \
4021.210Slukem	cd $${kerndir} && ( \
4031.214Slukem		echo "/set uname=${BINOWN} gname=${BINGRP}"; \
4041.214Slukem		echo ". type=dir optional"; \
4051.210Slukem		for kernel in $${kernlist}; do \
4061.214Slukem			echo "./$${kernel} type=file"; \
4071.207Sbjh21			for s in $${kernsuffixes}; do \
4081.197Sthorpej				if [ -f $${kernel}.$${s} ]; then \
4091.214Slukem					echo "./$${kernel}.$${s} type=file"; \
4101.197Sthorpej				fi; \
4111.197Sthorpej			done; \
4121.216Slukem		done ) | GZIP=-9 ${PAX} -zw \
4131.235Slukem		    -M -N ${NETBSDSRCDIR}/etc \
4141.210Slukem		    -f ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz
4151.232Slukem.endfor	# KERNEL_SETS							# }
4161.232Slukem
4171.232Slukembuild_kernelsets: ${_KERNELSETS_TO_BUILD}
4181.232Slukem
4191.232Slukem# build_releasekernels --
4201.232Slukem#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
4211.232Slukem#	${RELEASEDIR}/binary/kernel
4221.232Slukem#
4231.232Slukem.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
4241.232Slukem_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
4251.232Slukemreleasekern-${configfile}:
4261.197Sthorpej	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
4271.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
4281.207Sbjh21	kernsuffixes="${KERNEL_SUFFIXES}"; \
4291.197Sthorpej	cd $${kerndir} &&	\
4301.197Sthorpej		gziplist=`for kernel in $${kernlist}; do \
4311.197Sthorpej			echo "$${kernel}"; \
4321.207Sbjh21			for s in $${kernsuffixes}; do \
4331.197Sthorpej				if [ -f $${kernel}.$${s} ]; then \
4341.197Sthorpej					echo "$${kernel}.$${s}"; \
4351.197Sthorpej				fi; \
4361.197Sthorpej			done; \
4371.197Sthorpej		done`; \
4381.197Sthorpej		for kernel in $${gziplist} ; do \
4391.114Sfair		gzip -c -9 < $${kernel} > \
4401.201Slukem		    ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
4411.232Slukem.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
4421.232Slukem
4431.232Slukembuild_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
4441.232Slukem
4451.232Slukem# snap_kern --
4461.232Slukem#	build the kernels, then the sets & release kernels
4471.232Slukemsnap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
4481.232Slukem	    build_kernels .WAIT \
4491.232Slukem	    build_kernelsets build_releasekernels
4501.232Slukem
4511.232Slukem.endif # !target(snap_kern)					# }
4521.232Slukem
4531.108Sdrochner
4541.204Slukemsnap_md_post: check_DESTDIR check_RELEASEDIR
4551.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
4561.7Scgd
4571.1Scgd.include <bsd.prog.mk>
458