Makefile.bootcd revision 1.15
11.15Sad#	$NetBSD: Makefile.bootcd,v 1.15 2008/11/21 14:49:45 ad 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.1Shubertf
711.1Shubertf
721.1ShubertfCLEANFILES+=	${CDBASE}.iso
731.8SbouyerCLEANFILES+=	bootxx.${MACHINE}
741.1Shubertf
751.1Shubertf
761.1Shubertf.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
771.1Shubertf
781.8Sbouyer.if defined(CDINSTKERNEL)
791.8Sbouyer_INSTKERNELNOBJDIR!=	cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
801.8Sbouyer.endif
811.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
821.8Sbouyer.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
831.8SbouyerBOOT2=boot.${MACHINE}
841.8Sbouyer.else
851.8SbouyerBOOT2=boot
861.8Sbouyer.endif
871.8Sbouyer.endif
881.1Shubertf
891.1Shubertfprepare:
901.1Shubertf	${MKDIR} cdrom
911.8Sbouyer.if defined(CDKERNELS)
921.8Sbouyer.for kernel target in ${CDKERNELS}
931.8Sbouyer	${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
941.8Sbouyer.endfor
951.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
961.8Sbouyer	${RM} -f cdrom/${BOOT2}
971.8Sbouyer	${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
981.8Sbouyer	${RM} -f bootxx.${MACHINE}
991.8Sbouyer	${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
1001.8Sbouyer	${CHMOD} +w bootxx.${MACHINE}
1011.8Sbouyer.if defined(CDBOOTOPTIONS)
1021.8Sbouyer	${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
1031.8Sbouyer.endif
1041.8Sbouyer.endif
1051.8Sbouyer.endif
1061.1Shubertf
1071.1Shubertf# Copy $RELEASEDIR/${MACHINE} in the CDROM dir
1081.1Shubertf#
1091.1Shubertf# XXX This could be done a lot easier if makefs(8) could
1101.1Shubertf# XXX include more than one directory on the image - HF
1111.1Shubertf#
1121.1Shubertfcopy-releasedir:
1131.8Sbouyer	${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso
1141.9Schristos	if ${CDRELEASE}; then 						\
1151.14Smatt		if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then 		\
1161.14Smatt			echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
1171.9Schristos			exit 1; 					\
1181.9Schristos		fi; 							\
1191.9Schristos		${MKDIR} cdrom/${MACHINE}; 				\
1201.10Sjnemeth		curdir=$$(pwd);						\
1211.9Schristos		release_destdir=$$(pwd)/cdrom/${MACHINE}; 		\
1221.15Sad		cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; 			\
1231.9Schristos		echo Copying $$(pwd) to $$release_destdir ...; 		\
1241.7Shubertf		${TOOL_PAX} 						\
1251.7Shubertf			-rw -pe -v 					\
1261.7Shubertf			${CDRELEASE_EXCLUDE}				\
1271.9Schristos			. $$release_destdir; 				\
1281.10Sjnemeth		cd $$curdir;						\
1291.9Schristos	fi
1301.9Schristos	if ${CDSOURCE}; then 						\
1311.9Schristos		if [ ! -d ${RELEASEDIR}/source ]; then	 		\
1321.9Schristos			echo "Missing ${RELEASEDIR}/source, aborting"; 	\
1331.9Schristos			exit 1; 					\
1341.9Schristos		fi; 							\
1351.9Schristos		${MKDIR} cdrom/source; 					\
1361.10Sjnemeth		curdir=$$(pwd);						\
1371.9Schristos		release_destdir=$$(pwd)/cdrom/source;	 		\
1381.9Schristos		cd ${RELEASEDIR}/source; 				\
1391.9Schristos		echo Copying $$(pwd) to $$release_destdir ...;		\
1401.9Schristos		${TOOL_PAX} 						\
1411.9Schristos			-rw -pe -v 					\
1421.9Schristos			. $$release_destdir; 				\
1431.10Sjnemeth		cd $$curdir;						\
1441.1Shubertf	fi
1451.15Sad	if [ "X${CDRUNTIME}}" != "X" ]; then				\
1461.15Sad		curdir=$$(pwd);						\
1471.15Sad		release_destdir=$${curdir}/cdrom;			\
1481.15Sad		cd $$release_destdir;					\
1491.15Sad		cd ${DESTDIR};						\
1501.15Sad		for cde in ${CDRUNTIME};				\
1511.15Sad		do							\
1521.15Sad			${TOOL_PAX} -rw -pp -v $${cde} $$release_destdir;\
1531.15Sad		done;							\
1541.15Sad		cd $$curdir;						\
1551.15Sad	fi
1561.13Ssborrill	if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then		\
1571.11Sjnemeth		curdir=$$(pwd);						\
1581.13Ssborrill		skipflag="";						\
1591.13Ssborrill		if [ "X${CDEXTRA_SKIP}" != "X" ]; then			\
1601.13Ssborrill			rm -f cdskip;					\
1611.13Ssborrill			for skip in ${CDEXTRA_SKIP};			\
1621.13Ssborrill			do						\
1631.13Ssborrill				echo $${skip} >> cdskip;		\
1641.13Ssborrill			done;						\
1651.13Ssborrill			skipflag="-X $${curdir}/cdskip";		\
1661.13Ssborrill		fi;							\
1671.13Ssborrill		for cde in ${CDEXTRA} ${CDBUILDEXTRA};			\
1681.13Ssborrill		do							\
1691.13Ssborrill			release_destdir=$${curdir}/cdrom;		\
1701.13Ssborrill			if [ -f $${cde} ]; then				\
1711.13Ssborrill				echo Copying $${cde} to $$release_destdir ...;	\
1721.13Ssborrill				${CP} $${cde} $${release_destdir};	\
1731.13Ssborrill			elif [ -d $${cde} ]; then			\
1741.13Ssborrill				cd $${cde};				\
1751.13Ssborrill				echo Copying $$(pwd) to $$release_destdir ...;	\
1761.13Ssborrill				${TOOL_MTREE} -c $${skipflag} |		\
1771.13Ssborrill					${TOOL_PAX} -rw -pe -v -M	\
1781.13Ssborrill					$$release_destdir; 		\
1791.13Ssborrill			else						\
1801.13Ssborrill				echo "Missing $${cde}, aborting"; 	\
1811.13Ssborrill				exit 1; 				\
1821.13Ssborrill			fi; 						\
1831.13Ssborrill			cd $$curdir;					\
1841.13Ssborrill		done;							\
1851.11Sjnemeth	fi
1861.1Shubertf
1871.1Shubertfimage:
1881.8Sbouyer	${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom
1891.8Sbouyer
1901.8Sbouyer.if ${CDRELEASE} == false
1911.15Sadrelease: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
1921.8Sbouyer	${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1931.8Sbouyer	${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
1941.1Shubertf
1951.8Sbouyeriso_image:
1961.8Sbouyer.else
1971.1Shubertfrelease:
1981.8Sbouyer
1991.15Sadiso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
2001.8Sbouyer	${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
2011.8Sbouyer	${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
2021.8Sbouyer.endif
2031.1Shubertf
2041.1Shubertfclean:
2051.1Shubertf	${RM} -fr cdrom
2061.1Shubertf
2071.8Sbouyerprepare_md_post: .PHONY
2081.8Sbouyerimage_md_post: .PHONY
2091.15Sadimage_md_pre: .PHONY
2101.8Sbouyer
2111.1Shubertf.include <bsd.prog.mk>
212