1# $NetBSD: Makefile.bootcd,v 1.16 2008/12/02 10:06:00 hubertf Exp $ 2# 3# Makefile snipped to create a CD/DVD ISO 4# 5 6# XXX TODO: 7# 1) merge with src/distrib/cdrom 8# 2) teach makefs to add data from more than 1 directory (see below) 9 10# 11# Required variables: 12# CDBASE Basename of the iso 13# 14# Optional variables: 15# CDRELEASE Set to 'true' to include $RELEASEDIR/$MACHINE on the CD 16# CDRELEASE_NOISOS Excludes installation/cdrom directory if set 17# CDSOURCE Set to 'true' to include $RELEASEDIR/source on the CD 18# CDEXTRA Set to a list of files or directories containing extra 19# stuff to put on CD (set by build.sh -C flag) 20# CDBUILDEXTRA Set to a list of files or directories containing extra 21# stuff to put on CD (use in Makefiles) 22# CDEXTRA_SKIP A list of file exclusion paths to exclude when copying 23# directories of extra stuff in CDEXTRA AND CDBUILDEXTRA 24# BOOT Defaults to $DESTDIR/usr/mdec/boot 25# BOOTXX_CD9660 Defaults to $DESTDIR/usr/mdec/bootxx_cd9660 26# CDBOOTOPTIONS Options for installboot, eg -o console=com0,speed=9600 27# CDMAKEFSOPTIONS Options for makefs, eg bootimage=i386;bootxx,no-emul-boot 28# CDROMS_RELEASEDIR Where to install ${CDBASE}.iso 29# CDINSTKERNEL instkernel directory (relative to ${.CURDIR}) 30# CDKERNELS couples of the form: 31# source name_on_cd 32# CDRUNTIME files/directories to copy from $DESTDIR onto the CD 33# source kernels are copied from ${CDINSTKERNEL} (or its obj dir) 34# note that as of yet, bootxx_cd9660 can't load kernel names of more than 35# 8 chars (though they can be in a sub-directory meaning the pathname is 36# longer than 8 chars) 37# 38 39BOOT?= ${DESTDIR}/usr/mdec/boot 40BOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660 41CDRELEASE?= false 42CDSOURCE?= false 43.if ${CDRELEASE} == false 44CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom 45.else 46CDROMS_RELEASEDIR?= iso 47.endif 48.if defined(CDRELEASE_NOISOS) 49CDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp' 50.endif 51 52.include <bsd.sys.mk> # for HOST_SH 53.include <bsd.own.mk> # For PRINTOBJDIR 54.include <bsd.kernobj.mk> # For KERNSRCDIR 55 56DISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s 57ISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z 58PUBLISHER?= The_NetBSD_Project 59.if defined(CDMAKEFSOPTIONS) 60_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS} 61.else 62_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER} 63.endif 64 65# Stuff that should come from elsewhere - XXX where? - HF 66CP?= cp 67RM?= rm 68MKDIR?= mkdir -p 69CHMOD?= chmod 70 71 72CLEANFILES+= ${CDBASE}.iso 73CLEANFILES+= bootxx.${MACHINE} 74 75 76.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 77 78.if defined(CDINSTKERNEL) 79_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 80.endif 81.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 82.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 83BOOT2=boot.${MACHINE} 84.else 85BOOT2=boot 86.endif 87.endif 88 89prepare: 90 ${MKDIR} cdrom 91.if defined(CDKERNELS) 92.for kernel target in ${CDKERNELS} 93 ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 94.endfor 95.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 96 ${RM} -f cdrom/${BOOT2} 97 ${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 98 ${RM} -f bootxx.${MACHINE} 99 ${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 100 ${CHMOD} +w bootxx.${MACHINE} 101.if defined(CDBOOTOPTIONS) 102 ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 103.endif 104.endif 105.endif 106 107# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 108# 109# XXX This could be done a lot easier if makefs(8) could 110# XXX include more than one directory on the image - HF 111# 112copy-releasedir: 113 ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso 114 if ${CDRELEASE}; then \ 115 if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 116 echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 117 exit 1; \ 118 fi; \ 119 ${MKDIR} cdrom/${MACHINE}; \ 120 curdir=$$(pwd); \ 121 release_destdir=$$(pwd)/cdrom/${MACHINE}; \ 122 cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \ 123 echo Copying $$(pwd) to $$release_destdir ...; \ 124 ${TOOL_PAX} \ 125 -rw -pe -v \ 126 ${CDRELEASE_EXCLUDE} \ 127 . $$release_destdir; \ 128 cd $$curdir; \ 129 fi 130 if ${CDSOURCE}; then \ 131 if [ ! -d ${RELEASEDIR}/source ]; then \ 132 echo "Missing ${RELEASEDIR}/source, aborting"; \ 133 exit 1; \ 134 fi; \ 135 ${MKDIR} cdrom/source; \ 136 curdir=$$(pwd); \ 137 release_destdir=$$(pwd)/cdrom/source; \ 138 cd ${RELEASEDIR}/source; \ 139 echo Copying $$(pwd) to $$release_destdir ...; \ 140 ${TOOL_PAX} \ 141 -rw -pe -v \ 142 . $$release_destdir; \ 143 cd $$curdir; \ 144 fi 145 if [ "X${CDRUNTIME}}" != "X" ]; then \ 146 curdir=$$(pwd); \ 147 release_destdir=$${curdir}/cdrom; \ 148 cd $$release_destdir; \ 149 cd ${DESTDIR}; \ 150 for cde in ${CDRUNTIME}; \ 151 do \ 152 ${TOOL_PAX} -rw -pp -v $${cde} $$release_destdir;\ 153 done; \ 154 cd $$curdir; \ 155 fi 156 if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \ 157 curdir=`pwd`; \ 158 skipflag=""; \ 159 cdextra_skip="${CDEXTRA_SKIP}"; \ 160 if [ "X$${cdextra_skip}" != "X" ]; then \ 161 rm -f cdskip; \ 162 for skip in $${cdextra_skip}; \ 163 do \ 164 echo $${skip} >> cdskip; \ 165 done; \ 166 skipflag="-X $${curdir}/cdskip"; \ 167 fi; \ 168 cdextra="${CDEXTRA}"; \ 169 cdbuildextra="${CDBUILDEXTRA}"; \ 170 for cde in $${cdextra} $${cdbuildextra}; \ 171 do \ 172 release_destdir=$${curdir}/cdrom; \ 173 if [ -f $${cde} ]; then \ 174 echo Copying $${cde} to $$release_destdir ...; \ 175 ${CP} $${cde} $${release_destdir}; \ 176 elif [ -d $${cde} ]; then \ 177 cd $${cde}; \ 178 echo Copying $$(pwd) to $$release_destdir ...; \ 179 ${TOOL_MTREE} -c $${skipflag} | \ 180 ${TOOL_PAX} -rw -pe -v -M \ 181 $$release_destdir; \ 182 else \ 183 echo "Missing $${cde}, aborting"; \ 184 exit 1; \ 185 fi; \ 186 cd $$curdir; \ 187 done; \ 188 fi 189 190image: 191 ${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom 192 193.if ${CDRELEASE} == false 194release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 195 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 196 ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR} 197 198iso_image: 199.else 200release: 201 202iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 203 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 204 ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR} 205.endif 206 207clean: 208 ${RM} -fr cdrom 209 210prepare_md_post: .PHONY 211image_md_post: .PHONY 212image_md_pre: .PHONY 213 214.include <bsd.prog.mk> 215