Makefile.bootcd revision 1.14
11.14Smatt#	$NetBSD: Makefile.bootcd,v 1.14 2008/06/23 02:16:53 matt Exp $
21.1Shubertf#
31.1Shubertf# Makefile snipped to create a CD/DVD ISO
41.1Shubertf#
51.1Shubertf
61.1Shubertf# XXX TODO:
71.1Shubertf# 1) merge with src/distrib/cdrom
81.1Shubertf# 2) teach makefs to add data from more than 1 directory (see below)
91.1Shubertf
101.1Shubertf#
111.1Shubertf# Required variables:
121.1Shubertf#	CDBASE		Basename of the iso
131.1Shubertf#
141.1Shubertf# Optional variables:
151.1Shubertf#	CDRELEASE	Set to 'true' to include $RELEASEDIR/$MACHINE on the CD
161.7Shubertf#	CDRELEASE_NOISOS Excludes installation/cdrom directory if set
171.9Schristos#	CDSOURCE	Set to 'true' to include $RELEASEDIR/source on the CD
181.13Ssborrill#	CDEXTRA		Set to a list of files or directories containing extra
191.13Ssborrill#			stuff to put on CD (set by build.sh -C flag)
201.13Ssborrill#	CDBUILDEXTRA	Set to a list of files or directories containing extra
211.13Ssborrill#			stuff to put on CD (use in Makefiles)
221.13Ssborrill#	CDEXTRA_SKIP	A list of file exclusion paths to exclude when copying
231.13Ssborrill#			directories of extra stuff in CDEXTRA AND CDBUILDEXTRA
241.1Shubertf#	BOOT		Defaults to $DESTDIR/usr/mdec/boot
251.1Shubertf#	BOOTXX_CD9660	Defaults to $DESTDIR/usr/mdec/bootxx_cd9660
261.1Shubertf#	CDBOOTOPTIONS	Options for installboot, eg -o console=com0,speed=9600
271.8Sbouyer#	CDMAKEFSOPTIONS	Options for makefs, eg bootimage=i386;bootxx,no-emul-boot
281.1Shubertf#	CDROMS_RELEASEDIR Where to install ${CDBASE}.iso
291.8Sbouyer#	CDINSTKERNEL	instkernel directory (relative to ${.CURDIR})
301.8Sbouyer#	CDKERNELS	couples of the form:
311.8Sbouyer#				source	name_on_cd
321.12Ssborrill# source kernels are copied from ${CDINSTKERNEL} (or its obj dir)
331.12Ssborrill# note that as of yet, bootxx_cd9660 can't load kernel names of more than
341.12Ssborrill# 8 chars (though they can be in a sub-directory meaning the pathname is
351.12Ssborrill# longer than 8 chars)
361.1Shubertf#
371.1Shubertf
381.1ShubertfBOOT?=		${DESTDIR}/usr/mdec/boot
391.1ShubertfBOOTXX_CD9660?=	${DESTDIR}/usr/mdec/bootxx_cd9660
401.1ShubertfCDRELEASE?=	false
411.9SchristosCDSOURCE?=	false
421.8Sbouyer.if ${CDRELEASE} == false
431.8SbouyerCDROMS_RELEASEDIR?=	${MACHINE}/installation/cdrom
441.8Sbouyer.else
451.8SbouyerCDROMS_RELEASEDIR?=	iso
461.8Sbouyer.endif
471.7Shubertf.if defined(CDRELEASE_NOISOS)
481.7ShubertfCDRELEASE_EXCLUDE=	-s ',./installation/cdrom.*,,gp'
491.7Shubertf.endif
501.1Shubertf
511.8Sbouyer.include <bsd.sys.mk>		# for HOST_SH
521.8Sbouyer.include <bsd.own.mk> 		# For PRINTOBJDIR
531.8Sbouyer.include <bsd.kernobj.mk>	# For KERNSRCDIR
541.8Sbouyer
551.8SbouyerDISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
561.8SbouyerISO_VOLID!=	echo NETBSD_${DISTRIBREV} | tr a-z A-Z
571.8SbouyerPUBLISHER?= The_NetBSD_Project
581.8Sbouyer.if defined(CDMAKEFSOPTIONS)
591.8Sbouyer_CDMAKEFSOPTIONS=	rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS}
601.8Sbouyer.else
611.8Sbouyer_CDMAKEFSOPTIONS=	rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
621.8Sbouyer.endif
631.8Sbouyer
641.1Shubertf# Stuff that should come from elsewhere - XXX where? - HF
651.1ShubertfCP?=		cp
661.1ShubertfRM?=		rm
671.1ShubertfMKDIR?=		mkdir -p
681.1ShubertfCHMOD?=		chmod
691.1Shubertf
701.1Shubertf
711.1ShubertfCLEANFILES+=	${CDBASE}.iso
721.8SbouyerCLEANFILES+=	bootxx.${MACHINE}
731.1Shubertf
741.1Shubertf
751.1Shubertf.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
761.1Shubertf
771.8Sbouyer.if defined(CDINSTKERNEL)
781.8Sbouyer_INSTKERNELNOBJDIR!=	cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
791.8Sbouyer.endif
801.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
811.8Sbouyer.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
821.8SbouyerBOOT2=boot.${MACHINE}
831.8Sbouyer.else
841.8SbouyerBOOT2=boot
851.8Sbouyer.endif
861.8Sbouyer.endif
871.1Shubertf
881.1Shubertfprepare:
891.1Shubertf	${MKDIR} cdrom
901.8Sbouyer.if defined(CDKERNELS)
911.8Sbouyer.for kernel target in ${CDKERNELS}
921.8Sbouyer	${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
931.8Sbouyer.endfor
941.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
951.8Sbouyer	${RM} -f cdrom/${BOOT2}
961.8Sbouyer	${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
971.8Sbouyer	${RM} -f bootxx.${MACHINE}
981.8Sbouyer	${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
991.8Sbouyer	${CHMOD} +w bootxx.${MACHINE}
1001.8Sbouyer.if defined(CDBOOTOPTIONS)
1011.8Sbouyer	${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
1021.8Sbouyer.endif
1031.8Sbouyer.endif
1041.8Sbouyer.endif
1051.1Shubertf
1061.1Shubertf# Copy $RELEASEDIR/${MACHINE} in the CDROM dir
1071.1Shubertf#
1081.1Shubertf# XXX This could be done a lot easier if makefs(8) could
1091.1Shubertf# XXX include more than one directory on the image - HF
1101.1Shubertf#
1111.1Shubertfcopy-releasedir:
1121.8Sbouyer	${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso
1131.9Schristos	if ${CDRELEASE}; then 						\
1141.14Smatt		if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then 		\
1151.14Smatt			echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
1161.9Schristos			exit 1; 					\
1171.9Schristos		fi; 							\
1181.9Schristos		${MKDIR} cdrom/${MACHINE}; 				\
1191.10Sjnemeth		curdir=$$(pwd);						\
1201.9Schristos		release_destdir=$$(pwd)/cdrom/${MACHINE}; 		\
1211.14Smatt		cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; 				\
1221.9Schristos		echo Copying $$(pwd) to $$release_destdir ...; 		\
1231.7Shubertf		${TOOL_PAX} 						\
1241.7Shubertf			-rw -pe -v 					\
1251.7Shubertf			${CDRELEASE_EXCLUDE}				\
1261.9Schristos			. $$release_destdir; 				\
1271.10Sjnemeth		cd $$curdir;						\
1281.9Schristos	fi
1291.9Schristos	if ${CDSOURCE}; then 						\
1301.9Schristos		if [ ! -d ${RELEASEDIR}/source ]; then	 		\
1311.9Schristos			echo "Missing ${RELEASEDIR}/source, aborting"; 	\
1321.9Schristos			exit 1; 					\
1331.9Schristos		fi; 							\
1341.9Schristos		${MKDIR} cdrom/source; 					\
1351.10Sjnemeth		curdir=$$(pwd);						\
1361.9Schristos		release_destdir=$$(pwd)/cdrom/source;	 		\
1371.9Schristos		cd ${RELEASEDIR}/source; 				\
1381.9Schristos		echo Copying $$(pwd) to $$release_destdir ...;		\
1391.9Schristos		${TOOL_PAX} 						\
1401.9Schristos			-rw -pe -v 					\
1411.9Schristos			. $$release_destdir; 				\
1421.10Sjnemeth		cd $$curdir;						\
1431.1Shubertf	fi
1441.13Ssborrill	if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then		\
1451.11Sjnemeth		curdir=$$(pwd);						\
1461.13Ssborrill		skipflag="";						\
1471.13Ssborrill		if [ "X${CDEXTRA_SKIP}" != "X" ]; then			\
1481.13Ssborrill			rm -f cdskip;					\
1491.13Ssborrill			for skip in ${CDEXTRA_SKIP};			\
1501.13Ssborrill			do						\
1511.13Ssborrill				echo $${skip} >> cdskip;		\
1521.13Ssborrill			done;						\
1531.13Ssborrill			skipflag="-X $${curdir}/cdskip";		\
1541.13Ssborrill		fi;							\
1551.13Ssborrill		for cde in ${CDEXTRA} ${CDBUILDEXTRA};			\
1561.13Ssborrill		do							\
1571.13Ssborrill			release_destdir=$${curdir}/cdrom;		\
1581.13Ssborrill			if [ -f $${cde} ]; then				\
1591.13Ssborrill				echo Copying $${cde} to $$release_destdir ...;	\
1601.13Ssborrill				${CP} $${cde} $${release_destdir};	\
1611.13Ssborrill			elif [ -d $${cde} ]; then			\
1621.13Ssborrill				cd $${cde};				\
1631.13Ssborrill				echo Copying $$(pwd) to $$release_destdir ...;	\
1641.13Ssborrill				${TOOL_MTREE} -c $${skipflag} |		\
1651.13Ssborrill					${TOOL_PAX} -rw -pe -v -M	\
1661.13Ssborrill					$$release_destdir; 		\
1671.13Ssborrill			else						\
1681.13Ssborrill				echo "Missing $${cde}, aborting"; 	\
1691.13Ssborrill				exit 1; 				\
1701.13Ssborrill			fi; 						\
1711.13Ssborrill			cd $$curdir;					\
1721.13Ssborrill		done;							\
1731.11Sjnemeth	fi
1741.1Shubertf
1751.1Shubertfimage:
1761.8Sbouyer	${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom
1771.8Sbouyer
1781.8Sbouyer.if ${CDRELEASE} == false
1791.8Sbouyerrelease: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image .WAIT image_md_post
1801.8Sbouyer	${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1811.8Sbouyer	${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1821.1Shubertf
1831.8Sbouyeriso_image:
1841.8Sbouyer.else
1851.1Shubertfrelease:
1861.8Sbouyer
1871.8Sbouyeriso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image .WAIT image_md_post
1881.8Sbouyer	${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1891.8Sbouyer	${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1901.8Sbouyer.endif
1911.1Shubertf
1921.1Shubertfclean:
1931.1Shubertf	${RM} -fr cdrom
1941.1Shubertf
1951.8Sbouyerprepare_md_post: .PHONY
1961.8Sbouyerimage_md_post: .PHONY
1971.8Sbouyer
1981.8Sbouyer
1991.1Shubertf.include <bsd.prog.mk>
200