Makefile revision 1.235
11.235Slukem#	$NetBSD: Makefile,v 1.235 2002/12/19 12:35:01 lukem 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.109Sdrochner	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
931.105Smycroft
941.234Sjdolecek.if exists(etc.${MACHINE}/ld.so.conf)
951.234SjdolecekBIN1+=	etc.${MACHINE}/ld.so.conf
961.152Sperry.endif
971.152Sperry
981.234Sjdolecek.if exists(etc.${MACHINE}/ttyaction)
991.234SjdolecekBIN1+=	etc.${MACHINE}/ttyaction
1001.105Smycroft.endif
1011.1Scgd
1021.46Sderaadt# -rw-rw-r--
1031.80SjonathanBIN2+=	motd
1041.1Scgd
1051.77Smycroft# -rw-------
1061.80SjonathanBIN3+=	hosts.equiv
1071.77Smycroft
1081.230SperryETC_PKG=-T etc_pkg
1091.230SperryBASE_PKG=-T base_pkg
1101.230SperryETC_INSTALL_FILE=${INSTALL_FILE} ${ETC_PKG}
1111.230SperryETC_INSTALL_LINK=${INSTALL_LINK} ${ETC_PKG}
1121.230SperryETC_INSTALL_SYMLINK=${INSTALL_SYMLINK} ${ETC_PKG}
1131.230Sperry
1141.144SthorpejNAMEDB=	127 root.cache named.conf localhost loopback.v6
1151.1Scgd
1161.220Sitojun.if make(install-etc-files)						# {
1171.221Sitojun.include <bsd.endian.mk>
1181.191Stv.if ${TARGET_ENDIANNESS} == "1234"
1191.221SitojunTARGET_ENDIANNESS=	-L
1201.191Stv.elif ${TARGET_ENDIANNESS} == "4321"
1211.221SitojunTARGET_ENDIANNESS=	-B
1221.170Sjdolecek.else
1231.170SjdolecekTARGET_ENDIANNESS=
1241.191Stv.endif
1251.220Sitojun.endif	# install-etc-files						# }
1261.149Ssjg
1271.149Ssjgobj:
1281.149Ssjg	mkdir -p ${KERNOBJDIR}
1291.149Ssjg
1301.204Slukemdistribution: check_DESTDIR .WAIT distrib-dirs
1311.182Schs.if !defined(DISTRIBUTION_DONE)
1321.87Sperry.if !defined(INSTALL_DONE)
1331.233Slukem	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= includes)
1341.233Slukem	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= install)
1351.200Slukem.endif	# !INSTALL_DONE
1361.193Sthorpej	${MAKE} install-etc-files
1371.200Slukem.endif	# !DISTRIBUTION_DONE
1381.193Sthorpej
1391.204Slukeminstall-etc-files: check_DESTDIR
1401.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1411.230Sperry	    ${BIN1} ${DESTDIR}/etc
1421.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
1431.230Sperry	    ${BIN2} ${DESTDIR}/etc
1441.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
1451.230Sperry	    ${BIN3} ${DESTDIR}/etc
1461.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1471.230Sperry	    aliases ${DESTDIR}/etc/mail
1481.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1491.230Sperry	    /dev/null ${DESTDIR}/etc/mail/local-host-names
1501.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1511.230Sperry	    crontab ${DESTDIR}/var/cron/tabs/root
1521.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1531.230Sperry	    master.passwd ${DESTDIR}/etc
1541.198Sjmc	${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
1551.230Sperry	    ${DESTDIR}/etc/master.passwd
1561.194Sperry.if defined(UNPRIVED)
1571.222Slukem	( \
1581.230Sperry	    echo "/etc/passwd type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
1591.230Sperry	    echo "/etc/pwd.db type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
1601.230Sperry	    echo "/etc/spwd.db type=file mode=0600 uname=root gname=wheel tags=etc_pkg"; \
1611.222Slukem	) | \
1621.222Slukem	    sed -e "s|^/|./${DESTDIR}/|g" -e "s|//|/|g" | ${CAT} -l >>${METALOG}
1631.200Slukem.endif	# UNPRIVED
1641.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
1651.230Sperry	    MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
1661.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1671.230Sperry	    minfree ${DESTDIR}/var/crash
1681.1Scgd	(cd root; \
1691.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1701.230Sperry		    dot.cshrc ${DESTDIR}/root/.cshrc; \
1711.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1721.230Sperry		    dot.klogin ${DESTDIR}/root/.klogin; \
1731.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1741.230Sperry		    dot.login ${DESTDIR}/root/.login; \
1751.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1761.230Sperry		    dot.profile ${DESTDIR}/root/.profile; \
1771.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1781.230Sperry		    dot.shrc ${DESTDIR}/root/.shrc; \
1791.189Sperry		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
1801.230Sperry		${ETC_INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
1811.230Sperry		${ETC_INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
1821.162Slukem	(cd defaults; ${MAKE} install)
1831.83Smrg	(cd mtree; ${MAKE} install)
1841.63Smikel	(cd namedb; \
1851.230Sperry		${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1861.124Ssimonb		    ${NAMEDB} ${DESTDIR}/etc/namedb)
1871.140Slukem	(cd rc.d; ${MAKE} install)
1881.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1891.230Sperry	    postinstall ${DESTDIR}/etc
1901.230Sperry	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
1911.230Sperry	    ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
1921.230Sperry	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
1931.230Sperry	    /usr/sbin/rmt ${DESTDIR}/etc/rmt
1941.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 664 \
1951.230Sperry	    /dev/null ${DESTDIR}/etc/dumpdates
1961.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 600 \
1971.230Sperry	    /dev/null ${DESTDIR}/etc/skeykeys
1981.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1991.230Sperry	    /dev/null ${DESTDIR}/var/at/at.deny
2001.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2011.230Sperry	    /dev/null ${DESTDIR}/var/cron/log
2021.230Sperry	${ETC_INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 \
2031.230Sperry	    /dev/null ${DESTDIR}/var/db/locate.database
2041.230Sperry	${ETC_INSTALL_FILE} -o uucp -g dialer -m 640 \
2051.230Sperry	    /dev/null ${DESTDIR}/var/log/aculog
2061.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2071.230Sperry	    /dev/null ${DESTDIR}/var/log/authlog
2081.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
2091.230Sperry	    /dev/null ${DESTDIR}/var/log/lastlog
2101.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 \
2111.230Sperry	    /dev/null ${DESTDIR}/var/log/lpd-errs
2121.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2131.230Sperry	    /dev/null ${DESTDIR}/var/log/maillog
2141.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2151.230Sperry	    /dev/null ${DESTDIR}/var/log/messages
2161.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2171.230Sperry	    /dev/null ${DESTDIR}/var/log/secure
2181.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2191.230Sperry	    /dev/null ${DESTDIR}/var/log/sendmail.st
2201.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2211.230Sperry	    /dev/null ${DESTDIR}/var/log/wtmp
2221.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2231.230Sperry	    /dev/null ${DESTDIR}/var/log/wtmpx
2241.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2251.230Sperry	    /dev/null ${DESTDIR}/var/log/xferlog
2261.230Sperry	${ETC_INSTALL_FILE} -o daemon -g staff -m 664 \
2271.230Sperry	    /dev/null ${DESTDIR}/var/msgs/bounds
2281.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
2291.230Sperry	    /dev/null ${DESTDIR}/var/run/utmp
2301.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
2311.230Sperry	    /dev/null ${DESTDIR}/var/run/utmpx
2321.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2331.230Sperry	    /dev/null ${DESTDIR}/var/games/atc_scores
2341.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2351.230Sperry	    /dev/null ${DESTDIR}/var/games/battlestar.log
2361.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2371.230Sperry	    /dev/null ${DESTDIR}/var/games/cfscores
2381.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2391.230Sperry	    /dev/null ${DESTDIR}/var/games/criblog
2401.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 660 \
2411.231Sperry	    /dev/null ${DESTDIR}/var/games/hackdir/perm
2421.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 660 \
2431.231Sperry	    /dev/null ${DESTDIR}/var/games/hackdir/record
2441.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2451.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/llog12.0
2461.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2471.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/lscore12.0
2481.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2491.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/playerids
2501.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2511.230Sperry	    /dev/null ${DESTDIR}/var/games/robots_roll
2521.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2531.230Sperry	    /dev/null ${DESTDIR}/var/games/rogue.scores
2541.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2551.230Sperry	    /dev/null ${DESTDIR}/var/games/saillog
2561.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2571.230Sperry	    /dev/null ${DESTDIR}/var/games/snakerawscores
2581.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2591.230Sperry	    /dev/null ${DESTDIR}/var/games/snake.log
2601.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2611.230Sperry	    /dev/null ${DESTDIR}/var/games/tetris.scores
2621.165Ssimonb	(cd skel; ${MAKE} distribution)
2631.233Slukem	(cd ${NETBSDSRCDIR}/usr.bin/mail; ${MAKE} distribution)
2641.233Slukem	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/postfix/; ${MAKE} distribution)
2651.155Sthorpej.if (${MKCRYPTO} != "no")
2661.233Slukem	(cd ${NETBSDSRCDIR}/usr.bin/ssh; ${MAKE} distribution)
2671.155Sthorpej.endif
2681.200Slukem.if !defined(NO_SENDMAIL)
2691.233Slukem	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
2701.90Skim.endif
2711.1Scgd
2721.204Slukemdistrib-dirs: check_DESTDIR
2731.230Sperry	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
2741.235Slukem	${MTREE} -def mtree/NetBSD.dist -N ${.CURDIR} \
2751.235Slukem	    -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
2761.189Sperry	rm -f ${DESTDIR}/sys
2771.230Sperry	${INSTALL_SYMLINK} -o root -g wheel -m 755 ${BASE_PKG} \
2781.230Sperry	    usr/src/sys ${DESTDIR}/sys
2791.200Slukem
2801.204Slukemrelease snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
2811.233Slukem		    distribution .WAIT \
2821.233Slukem		    snap_pre .WAIT snap_kern .WAIT \
2831.233Slukem		    snap_post .WAIT snap_md_post
2841.233Slukem	(cd ${NETBSDSRCDIR}/distrib/sets; ${MAKE} sets)
2851.206Sbjh21	${MAKESUMS} -t ${RELEASEDIR}/binary/kernel '*.gz'
2861.161Shubertf
2871.161Shubertf# Standalone target to create a CDROM image after the release
2881.161Shubertf# was composed. Should be run after "make build" in both src and xsrc
2891.204Slukemiso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_post
2901.233Slukem#	empty target
2911.161Shubertf
2921.204Slukemiso-image_mi: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_pre
2931.161Shubertf	@if ${MKISOFS} --version; then \
2941.161Shubertf		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
2951.161Shubertf		${MKISOFS} ${MKISOFS_FLAGS} \
2961.230Sperry		    -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
2971.230Sperry		    ${RELEASEDIR} ; \
2981.206Sbjh21		${MAKESUMS} -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
2991.161Shubertf	else \
3001.161Shubertf		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
3011.161Shubertf	fi
3021.161Shubertf
3031.161Shubertf# Setup the $RELEASEDIR to produce a bootable CD image:
3041.204Slukemiso-image_md_pre: check_DESTDIR check_RELEASEDIR
3051.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
3061.161Shubertf
3071.161Shubertf# Fixup the  CD-image to be bootable
3081.204Slukemiso-image_md_post: check_DESTDIR check_RELEASEDIR .WAIT iso-image_mi
3091.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
3101.41Scgd
3111.204Slukemsnap_pre: check_DESTDIR check_RELEASEDIR
3121.168Sjmc# Could be a mount point, ignore the errors
3131.167Sjmc	-/bin/rm -rf ${RELEASEDIR}
3141.202Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}
3151.117Ssimonb.for dir in ${INSTALLATION_DIRS}
3161.202Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}/${dir}
3171.117Ssimonb.endfor
3181.96Scjs
3191.233Slukemsnap_post: check_DESTDIR check_RELEASEDIR
3201.233Slukem.ifndef UPDATE
3211.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
3221.233Slukem.endif
3231.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
3241.233Slukem	    ${MAKE} release
3251.233Slukem
3261.232Slukem# snap_kern --
3271.232Slukem# This target builds the kernels specified by each port.
3281.232Slukem# A port may specify the following kernels:
3291.196Sthorpej#
3301.196Sthorpej#	KERNEL_SETS		The list of kernels that will be
3311.196Sthorpej#				packaged into sets, named
3321.196Sthorpej#				kern-${kernel}.tgz.  These kernels
3331.203Schs#				are also placed in the binary/kernel
3341.196Sthorpej#				area of the release package as
3351.196Sthorpej#				netbsd-${kernel}.gz.
3361.196Sthorpej#
3371.196Sthorpej#	EXTRA_KERNELS		Additional kernels to place in the
3381.203Schs#				binary/kernel area of the release
3391.196Sthorpej#				package as netbsd-${kernel}.gz, but
3401.196Sthorpej#				which are not placed into sets. This
3411.196Sthorpej#				allows a port to provide e.g. a netbootable
3421.196Sthorpej#				installation kernel containing a ramdisk.
3431.196Sthorpej#
3441.196Sthorpej#	BUILD_KERNELS		Additional kernels to build which are
3451.196Sthorpej#				not placed into sets nor into the
3461.203Schs#				binary/kernel area of the release
3471.196Sthorpej#				package.  These are typically kernels
3481.196Sthorpej#				that are built for inclusion only in
3491.196Sthorpej#				installation disk/CD-ROM/tape images.
3501.116Sfair#
3511.197Sthorpej# A port may also specify KERNEL_SUFFIXES, which is an optional list
3521.197Sthorpej# of filename suffixes for kernels to include in the kernel sets and
3531.203Schs# in the binary/kernel area of the release package (e.g. "netbsd" vs.
3541.197Sthorpej# "netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
3551.197Sthorpej# with these suffixes do not exist in the kernel build directory.
3561.197Sthorpej#
3571.229Slukem#
3581.229Slukem# A list of all the kernels to build, which can be overridden from
3591.229Slukem# external sources (such as make(1)'s environment or command line)
3601.229Slukem#
3611.229SlukemALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
3621.229Slukem#
3631.116SfairGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
3641.116Sfair		END{ if (found == 0) print "netbsd"; }'
3651.96Scjs#
3661.232Slukem.if !target(snap_kern)						# {
3671.232Slukem
3681.232Slukem# build_kernels --
3691.232Slukem#	Configure & compile kernels listed in ${ALL_KERNELS}
3701.232Slukem#
3711.201Slukem.if !defined(KERNELS_DONE)						# {
3721.232Slukem.for configfile in ${ALL_KERNELS}					# {
3731.232Slukem_KERNELS_TO_BUILD+=kern-${configfile}
3741.232Slukemkern-${configfile}:
3751.232Slukem	cd ${KERNCONFDIR} && ${CONFIG} -s ${KERNSRCDIR} \
3761.232Slukem	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
3771.201Slukem.if !defined(UPDATE)
3781.200Slukem	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
3791.96Scjs.endif
3801.218Ssommerfe	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
3811.232Slukem.endfor	# ALL_KERNELS							# }
3821.232Slukem.endif	# KERNELS_DONE							# }
3831.232Slukem
3841.232Slukembuild_kernels: ${_KERNELS_TO_BUILD}
3851.232Slukem
3861.232Slukem# build_kernelsets --
3871.232Slukem#	Create kernel sets from ${KERNEL_SETS} into ${RELEASEDIR}/binary/sets
3881.232Slukem#
3891.232Slukem.for configfile in ${KERNEL_SETS}					# {
3901.232Slukem_KERNELSETS_TO_BUILD+=kernset-${configfile}
3911.232Slukemkernset-${configfile}:
3921.197Sthorpej	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
3931.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
3941.207Sbjh21	kernsuffixes="${KERNEL_SUFFIXES}"; \
3951.210Slukem	cd $${kerndir} && ( \
3961.214Slukem		echo "/set uname=${BINOWN} gname=${BINGRP}"; \
3971.214Slukem		echo ". type=dir optional"; \
3981.210Slukem		for kernel in $${kernlist}; do \
3991.214Slukem			echo "./$${kernel} type=file"; \
4001.207Sbjh21			for s in $${kernsuffixes}; do \
4011.197Sthorpej				if [ -f $${kernel}.$${s} ]; then \
4021.214Slukem					echo "./$${kernel}.$${s} type=file"; \
4031.197Sthorpej				fi; \
4041.197Sthorpej			done; \
4051.216Slukem		done ) | GZIP=-9 ${PAX} -zw \
4061.235Slukem		    -M -N ${NETBSDSRCDIR}/etc \
4071.210Slukem		    -f ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz
4081.232Slukem.endfor	# KERNEL_SETS							# }
4091.232Slukem
4101.232Slukembuild_kernelsets: ${_KERNELSETS_TO_BUILD}
4111.232Slukem
4121.232Slukem# build_releasekernels --
4131.232Slukem#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
4141.232Slukem#	${RELEASEDIR}/binary/kernel
4151.232Slukem#
4161.232Slukem.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
4171.232Slukem_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
4181.232Slukemreleasekern-${configfile}:
4191.197Sthorpej	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
4201.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
4211.207Sbjh21	kernsuffixes="${KERNEL_SUFFIXES}"; \
4221.197Sthorpej	cd $${kerndir} &&	\
4231.197Sthorpej		gziplist=`for kernel in $${kernlist}; do \
4241.197Sthorpej			echo "$${kernel}"; \
4251.207Sbjh21			for s in $${kernsuffixes}; do \
4261.197Sthorpej				if [ -f $${kernel}.$${s} ]; then \
4271.197Sthorpej					echo "$${kernel}.$${s}"; \
4281.197Sthorpej				fi; \
4291.197Sthorpej			done; \
4301.197Sthorpej		done`; \
4311.197Sthorpej		for kernel in $${gziplist} ; do \
4321.114Sfair		gzip -c -9 < $${kernel} > \
4331.201Slukem		    ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
4341.232Slukem.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
4351.232Slukem
4361.232Slukembuild_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
4371.232Slukem
4381.232Slukem# snap_kern --
4391.232Slukem#	build the kernels, then the sets & release kernels
4401.232Slukemsnap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
4411.232Slukem	    build_kernels .WAIT \
4421.232Slukem	    build_kernelsets build_releasekernels
4431.232Slukem
4441.232Slukem.endif # !target(snap_kern)					# }
4451.232Slukem
4461.108Sdrochner
4471.204Slukemsnap_md_post: check_DESTDIR check_RELEASEDIR
4481.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
4491.7Scgd
4501.1Scgd.include <bsd.prog.mk>
451