Makefile.bootcd revision 1.17
11.17Schristos#	$NetBSD: Makefile.bootcd,v 1.17 2009/09/25 14:09:27 christos 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.15Sad#	CDRUNTIME	files/directories to copy from $DESTDIR onto the CD
331.12Ssborrill# source kernels are copied from ${CDINSTKERNEL} (or its obj dir)
341.12Ssborrill# note that as of yet, bootxx_cd9660 can't load kernel names of more than
351.12Ssborrill# 8 chars (though they can be in a sub-directory meaning the pathname is
361.12Ssborrill# longer than 8 chars)
371.1Shubertf#
381.1Shubertf
391.1ShubertfBOOT?=		${DESTDIR}/usr/mdec/boot
401.1ShubertfBOOTXX_CD9660?=	${DESTDIR}/usr/mdec/bootxx_cd9660
411.1ShubertfCDRELEASE?=	false
421.9SchristosCDSOURCE?=	false
431.8Sbouyer.if ${CDRELEASE} == false
441.8SbouyerCDROMS_RELEASEDIR?=	${MACHINE}/installation/cdrom
451.8Sbouyer.else
461.8SbouyerCDROMS_RELEASEDIR?=	iso
471.8Sbouyer.endif
481.7Shubertf.if defined(CDRELEASE_NOISOS)
491.7ShubertfCDRELEASE_EXCLUDE=	-s ',./installation/cdrom.*,,gp'
501.7Shubertf.endif
511.1Shubertf
521.8Sbouyer.include <bsd.sys.mk>		# for HOST_SH
531.8Sbouyer.include <bsd.own.mk> 		# For PRINTOBJDIR
541.8Sbouyer.include <bsd.kernobj.mk>	# For KERNSRCDIR
551.8Sbouyer
561.8SbouyerDISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
571.8SbouyerISO_VOLID!=	echo NETBSD_${DISTRIBREV} | tr a-z A-Z
581.8SbouyerPUBLISHER?= The_NetBSD_Project
591.8Sbouyer.if defined(CDMAKEFSOPTIONS)
601.8Sbouyer_CDMAKEFSOPTIONS=	rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS}
611.8Sbouyer.else
621.8Sbouyer_CDMAKEFSOPTIONS=	rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
631.8Sbouyer.endif
641.8Sbouyer
651.1Shubertf# Stuff that should come from elsewhere - XXX where? - HF
661.1ShubertfCP?=		cp
671.1ShubertfRM?=		rm
681.1ShubertfMKDIR?=		mkdir -p
691.1ShubertfCHMOD?=		chmod
701.17SchristosECHO?=		echo
711.1Shubertf
721.1Shubertf
731.1ShubertfCLEANFILES+=	${CDBASE}.iso
741.8SbouyerCLEANFILES+=	bootxx.${MACHINE}
751.1Shubertf
761.1Shubertf
771.1Shubertf.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
781.1Shubertf
791.8Sbouyer.if defined(CDINSTKERNEL)
801.8Sbouyer_INSTKERNELNOBJDIR!=	cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
811.8Sbouyer.endif
821.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
831.8Sbouyer.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
841.8SbouyerBOOT2=boot.${MACHINE}
851.8Sbouyer.else
861.8SbouyerBOOT2=boot
871.8Sbouyer.endif
881.8Sbouyer.endif
891.1Shubertf
901.1Shubertfprepare:
911.1Shubertf	${MKDIR} cdrom
921.8Sbouyer.if defined(CDKERNELS)
931.8Sbouyer.for kernel target in ${CDKERNELS}
941.8Sbouyer	${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
951.8Sbouyer.endfor
961.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
971.8Sbouyer	${RM} -f cdrom/${BOOT2}
981.8Sbouyer	${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
991.8Sbouyer	${RM} -f bootxx.${MACHINE}
1001.8Sbouyer	${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
1011.8Sbouyer	${CHMOD} +w bootxx.${MACHINE}
1021.8Sbouyer.if defined(CDBOOTOPTIONS)
1031.8Sbouyer	${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
1041.8Sbouyer.endif
1051.8Sbouyer.endif
1061.8Sbouyer.endif
1071.1Shubertf
1081.1Shubertf# Copy $RELEASEDIR/${MACHINE} in the CDROM dir
1091.1Shubertf#
1101.1Shubertf# XXX This could be done a lot easier if makefs(8) could
1111.1Shubertf# XXX include more than one directory on the image - HF
1121.1Shubertf#
1131.1Shubertfcopy-releasedir:
1141.8Sbouyer	${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso
1151.9Schristos	if ${CDRELEASE}; then 						\
1161.14Smatt		if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then 		\
1171.14Smatt			echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
1181.9Schristos			exit 1; 					\
1191.9Schristos		fi; 							\
1201.9Schristos		${MKDIR} cdrom/${MACHINE}; 				\
1211.10Sjnemeth		curdir=$$(pwd);						\
1221.9Schristos		release_destdir=$$(pwd)/cdrom/${MACHINE}; 		\
1231.15Sad		cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; 			\
1241.9Schristos		echo Copying $$(pwd) to $$release_destdir ...; 		\
1251.7Shubertf		${TOOL_PAX} 						\
1261.7Shubertf			-rw -pe -v 					\
1271.7Shubertf			${CDRELEASE_EXCLUDE}				\
1281.9Schristos			. $$release_destdir; 				\
1291.10Sjnemeth		cd $$curdir;						\
1301.9Schristos	fi
1311.9Schristos	if ${CDSOURCE}; then 						\
1321.9Schristos		if [ ! -d ${RELEASEDIR}/source ]; then	 		\
1331.9Schristos			echo "Missing ${RELEASEDIR}/source, aborting"; 	\
1341.9Schristos			exit 1; 					\
1351.9Schristos		fi; 							\
1361.9Schristos		${MKDIR} cdrom/source; 					\
1371.10Sjnemeth		curdir=$$(pwd);						\
1381.9Schristos		release_destdir=$$(pwd)/cdrom/source;	 		\
1391.9Schristos		cd ${RELEASEDIR}/source; 				\
1401.9Schristos		echo Copying $$(pwd) to $$release_destdir ...;		\
1411.9Schristos		${TOOL_PAX} 						\
1421.9Schristos			-rw -pe -v 					\
1431.9Schristos			. $$release_destdir; 				\
1441.10Sjnemeth		cd $$curdir;						\
1451.1Shubertf	fi
1461.15Sad	if [ "X${CDRUNTIME}}" != "X" ]; then				\
1471.15Sad		curdir=$$(pwd);						\
1481.15Sad		release_destdir=$${curdir}/cdrom;			\
1491.15Sad		cd $$release_destdir;					\
1501.15Sad		cd ${DESTDIR};						\
1511.15Sad		for cde in ${CDRUNTIME};				\
1521.15Sad		do							\
1531.15Sad			${TOOL_PAX} -rw -pp -v $${cde} $$release_destdir;\
1541.15Sad		done;							\
1551.15Sad		cd $$curdir;						\
1561.15Sad	fi
1571.13Ssborrill	if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then		\
1581.16Shubertf		curdir=`pwd`;						\
1591.13Ssborrill		skipflag="";						\
1601.16Shubertf		cdextra_skip="${CDEXTRA_SKIP}";				\
1611.16Shubertf		if [ "X$${cdextra_skip}" != "X" ]; then			\
1621.13Ssborrill			rm -f cdskip;					\
1631.16Shubertf			for skip in $${cdextra_skip};			\
1641.13Ssborrill			do						\
1651.13Ssborrill				echo $${skip} >> cdskip;		\
1661.13Ssborrill			done;						\
1671.13Ssborrill			skipflag="-X $${curdir}/cdskip";		\
1681.13Ssborrill		fi;							\
1691.16Shubertf		cdextra="${CDEXTRA}"; 					\
1701.16Shubertf		cdbuildextra="${CDBUILDEXTRA}"; 			\
1711.16Shubertf		for cde in $${cdextra} $${cdbuildextra};		\
1721.13Ssborrill		do							\
1731.13Ssborrill			release_destdir=$${curdir}/cdrom;		\
1741.13Ssborrill			if [ -f $${cde} ]; then				\
1751.13Ssborrill				echo Copying $${cde} to $$release_destdir ...;	\
1761.13Ssborrill				${CP} $${cde} $${release_destdir};	\
1771.13Ssborrill			elif [ -d $${cde} ]; then			\
1781.13Ssborrill				cd $${cde};				\
1791.13Ssborrill				echo Copying $$(pwd) to $$release_destdir ...;	\
1801.13Ssborrill				${TOOL_MTREE} -c $${skipflag} |		\
1811.13Ssborrill					${TOOL_PAX} -rw -pe -v -M	\
1821.13Ssborrill					$$release_destdir; 		\
1831.13Ssborrill			else						\
1841.13Ssborrill				echo "Missing $${cde}, aborting"; 	\
1851.13Ssborrill				exit 1; 				\
1861.13Ssborrill			fi; 						\
1871.13Ssborrill			cd $$curdir;					\
1881.13Ssborrill		done;							\
1891.11Sjnemeth	fi
1901.1Shubertf
1911.1Shubertfimage:
1921.8Sbouyer	${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom
1931.8Sbouyer
1941.8Sbouyer.if ${CDRELEASE} == false
1951.15Sadrelease: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
1961.8Sbouyer	${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1971.8Sbouyer	${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1981.1Shubertf
1991.8Sbouyeriso_image:
2001.8Sbouyer.else
2011.1Shubertfrelease:
2021.8Sbouyer
2031.15Sadiso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
2041.8Sbouyer	${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
2051.8Sbouyer	${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
2061.8Sbouyer.endif
2071.1Shubertf
2081.1Shubertfclean:
2091.1Shubertf	${RM} -fr cdrom
2101.1Shubertf
2111.8Sbouyerprepare_md_post: .PHONY
2121.8Sbouyerimage_md_post: .PHONY
2131.15Sadimage_md_pre: .PHONY
2141.8Sbouyer
2151.1Shubertf.include <bsd.prog.mk>
216