Makefile revision 1.300
11.300Slukem#	$NetBSD: Makefile,v 1.300 2005/01/10 01:17:25 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.270Slukem#   MKCRYPTO; if not `no', install crypto-related configuration
191.270Slukem#   MKSENDMAIL; if not `no', install sendmail configuration
201.270Slukem#   MKUNPRIVED; if not `no', allow non-root installs.
211.255Slukem#   MKUPDATE; if not `no', don't do a 'make clean' before kernel compile
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.286Scl#	into a release(7) format in RELEASEDIR/${RELEASEMACHINEDIR}.
311.241Slukem#	Any port-dependent stuff for this target is found in
321.241Slukem#	etc.${MACHINE}/Makefile.inc.
331.106Scjs#    release: a synonym for `snapshot'
341.242Slukem#
351.199Stv
361.270Slukem# For MK* vars
371.90Skim.include <bsd.own.mk>
381.187Sjmc
391.260Slukem.include <bsd.sys.mk>		# for HOST_SH
401.260Slukem.include <bsd.kernobj.mk>	# For KERNSRCDIR, KERNOBJDIR, ...
411.260Slukem.include <bsd.endian.mk>	# For TARGET_ENDIANNESS
421.252Slukem
431.211Slukem
441.187Sjmc.MAKEOVERRIDES+=	USETOOLS
451.90Skim
461.23ScgdTZDIR=		/usr/share/zoneinfo
471.157SkleinkLOCALTIME?=	UTC
481.283SagcCKSUM?=		${TOOL_CKSUM}
491.283SagcMAKESUMS=	CKSUM=${CKSUM:Q} ${HOST_SH} ${NETBSDSRCDIR}/distrib/sets/makesums
501.266SlukemDISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
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.242Slukem# Note: At least mkisofs 2.0 should be used.
551.242Slukem#
561.161ShubertfMKISOFS?=	mkisofs
571.260SlukemDISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
581.224Sbjh21# ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
591.224Sbjh21ISO_VOLID!=	echo NETBSD_${MACHINE}_${DISTRIBREV} | tr a-z A-Z
601.161ShubertfMKISOFS_FLAGS+= -J -l \
611.161Shubertf		-r -T -v \
621.224Sbjh21		-V ${ISO_VOLID} \
631.161Shubertf		-P "The NetBSD Project" \
641.286Scl		-m "${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom"
651.1Scgd
661.80Sjonathan# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
671.80Sjonathan# are empty, to preserve the old semantics of setting them below with "=".
681.242Slukem#
691.200SlukemBIN1=
701.80SjonathanBIN2=
711.80SjonathanBIN3=
721.80Sjonathan
731.286Scl# Directories to build in ${RELEASEDIR}/${RELEASEMACHINEDIR}.
741.241Slukem# MD Makefile.inc files can add to this.
751.117Ssimonb# NOTE: Parent directories must be listed before subdirectories.
761.242Slukem#
771.217SlukemINSTALLATION_DIRS=	binary binary/sets binary/kernel installation
781.117Ssimonb
791.286Scl.if exists(etc.${RELEASEMACHINE}/Makefile.inc)
801.286Scl.include "etc.${RELEASEMACHINE}/Makefile.inc"
811.71Scjs.endif
821.32Sjtc
831.21Scgd# -rw-r--r--
841.21ScgdBINOWN= root
851.21ScgdBINGRP= wheel
861.227SperryUTMPGRP= utmp
871.184SlukemBIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
881.223Sfredette	daily.conf dm.conf floppytab ftpchroot ftpusers \
891.280Sitohy	gettytab group hosts hosts.lpd inetd.conf lkm.conf locate.conf \
901.131Sveego	mailer.conf man.conf monthly monthly.conf mrouted.conf \
911.151Sfvdl	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
921.291Slukem	passwd.conf phones printcap profile protocols \
931.291Slukem	rbootd.conf rc rc.conf rc.lkm rc.local rc.subr rc.shutdown remote rpc \
941.142Stsarna	security security.conf services shells sysctl.conf syslog.conf \
951.291Slukem	weekly weekly.conf wscons.conf
961.291Slukem
971.242Slukem# Use machine-specific disktab if it exists, or the MI one otherwise
981.236Sjdolecek.if exists(etc.${MACHINE}/disktab)
991.236SjdolecekBIN1+=	etc.${MACHINE}/disktab
1001.236Sjdolecek.else
1011.236SjdolecekBIN1+=	disktab
1021.236Sjdolecek.endif
1031.105Smycroft
1041.234Sjdolecek.if exists(etc.${MACHINE}/ld.so.conf)
1051.234SjdolecekBIN1+=	etc.${MACHINE}/ld.so.conf
1061.152Sperry.endif
1071.152Sperry
1081.234Sjdolecek.if exists(etc.${MACHINE}/ttyaction)
1091.234SjdolecekBIN1+=	etc.${MACHINE}/ttyaction
1101.105Smycroft.endif
1111.1Scgd
1121.46Sderaadt# -rw-rw-r--
1131.80SjonathanBIN2+=	motd
1141.1Scgd
1151.77Smycroft# -rw-------
1161.80SjonathanBIN3+=	hosts.equiv
1171.77Smycroft
1181.291SlukemSYSPKG=	etc
1191.230SperryETC_PKG=-T etc_pkg
1201.230SperryBASE_PKG=-T base_pkg
1211.242SlukemETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
1221.261SclETC_INSTALL_OBJ_FILE=cd ${.OBJDIR} && ${INSTALL_FILE} ${ETC_PKG}
1231.230Sperry
1241.191Stv.if ${TARGET_ENDIANNESS} == "1234"
1251.252SlukemPWD_MKDB_ENDIAN=	-L
1261.191Stv.elif ${TARGET_ENDIANNESS} == "4321"
1271.252SlukemPWD_MKDB_ENDIAN=	-B
1281.170Sjdolecek.else
1291.252SlukemPWD_MKDB_ENDIAN=
1301.191Stv.endif
1311.149Ssjg
1321.149Ssjg
1331.242Slukem# distribution --
1341.242Slukem#	Build a distribution
1351.242Slukem#
1361.275Slukemdistribution: .PHONY check_DESTDIR .WAIT distrib-dirs
1371.182Schs.if !defined(DISTRIBUTION_DONE)
1381.87Sperry.if !defined(INSTALL_DONE)
1391.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR} include _DISTRIB=
1401.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR} install _DISTRIB=
1411.200Slukem.endif	# !INSTALL_DONE
1421.285Slukem	${MAKEDIRTARGET} . install-etc-files
1431.288Slukem.if ${MKX11} != "no"
1441.288Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/x11 distribution
1451.288Slukem.endif
1461.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets makesetfiles
1471.200Slukem.endif	# !DISTRIBUTION_DONE
1481.193Sthorpej
1491.266Slukem
1501.295SchristosCLEANFILES+=	MAKEDEV
1511.275SlukemMAKEDEV: .EXEC
1521.263Slukem	${_MKTARGET_CREATE}
1531.264Slukem	MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
1541.264Slukem	    NETBSDSRCDIR=${NETBSDSRCDIR:Q} \
1551.264Slukem	    awk -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl > ${.TARGET}
1561.257Sjdolecek
1571.266SlukemRELEASEVARS=	BSDOBJDIR BSDSRCDIR BUILDID \
1581.266Slukem		DESTDIR EXTERNAL_TOOLCHAIN \
1591.266Slukem		INSTALLWORLDDIR \
1601.266Slukem		KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
1611.266Slukem		MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
1621.266Slukem		MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
1631.273Slukem		MKBFD MKCATPAGES \
1641.273Slukem		MKCRYPTO MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKCVS \
1651.273Slukem		MKDOC MKDYNAMICROOT MKGCC MKGCCCMDS MKGDB \
1661.273Slukem		MKHESIOD MKHOSTOBJ MKHTML MKIEEEFP MKINFO \
1671.273Slukem		MKKERBEROS4 MKKERBEROS MKLINKLIB MKLINT \
1681.273Slukem		MKMAN MKMANZ MKNLS MKOBJ MKOBJDIRS \
1691.299Slukem		MKPAM MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
1701.273Slukem		MKSENDMAIL MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \
1711.273Slukem		MKUNPRIVED MKUPDATE MKUUCP MKX11 MKYP \
1721.276Slukem		NBUILDJOBS NETBSDSRCDIR \
1731.266Slukem		NOCLEANDIR NODISTRIBDIRS NOINCLUDES \
1741.276Slukem		OBJMACHINE \
1751.276Slukem		RELEASEDIR TOOLCHAIN_MISSING TOOLDIR \
1761.276Slukem		USETOOLS USR_OBJMACHINE \
1771.276Slukem		X11SRCDIR
1781.276Slukem
1791.276Slukemparams: .PHONY
1801.276Slukem.for var in ${RELEASEVARS}
1811.276Slukem.if defined(${var})
1821.276Slukem	@printf "%20s = '%-s'\n" ${var} ${${var}:Q}
1831.276Slukem.else
1841.276Slukem	@printf "%20s = (undefined)\n" ${var}
1851.276Slukem.endif
1861.276Slukem.endfor
1871.266Slukem
1881.272SlukemCLEANFILES+=	etc-release
1891.275Slukemetc-release: .EXEC
1901.266Slukem	${_MKTARGET_CREATE}
1911.266Slukem	@(	echo "NetBSD ${DISTRIBVER}/${MACHINE}"; \
1921.266Slukem		echo ; \
1931.269Slukem		cat ${NETBSDSRCDIR}/sys/conf/copyright; \
1941.266Slukem		echo ; \
1951.266Slukem		echo "Build settings:"; \
1961.281Slukem		printf "%20s   %s\n"  "Build date" "$$(date -u)"; \
1971.281Slukem		printf "%20s   %s\n"  "Built by" "$${USER-root}@$$(hostname)"; \
1981.281Slukem		echo ; \
1991.282Senami		(cd ${.CURDIR}; ${MAKE} ${MFLAGS} -j1 params); \
2001.276Slukem	) >${.OBJDIR}/${.TARGET}
2011.266Slukem
2021.275Slukeminstall-etc-release: .PHONY etc-release
2031.272Slukem	${_MKMSG_INSTALL} etc/release
2041.266Slukem	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 444 \
2051.272Slukem	    etc-release ${DESTDIR}/etc/release
2061.242Slukem
2071.291Slukem
2081.291SlukemFILESDIR=		/etc
2091.291SlukemCONFIGFILES=
2101.291SlukemCONFIGSYMLINKS=
2111.291Slukem
2121.291Slukem.for file in ${BIN1}
2131.291SlukemCONFIGFILES+=		${file}
2141.291SlukemFILESMODE_${file:T}=	644
2151.291Slukem.endfor
2161.291Slukem
2171.291Slukem.for file in ${BIN2}
2181.291SlukemCONFIGFILES+=		${file}
2191.291SlukemFILESMODE_${file:T}=	664
2201.291Slukem.endfor
2211.291Slukem
2221.291Slukem.for file in ${BIN3}
2231.291SlukemCONFIGFILES+=		${file}
2241.291SlukemFILESMODE_${file:T}=	600
2251.291Slukem.endfor
2261.291Slukem
2271.291SlukemCONFIGFILES+=		postinstall
2281.291SlukemFILESMODE_postinstall=	${BINMODE}
2291.291Slukem
2301.291SlukemCONFIGFILES+=		aliases
2311.291SlukemFILESDIR_aliases=	/etc/mail
2321.291SlukemFILESMODE_aliases=	644
2331.291Slukem
2341.291SlukemCONFIGFILES+=		MAKEDEV.local
2351.291SlukemFILESDIR_MAKEDEV.local=	/dev
2361.291SlukemFILESMODE_MAKEDEV.local=${BINMODE}
2371.291Slukem
2381.291SlukemCONFIGFILES+=		crontab
2391.291SlukemFILESDIR_crontab=	/var/cron/tabs
2401.291SlukemFILESNAME_crontab=	root
2411.291SlukemFILESMODE_crontab=	600
2421.291Slukem
2431.291SlukemCONFIGFILES+=		minfree
2441.291SlukemFILESDIR_minfree=	/var/crash
2451.291SlukemFILESMODE_minfree=	600
2461.291Slukem
2471.291SlukemCONFIGSYMLINKS+=	${TZDIR}/${LOCALTIME}	/etc/localtime \
2481.291Slukem			/usr/sbin/rmt		/etc/rmt
2491.291Slukem
2501.291Slukem
2511.242Slukem# install-etc-files --
2521.242Slukem#	Install etc (config) files; not performed by "make build"
2531.242Slukem#
2541.297Schristosinstall-etc-files: .PHONY check_DESTDIR MAKEDEV
2551.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/etc/master.passwd
2561.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2571.230Sperry	    master.passwd ${DESTDIR}/etc
2581.254Slukem	${TOOL_PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
2591.230Sperry	    ${DESTDIR}/etc/master.passwd
2601.255Slukem.if ${MKUNPRIVED} != "no"
2611.222Slukem	( \
2621.246Slukem		for metaent in passwd pwd.db spwd.db; do \
2631.246Slukem	    		echo "./etc/$${metaent} type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
2641.246Slukem		done; \
2651.239Slukem	) | ${METALOG.add}
2661.255Slukem.endif	# MKUNPRIVED != no
2671.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/etc/ttys
2681.289Schristos	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2691.298Schristos	    ${.CURDIR}/etc.${MACHINE}/ttys ${DESTDIR}/etc
2701.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/dev/MAKEDEV
2711.259Sross	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
2721.257Sjdolecek	    MAKEDEV ${DESTDIR}/dev
2731.291Slukem.for owner group mode file in \
2741.291Slukem		${BINOWN} operator	664	/etc/dumpdates  \
2751.291Slukem		${BINOWN} ${BINGRP}	644	/etc/mail/local-host-names \
2761.291Slukem		${BINOWN} operator	600	/etc/skeykeys \
2771.291Slukem		root wheel		600	/var/at/at.deny \
2781.291Slukem		nobody ${BINGRP}	664	/var/db/locate.database \
2791.291Slukem		uucp dialer		640	/var/log/aculog \
2801.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/authlog \
2811.291Slukem		root wheel		600	/var/log/cron \
2821.291Slukem		${BINOWN} ${BINGRP}	664	/var/log/lastlog \
2831.291Slukem		${BINOWN} ${BINGRP}	640	/var/log/lpd-errs \
2841.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/maillog \
2851.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/messages \
2861.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/secure \
2871.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/sendmail.st \
2881.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/wtmp \
2891.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/wtmpx \
2901.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/xferlog \
2911.291Slukem		daemon staff		664	/var/msgs/bounds \
2921.291Slukem		${BINOWN} ${UTMPGRP}	664	/var/run/utmp \
2931.291Slukem		${BINOWN} ${UTMPGRP}	664	/var/run/utmpx \
2941.291Slukem		games games		664	/var/games/atc_score \
2951.291Slukem		games games		664	/var/games/battlestar.log \
2961.291Slukem		games games		664	/var/games/cfscores \
2971.291Slukem		games games		664	/var/games/criblog \
2981.291Slukem		games games		660	/var/games/hackdir/perm \
2991.291Slukem		games games		660	/var/games/hackdir/record \
3001.291Slukem		games games		664	/var/games/larn/llog12.0 \
3011.291Slukem		games games		664	/var/games/larn/lscore12.0 \
3021.291Slukem		games games		664	/var/games/larn/playerids \
3031.291Slukem		games games		664	/var/games/robots_roll \
3041.291Slukem		games games		664	/var/games/rogue.scores \
3051.291Slukem		games games		664	/var/games/saillog \
3061.291Slukem		games games		664	/var/games/snakerawscores \
3071.291Slukem		games games		664	/var/games/snake.log \
3081.291Slukem		games games		664	/var/games/tetris.scores
3091.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}${file}
3101.291Slukem	${ETC_INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} \
3111.291Slukem	    	/dev/null ${DESTDIR}${file}
3121.291Slukem.endfor
3131.300Slukem.for subdir in . defaults mtree namedb pam.d powerd rc.d root skel ssh
3141.291Slukem	${MAKEDIRTARGET} ${subdir} configinstall
3151.291Slukem.endfor
3161.287Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/mail configinstall
3171.294Syamt	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.sbin/pf configinstall
3181.287Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/postfix configinstall
3191.155Sthorpej.if (${MKCRYPTO} != "no")
3201.287Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/ssh configinstall
3211.155Sthorpej.endif
3221.270Slukem.if (${MKSENDMAIL} != "no")
3231.287Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf configinstall
3241.90Skim.endif
3251.247Slukem
3261.247Slukem
3271.247Slukem# install-obsolete-lists --
3281.247Slukem#	Install var/db/obsolete set lists; this is performed by "make build"
3291.247Slukem#
3301.247SlukemOBSOLETE.dir=		${.OBJDIR}/obsolete.dir
3311.247SlukemOBSOLETE.files=		base comp etc games man misc text
3321.247Slukem
3331.275Slukeminstall-obsolete-lists: .PHONY
3341.246Slukem	mkdir -p ${OBSOLETE.dir}
3351.253Slukem	(cd ${NETBSDSRCDIR}/distrib/sets && \
3361.253Slukem	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
3371.246Slukem.for file in ${OBSOLETE.files}
3381.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/var/db/obsolete/${file}
3391.246Slukem	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
3401.247Slukem	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
3411.246Slukem.endfor
3421.1Scgd
3431.242Slukem
3441.242Slukem# distrib-dirs --
3451.242Slukem#	Populate $DESTDIR with directories needed by NetBSD
3461.242Slukem#
3471.255Slukem.if ${MKUNPRIVED} == "no"
3481.255SlukemTOOL_MTREE.unpriv=
3491.255Slukem.else
3501.255SlukemTOOL_MTREE.unpriv=	-W
3511.255Slukem.endif
3521.255Slukem
3531.275Slukemdistrib-dirs: .PHONY check_DESTDIR
3541.256Sdsl.if !defined(DISTRIBUTION_DONE)
3551.230Sperry	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
3561.256Sdsl.endif
3571.254Slukem	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
3581.255Slukem	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
3591.200Slukem
3601.242Slukem
3611.242Slukem# release, snapshot --
3621.242Slukem#	Build a full distribution including kernels & install media.
3631.242Slukem#
3641.275Slukemrelease snapshot: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
3651.233Slukem		    distribution .WAIT \
3661.233Slukem		    snap_pre .WAIT snap_kern .WAIT \
3671.233Slukem		    snap_post .WAIT snap_md_post
3681.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets sets
3691.286Scl	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel '*.gz'
3701.161Shubertf
3711.242Slukem
3721.242Slukem# iso-image --
3731.242Slukem#	Standalone target to create a CDROM image after the release
3741.242Slukem#	was composed.  Should be run after "make release" in src and xsrc.
3751.242Slukem#
3761.245Slukem#	Note: At least mkisofs 2.0 should be used.
3771.242Slukem#
3781.292SheCDROM_NAME_ADD?=
3791.292SheCDROM.image=${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom/netbsd-${MACHINE}${CDROM_NAME_ADD}.iso
3801.242SlukemCDROM.dir=	cdrom.dir
3811.242SlukemCDROM.pathlist=	cdrom.pathlist
3821.242Slukem
3831.275Slukemiso-image: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-md-post
3841.286Scl	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom '*.iso'
3851.265Slukem	@echo "iso-image created as: ${CDROM.image}"
3861.161Shubertf
3871.275Slukemiso-image-setup: .PHONY check_RELEASEDIR
3881.242Slukem	rm -f ${CDROM.pathlist}
3891.286Scl	echo "${MACHINE}=${RELEASEDIR}/${RELEASEMACHINEDIR}" >> ${CDROM.pathlist}
3901.242Slukem	mkdir -p ${CDROM.dir}
3911.286Scl	mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom
3921.242Slukem
3931.248Slukem# iso-image-mi --
3941.242Slukem#	Create the image after the MD operations have completed.
3951.248Slukem#
3961.275Slukemiso-image-mi: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
3971.248Slukem		iso-image-setup .WAIT iso-image-md-pre
3981.242Slukem	@if ! ${MKISOFS} --version; then \
3991.242Slukem		echo "install pkgsrc/sysutils/cdrecord and run 'make iso-image'." ; \
4001.242Slukem		false; \
4011.161Shubertf	fi
4021.242Slukem	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
4031.242Slukem	    -o ${CDROM.image} ${CDROM.dir}
4041.242Slukem
4051.248Slukem# iso-image-md-pre --
4061.242Slukem#	Setup ${CDROM.dir} to produce a bootable CD image.
4071.242Slukem#	Overridden by etc.$MACHINE/Makefile.inc
4081.242Slukem#
4091.275Slukemiso-image-md-pre: .PHONY check_DESTDIR check_RELEASEDIR
4101.242Slukem#	(empty -- look in the machine-dependent Makefile.inc)
4111.161Shubertf
4121.248Slukem# iso-image-md-post --
4131.242Slukem#	Fixup the CD-image to be bootable.
4141.242Slukem#	Overridden by etc.$MACHINE/Makefile.inc
4151.242Slukem#
4161.275Slukemiso-image-md-post: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-mi
4171.242Slukem#	(empty -- look in the machine-dependent Makefile.inc)
4181.41Scgd
4191.242Slukem
4201.242Slukem# snap_pre --
4211.242Slukem#	Create ${RELEASEDIR} and necessary subdirectories.
4221.242Slukem#
4231.275Slukemsnap_pre: .PHONY check_DESTDIR check_RELEASEDIR
4241.241Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}
4251.255Slukem.if ${MKUPDATE} == "no"
4261.168Sjmc# Could be a mount point, ignore the errors
4271.286Scl	-/bin/rm -rf ${RELEASEDIR}/${RELEASEMACHINEDIR}
4281.240Slukem.endif
4291.286Scl	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}
4301.117Ssimonb.for dir in ${INSTALLATION_DIRS}
4311.286Scl	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${dir}
4321.117Ssimonb.endfor
4331.96Scjs
4341.242Slukem# snap_post --
4351.242Slukem#	Build the install media and notes from distrib
4361.242Slukem#
4371.275Slukemsnap_post: .PHONY check_DESTDIR check_RELEASEDIR
4381.255Slukem.if ${MKUPDATE} == "no"
4391.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
4401.233Slukem.endif
4411.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
4421.233Slukem	    ${MAKE} release
4431.233Slukem
4441.232Slukem# snap_kern --
4451.242Slukem#	This target builds the kernels specified by each port.
4461.242Slukem#	A port may specify the following kernels:
4471.196Sthorpej#
4481.196Sthorpej#	KERNEL_SETS		The list of kernels that will be
4491.196Sthorpej#				packaged into sets, named
4501.196Sthorpej#				kern-${kernel}.tgz.  These kernels
4511.203Schs#				are also placed in the binary/kernel
4521.196Sthorpej#				area of the release package as
4531.196Sthorpej#				netbsd-${kernel}.gz.
4541.196Sthorpej#
4551.196Sthorpej#	EXTRA_KERNELS		Additional kernels to place in the
4561.203Schs#				binary/kernel area of the release
4571.196Sthorpej#				package as netbsd-${kernel}.gz, but
4581.196Sthorpej#				which are not placed into sets. This
4591.196Sthorpej#				allows a port to provide e.g. a netbootable
4601.196Sthorpej#				installation kernel containing a ramdisk.
4611.196Sthorpej#
4621.196Sthorpej#	BUILD_KERNELS		Additional kernels to build which are
4631.196Sthorpej#				not placed into sets nor into the
4641.203Schs#				binary/kernel area of the release
4651.196Sthorpej#				package.  These are typically kernels
4661.196Sthorpej#				that are built for inclusion only in
4671.196Sthorpej#				installation disk/CD-ROM/tape images.
4681.116Sfair#
4691.242Slukem#	A port may also specify KERNEL_SUFFIXES, which is an optional list
4701.242Slukem#	of filename suffixes for kernels to include in the kernel sets and
4711.242Slukem#	in the binary/kernel area of the release package (e.g. "netbsd" vs.
4721.242Slukem#	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
4731.242Slukem#	with these suffixes do not exist in the kernel build directory.
4741.197Sthorpej#
4751.229Slukem#
4761.229Slukem# A list of all the kernels to build, which can be overridden from
4771.229Slukem# external sources (such as make(1)'s environment or command line)
4781.229Slukem#
4791.229SlukemALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
4801.242Slukem
4811.116SfairGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
4821.116Sfair		END{ if (found == 0) print "netbsd"; }'
4831.242Slukem
4841.232Slukem.if !target(snap_kern)						# {
4851.232Slukem
4861.232Slukem# build_kernels --
4871.232Slukem#	Configure & compile kernels listed in ${ALL_KERNELS}
4881.232Slukem#
4891.284Scgd# The 'sync' is so that all writes during the build are pushed back
4901.284Scgd# to the disk.  Not having it causes problems on some host systems
4911.284Scgd# (e.g. Linux) when building on NFS.
4921.284Scgd#
4931.201Slukem.if !defined(KERNELS_DONE)						# {
4941.232Slukem.for configfile in ${ALL_KERNELS}					# {
4951.232Slukem_KERNELS_TO_BUILD+=kern-${configfile}
4961.275Slukemkern-${configfile}: .PHONY
4971.254Slukem	cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
4981.232Slukem	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
4991.255Slukem.if ${MKUPDATE} == "no"
5001.200Slukem	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
5011.96Scjs.endif
5021.218Ssommerfe	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
5031.284Scgd	sync
5041.232Slukem.endfor	# ALL_KERNELS							# }
5051.232Slukem.endif	# KERNELS_DONE							# }
5061.232Slukem
5071.275Slukembuild_kernels: .PHONY ${_KERNELS_TO_BUILD}
5081.232Slukem
5091.232Slukem# build_kernelsets --
5101.241Slukem#	Create kernel sets from ${KERNEL_SETS} into
5111.286Scl#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
5121.232Slukem#
5131.232Slukem.for configfile in ${KERNEL_SETS}					# {
5141.232Slukem_KERNELSETS_TO_BUILD+=kernset-${configfile}
5151.275Slukemkernset-${configfile}: .PHONY
5161.256Sdsl	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
5171.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
5181.256Sdsl	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
5191.286Scl	kern_tgz=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets/kern-${configfile}.tgz; \
5201.256Sdsl	pax_cmd="GZIP=-9 ${TOOL_PAX} -O -zw -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
5211.256Sdsl	cd $${kerndir} && { \
5221.256Sdsl		kernels=; newest=; \
5231.210Slukem		for kernel in $${kernlist}; do \
5241.256Sdsl			for s in "" $${kernsuffixes}; do \
5251.256Sdsl				ks="$${kernel}$${s}"; \
5261.256Sdsl				[ -f $${ks} ] || continue; \
5271.256Sdsl				kernels="$${kernels} $${ks}"; \
5281.256Sdsl				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
5291.256Sdsl					newest=$${ks}; \
5301.197Sthorpej			done; \
5311.256Sdsl		done; \
5321.256Sdsl		[ $${kern_tgz} -nt "$${newest}" ] || { \
5331.256Sdsl			echo "echo $${kernels} | $${pax_cmd}"; \
5341.256Sdsl			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
5351.256Sdsl			echo ". type=dir optional"; \
5361.256Sdsl			for kernel in $${kernels}; do \
5371.256Sdsl				echo "./$${kernel} type=file"; \
5381.256Sdsl			done ) | eval $${pax_cmd}; \
5391.256Sdsl		} \
5401.256Sdsl	}
5411.232Slukem.endfor	# KERNEL_SETS							# }
5421.232Slukem
5431.232Slukembuild_kernelsets: ${_KERNELSETS_TO_BUILD}
5441.232Slukem
5451.232Slukem# build_releasekernels --
5461.232Slukem#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
5471.286Scl#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel
5481.232Slukem#
5491.232Slukem.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
5501.232Slukem_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
5511.275Slukemreleasekern-${configfile}: .PHONY
5521.256Sdsl	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
5531.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
5541.256Sdsl	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
5551.256Sdsl	cd $${kerndir} && {	\
5561.256Sdsl		for kernel in $${kernlist}; do \
5571.256Sdsl			for s in "" $${kernsuffixes}; do \
5581.256Sdsl				ks="$${kernel}$${s}"; \
5591.256Sdsl				[ ! -f $${ks} ] && continue; \
5601.286Scl				knl_gz="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel/$${ks}-${configfile:C/.*\///}.gz"; \
5611.256Sdsl				[ $${knl_gz} -nt $${ks} ] && continue; \
5621.256Sdsl				echo "gzip -c -9 < $${kerndir}/$${ks} > $${knl_gz}"; \
5631.256Sdsl				gzip -c -9 < $${ks} > $${knl_gz}; \
5641.197Sthorpej			done; \
5651.256Sdsl		done; \
5661.256Sdsl	}
5671.232Slukem.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
5681.232Slukem
5691.232Slukembuild_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
5701.232Slukem
5711.232Slukem# snap_kern --
5721.232Slukem#	build the kernels, then the sets & release kernels
5731.242Slukem#
5741.232Slukemsnap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
5751.232Slukem	    build_kernels .WAIT \
5761.232Slukem	    build_kernelsets build_releasekernels
5771.232Slukem
5781.232Slukem.endif # !target(snap_kern)					# }
5791.232Slukem
5801.108Sdrochner
5811.242Slukem# snap_md_post --
5821.242Slukem#	Machine dependent distribution media operations.
5831.242Slukem#	Overridden by etc.$MACHINE/Makefile.inc
5841.242Slukem#
5851.204Slukemsnap_md_post: check_DESTDIR check_RELEASEDIR
5861.242Slukem#	(empty -- look in the machine-dependent Makefile.inc)
5871.242Slukem
5881.242Slukem
5891.242Slukemclean:
5901.246Slukem	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
5911.7Scgd
5921.1Scgd.include <bsd.prog.mk>
593