Makefile revision 1.239
11.239Slukem#	$NetBSD: Makefile,v 1.239 2002/12/23 06:52:49 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.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.239Slukem	    echo "./etc/passwd type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
1661.239Slukem	    echo "./etc/pwd.db type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
1671.239Slukem	    echo "./etc/spwd.db type=file mode=0600 uname=root gname=wheel tags=etc_pkg"; \
1681.239Slukem	) | ${METALOG.add}
1691.200Slukem.endif	# UNPRIVED
1701.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
1711.230Sperry	    MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
1721.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1731.230Sperry	    minfree ${DESTDIR}/var/crash
1741.1Scgd	(cd root; \
1751.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1761.230Sperry		    dot.cshrc ${DESTDIR}/root/.cshrc; \
1771.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
1781.230Sperry		    dot.klogin ${DESTDIR}/root/.klogin; \
1791.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1801.230Sperry		    dot.login ${DESTDIR}/root/.login; \
1811.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1821.230Sperry		    dot.profile ${DESTDIR}/root/.profile; \
1831.230Sperry		${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
1841.230Sperry		    dot.shrc ${DESTDIR}/root/.shrc; \
1851.189Sperry		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
1861.230Sperry		${ETC_INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
1871.230Sperry		${ETC_INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
1881.162Slukem	(cd defaults; ${MAKE} install)
1891.83Smrg	(cd mtree; ${MAKE} install)
1901.63Smikel	(cd namedb; \
1911.230Sperry		${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
1921.124Ssimonb		    ${NAMEDB} ${DESTDIR}/etc/namedb)
1931.140Slukem	(cd rc.d; ${MAKE} install)
1941.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1951.230Sperry	    postinstall ${DESTDIR}/etc
1961.230Sperry	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
1971.230Sperry	    ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
1981.230Sperry	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
1991.230Sperry	    /usr/sbin/rmt ${DESTDIR}/etc/rmt
2001.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 664 \
2011.230Sperry	    /dev/null ${DESTDIR}/etc/dumpdates
2021.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 600 \
2031.230Sperry	    /dev/null ${DESTDIR}/etc/skeykeys
2041.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2051.230Sperry	    /dev/null ${DESTDIR}/var/at/at.deny
2061.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2071.230Sperry	    /dev/null ${DESTDIR}/var/cron/log
2081.230Sperry	${ETC_INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 \
2091.230Sperry	    /dev/null ${DESTDIR}/var/db/locate.database
2101.230Sperry	${ETC_INSTALL_FILE} -o uucp -g dialer -m 640 \
2111.230Sperry	    /dev/null ${DESTDIR}/var/log/aculog
2121.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2131.230Sperry	    /dev/null ${DESTDIR}/var/log/authlog
2141.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
2151.230Sperry	    /dev/null ${DESTDIR}/var/log/lastlog
2161.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 \
2171.230Sperry	    /dev/null ${DESTDIR}/var/log/lpd-errs
2181.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2191.230Sperry	    /dev/null ${DESTDIR}/var/log/maillog
2201.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2211.230Sperry	    /dev/null ${DESTDIR}/var/log/messages
2221.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2231.230Sperry	    /dev/null ${DESTDIR}/var/log/secure
2241.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2251.230Sperry	    /dev/null ${DESTDIR}/var/log/sendmail.st
2261.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2271.230Sperry	    /dev/null ${DESTDIR}/var/log/wtmp
2281.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2291.230Sperry	    /dev/null ${DESTDIR}/var/log/wtmpx
2301.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
2311.230Sperry	    /dev/null ${DESTDIR}/var/log/xferlog
2321.230Sperry	${ETC_INSTALL_FILE} -o daemon -g staff -m 664 \
2331.230Sperry	    /dev/null ${DESTDIR}/var/msgs/bounds
2341.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
2351.230Sperry	    /dev/null ${DESTDIR}/var/run/utmp
2361.230Sperry	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
2371.230Sperry	    /dev/null ${DESTDIR}/var/run/utmpx
2381.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2391.230Sperry	    /dev/null ${DESTDIR}/var/games/atc_scores
2401.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2411.230Sperry	    /dev/null ${DESTDIR}/var/games/battlestar.log
2421.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2431.230Sperry	    /dev/null ${DESTDIR}/var/games/cfscores
2441.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2451.230Sperry	    /dev/null ${DESTDIR}/var/games/criblog
2461.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 660 \
2471.231Sperry	    /dev/null ${DESTDIR}/var/games/hackdir/perm
2481.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 660 \
2491.231Sperry	    /dev/null ${DESTDIR}/var/games/hackdir/record
2501.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2511.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/llog12.0
2521.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2531.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/lscore12.0
2541.231Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2551.231Sperry	    /dev/null ${DESTDIR}/var/games/larn/playerids
2561.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2571.230Sperry	    /dev/null ${DESTDIR}/var/games/robots_roll
2581.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2591.230Sperry	    /dev/null ${DESTDIR}/var/games/rogue.scores
2601.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2611.230Sperry	    /dev/null ${DESTDIR}/var/games/saillog
2621.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2631.230Sperry	    /dev/null ${DESTDIR}/var/games/snakerawscores
2641.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2651.230Sperry	    /dev/null ${DESTDIR}/var/games/snake.log
2661.230Sperry	${ETC_INSTALL_FILE} -o games -g games -m 664 \
2671.230Sperry	    /dev/null ${DESTDIR}/var/games/tetris.scores
2681.165Ssimonb	(cd skel; ${MAKE} distribution)
2691.233Slukem	(cd ${NETBSDSRCDIR}/usr.bin/mail; ${MAKE} distribution)
2701.233Slukem	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/postfix/; ${MAKE} distribution)
2711.155Sthorpej.if (${MKCRYPTO} != "no")
2721.233Slukem	(cd ${NETBSDSRCDIR}/usr.bin/ssh; ${MAKE} distribution)
2731.155Sthorpej.endif
2741.200Slukem.if !defined(NO_SENDMAIL)
2751.233Slukem	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
2761.90Skim.endif
2771.1Scgd
2781.204Slukemdistrib-dirs: check_DESTDIR
2791.230Sperry	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
2801.235Slukem	${MTREE} -def mtree/NetBSD.dist -N ${.CURDIR} \
2811.235Slukem	    -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
2821.200Slukem
2831.204Slukemrelease snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
2841.233Slukem		    distribution .WAIT \
2851.233Slukem		    snap_pre .WAIT snap_kern .WAIT \
2861.233Slukem		    snap_post .WAIT snap_md_post
2871.233Slukem	(cd ${NETBSDSRCDIR}/distrib/sets; ${MAKE} sets)
2881.206Sbjh21	${MAKESUMS} -t ${RELEASEDIR}/binary/kernel '*.gz'
2891.161Shubertf
2901.161Shubertf# Standalone target to create a CDROM image after the release
2911.161Shubertf# was composed. Should be run after "make build" in both src and xsrc
2921.204Slukemiso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_post
2931.233Slukem#	empty target
2941.161Shubertf
2951.204Slukemiso-image_mi: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_pre
2961.161Shubertf	@if ${MKISOFS} --version; then \
2971.161Shubertf		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
2981.161Shubertf		${MKISOFS} ${MKISOFS_FLAGS} \
2991.230Sperry		    -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
3001.230Sperry		    ${RELEASEDIR} ; \
3011.206Sbjh21		${MAKESUMS} -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
3021.161Shubertf	else \
3031.161Shubertf		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
3041.161Shubertf	fi
3051.161Shubertf
3061.161Shubertf# Setup the $RELEASEDIR to produce a bootable CD image:
3071.204Slukemiso-image_md_pre: check_DESTDIR check_RELEASEDIR
3081.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
3091.161Shubertf
3101.161Shubertf# Fixup the  CD-image to be bootable
3111.204Slukemiso-image_md_post: check_DESTDIR check_RELEASEDIR .WAIT iso-image_mi
3121.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
3131.41Scgd
3141.204Slukemsnap_pre: check_DESTDIR check_RELEASEDIR
3151.168Sjmc# Could be a mount point, ignore the errors
3161.167Sjmc	-/bin/rm -rf ${RELEASEDIR}
3171.202Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}
3181.117Ssimonb.for dir in ${INSTALLATION_DIRS}
3191.202Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}/${dir}
3201.117Ssimonb.endfor
3211.96Scjs
3221.233Slukemsnap_post: check_DESTDIR check_RELEASEDIR
3231.233Slukem.ifndef UPDATE
3241.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
3251.233Slukem.endif
3261.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
3271.233Slukem	    ${MAKE} release
3281.233Slukem
3291.232Slukem# snap_kern --
3301.232Slukem# This target builds the kernels specified by each port.
3311.232Slukem# A port may specify the following kernels:
3321.196Sthorpej#
3331.196Sthorpej#	KERNEL_SETS		The list of kernels that will be
3341.196Sthorpej#				packaged into sets, named
3351.196Sthorpej#				kern-${kernel}.tgz.  These kernels
3361.203Schs#				are also placed in the binary/kernel
3371.196Sthorpej#				area of the release package as
3381.196Sthorpej#				netbsd-${kernel}.gz.
3391.196Sthorpej#
3401.196Sthorpej#	EXTRA_KERNELS		Additional kernels to place in the
3411.203Schs#				binary/kernel area of the release
3421.196Sthorpej#				package as netbsd-${kernel}.gz, but
3431.196Sthorpej#				which are not placed into sets. This
3441.196Sthorpej#				allows a port to provide e.g. a netbootable
3451.196Sthorpej#				installation kernel containing a ramdisk.
3461.196Sthorpej#
3471.196Sthorpej#	BUILD_KERNELS		Additional kernels to build which are
3481.196Sthorpej#				not placed into sets nor into the
3491.203Schs#				binary/kernel area of the release
3501.196Sthorpej#				package.  These are typically kernels
3511.196Sthorpej#				that are built for inclusion only in
3521.196Sthorpej#				installation disk/CD-ROM/tape images.
3531.116Sfair#
3541.197Sthorpej# A port may also specify KERNEL_SUFFIXES, which is an optional list
3551.197Sthorpej# of filename suffixes for kernels to include in the kernel sets and
3561.203Schs# in the binary/kernel area of the release package (e.g. "netbsd" vs.
3571.197Sthorpej# "netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
3581.197Sthorpej# with these suffixes do not exist in the kernel build directory.
3591.197Sthorpej#
3601.229Slukem#
3611.229Slukem# A list of all the kernels to build, which can be overridden from
3621.229Slukem# external sources (such as make(1)'s environment or command line)
3631.229Slukem#
3641.229SlukemALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
3651.229Slukem#
3661.116SfairGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
3671.116Sfair		END{ if (found == 0) print "netbsd"; }'
3681.96Scjs#
3691.232Slukem.if !target(snap_kern)						# {
3701.232Slukem
3711.232Slukem# build_kernels --
3721.232Slukem#	Configure & compile kernels listed in ${ALL_KERNELS}
3731.232Slukem#
3741.201Slukem.if !defined(KERNELS_DONE)						# {
3751.232Slukem.for configfile in ${ALL_KERNELS}					# {
3761.232Slukem_KERNELS_TO_BUILD+=kern-${configfile}
3771.232Slukemkern-${configfile}:
3781.232Slukem	cd ${KERNCONFDIR} && ${CONFIG} -s ${KERNSRCDIR} \
3791.232Slukem	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
3801.201Slukem.if !defined(UPDATE)
3811.200Slukem	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
3821.96Scjs.endif
3831.218Ssommerfe	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
3841.232Slukem.endfor	# ALL_KERNELS							# }
3851.232Slukem.endif	# KERNELS_DONE							# }
3861.232Slukem
3871.232Slukembuild_kernels: ${_KERNELS_TO_BUILD}
3881.232Slukem
3891.232Slukem# build_kernelsets --
3901.232Slukem#	Create kernel sets from ${KERNEL_SETS} into ${RELEASEDIR}/binary/sets
3911.232Slukem#
3921.232Slukem.for configfile in ${KERNEL_SETS}					# {
3931.232Slukem_KERNELSETS_TO_BUILD+=kernset-${configfile}
3941.232Slukemkernset-${configfile}:
3951.197Sthorpej	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
3961.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
3971.207Sbjh21	kernsuffixes="${KERNEL_SUFFIXES}"; \
3981.210Slukem	cd $${kerndir} && ( \
3991.214Slukem		echo "/set uname=${BINOWN} gname=${BINGRP}"; \
4001.214Slukem		echo ". type=dir optional"; \
4011.210Slukem		for kernel in $${kernlist}; do \
4021.214Slukem			echo "./$${kernel} type=file"; \
4031.207Sbjh21			for s in $${kernsuffixes}; do \
4041.197Sthorpej				if [ -f $${kernel}.$${s} ]; then \
4051.214Slukem					echo "./$${kernel}.$${s} type=file"; \
4061.197Sthorpej				fi; \
4071.197Sthorpej			done; \
4081.238Slukem		done ) | GZIP=-9 ${PAX} -O -zw \
4091.235Slukem		    -M -N ${NETBSDSRCDIR}/etc \
4101.210Slukem		    -f ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz
4111.232Slukem.endfor	# KERNEL_SETS							# }
4121.232Slukem
4131.232Slukembuild_kernelsets: ${_KERNELSETS_TO_BUILD}
4141.232Slukem
4151.232Slukem# build_releasekernels --
4161.232Slukem#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
4171.232Slukem#	${RELEASEDIR}/binary/kernel
4181.232Slukem#
4191.232Slukem.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
4201.232Slukem_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
4211.232Slukemreleasekern-${configfile}:
4221.197Sthorpej	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
4231.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
4241.207Sbjh21	kernsuffixes="${KERNEL_SUFFIXES}"; \
4251.197Sthorpej	cd $${kerndir} &&	\
4261.197Sthorpej		gziplist=`for kernel in $${kernlist}; do \
4271.197Sthorpej			echo "$${kernel}"; \
4281.207Sbjh21			for s in $${kernsuffixes}; do \
4291.197Sthorpej				if [ -f $${kernel}.$${s} ]; then \
4301.197Sthorpej					echo "$${kernel}.$${s}"; \
4311.197Sthorpej				fi; \
4321.197Sthorpej			done; \
4331.197Sthorpej		done`; \
4341.197Sthorpej		for kernel in $${gziplist} ; do \
4351.114Sfair		gzip -c -9 < $${kernel} > \
4361.201Slukem		    ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
4371.232Slukem.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
4381.232Slukem
4391.232Slukembuild_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
4401.232Slukem
4411.232Slukem# snap_kern --
4421.232Slukem#	build the kernels, then the sets & release kernels
4431.232Slukemsnap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
4441.232Slukem	    build_kernels .WAIT \
4451.232Slukem	    build_kernelsets build_releasekernels
4461.232Slukem
4471.232Slukem.endif # !target(snap_kern)					# }
4481.232Slukem
4491.108Sdrochner
4501.204Slukemsnap_md_post: check_DESTDIR check_RELEASEDIR
4511.233Slukem#	nothing here -- look in the machine-dependent Makefile.inc
4521.7Scgd
4531.1Scgd.include <bsd.prog.mk>
454