NetBSD/distrib/common/Makefile.bootcd
bouyer 541b5a90c5 Improve the use of makefs to build boot CDs, and make it truely MI:
- allow to specify the "instkernel" directory, and allow to put multiple
  kernels on the image
- allow to specify the directory where the image will be created
- only use bootxx_cd9660 if it exists
- search for second-stage boot as usr/mdec/boot.${MACHINE} in addition to
  usr/mdec/boot
- make 'installboot -e' optional
- use target 'release' or 'iso_image' depending on ${CDRELEASE}
- call some MD targets, which will eventually complete the file list or
  make the image bootable
2007-03-06 21:38:29 +00:00

144 lines
4.0 KiB
Makefile

# $NetBSD: Makefile.bootcd,v 1.8 2007/03/06 21:38:29 bouyer Exp $
#
# Makefile snipped to create a CD/DVD ISO
#
# XXX TODO:
# 1) merge with src/distrib/cdrom
# 2) teach makefs to add data from more than 1 directory (see below)
#
# Required variables:
# CDBASE Basename of the iso
#
# Optional variables:
# CDRELEASE Set to 'true' to include $RELEASEDIR/$MACHINE on the CD
# CDRELEASE_NOISOS Excludes installation/cdrom directory if set
# BOOT Defaults to $DESTDIR/usr/mdec/boot
# BOOTXX_CD9660 Defaults to $DESTDIR/usr/mdec/bootxx_cd9660
# CDBOOTOPTIONS Options for installboot, eg -o console=com0,speed=9600
# CDMAKEFSOPTIONS Options for makefs, eg bootimage=i386;bootxx,no-emul-boot
# CDROMS_RELEASEDIR Where to install ${CDBASE}.iso
# CDINSTKERNEL instkernel directory (relative to ${.CURDIR})
# CDKERNELS couples of the form:
# source name_on_cd
# source kernels are copied from ${CDINSTKENRNEL} (or it's obj dir)
# note that as of yet, bootxx_cd9660 can't load kernel names of more than
# 8 chars.
#
BOOT?= ${DESTDIR}/usr/mdec/boot
BOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660
CDRELEASE?= false
.if ${CDRELEASE} == false
CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom
.else
CDROMS_RELEASEDIR?= iso
.endif
.if defined(CDRELEASE_NOISOS)
CDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp'
.endif
.include <bsd.sys.mk> # for HOST_SH
.include <bsd.own.mk> # For PRINTOBJDIR
.include <bsd.kernobj.mk> # For KERNSRCDIR
DISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
ISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z
PUBLISHER?= The_NetBSD_Project
.if defined(CDMAKEFSOPTIONS)
_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS}
.else
_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
.endif
# Stuff that should come from elsewhere - XXX where? - HF
CP?= cp
RM?= rm
MKDIR?= mkdir -p
CHMOD?= chmod
CLEANFILES+= ${CDBASE}.iso
CLEANFILES+= bootxx.${MACHINE}
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
.if defined(CDINSTKERNEL)
_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
.endif
.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
BOOT2=boot.${MACHINE}
.else
BOOT2=boot
.endif
.endif
prepare:
${MKDIR} cdrom
.if defined(CDKERNELS)
.for kernel target in ${CDKERNELS}
${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
.endfor
.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
${RM} -f cdrom/${BOOT2}
${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
${RM} -f bootxx.${MACHINE}
${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
${CHMOD} +w bootxx.${MACHINE}
.if defined(CDBOOTOPTIONS)
${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
.endif
.endif
.endif
# Copy $RELEASEDIR/${MACHINE} in the CDROM dir
#
# XXX This could be done a lot easier if makefs(8) could
# XXX include more than one directory on the image - HF
#
copy-releasedir:
${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso
if ${CDRELEASE} ; then \
if [ ! -d ${RELEASEDIR}/${MACHINE} ]; then \
echo "No releasedir ${RELEASEDIR}/${MACHINE}, aborting" ; \
exit 1 ; \
fi ; \
${MKDIR} cdrom/${MACHINE} ; \
release_destdir=`pwd`/cdrom/${MACHINE} ; \
cd ${RELEASEDIR}/${MACHINE} ; \
echo Copying `pwd` to $$release_destdir ... ; \
${TOOL_PAX} \
-rw -pe -v \
${CDRELEASE_EXCLUDE} \
. $$release_destdir ; \
fi
image:
${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom
.if ${CDRELEASE} == false
release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image .WAIT image_md_post
${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
iso_image:
.else
release:
iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image .WAIT image_md_post
${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
.endif
clean:
${RM} -fr cdrom
prepare_md_post: .PHONY
image_md_post: .PHONY
.include <bsd.prog.mk>