Makefile.bootcd revision 1.17
1# $NetBSD: Makefile.bootcd,v 1.17 2009/09/25 14:09:27 christos 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 70ECHO?= echo 71 72 73CLEANFILES+= ${CDBASE}.iso 74CLEANFILES+= bootxx.${MACHINE} 75 76 77.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 78 79.if defined(CDINSTKERNEL) 80_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 81.endif 82.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 83.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 84BOOT2=boot.${MACHINE} 85.else 86BOOT2=boot 87.endif 88.endif 89 90prepare: 91 ${MKDIR} cdrom 92.if defined(CDKERNELS) 93.for kernel target in ${CDKERNELS} 94 ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 95.endfor 96.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 97 ${RM} -f cdrom/${BOOT2} 98 ${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 99 ${RM} -f bootxx.${MACHINE} 100 ${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 101 ${CHMOD} +w bootxx.${MACHINE} 102.if defined(CDBOOTOPTIONS) 103 ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 104.endif 105.endif 106.endif 107 108# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 109# 110# XXX This could be done a lot easier if makefs(8) could 111# XXX include more than one directory on the image - HF 112# 113copy-releasedir: 114 ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso 115 if ${CDRELEASE}; then \ 116 if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 117 echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 118 exit 1; \ 119 fi; \ 120 ${MKDIR} cdrom/${MACHINE}; \ 121 curdir=$$(pwd); \ 122 release_destdir=$$(pwd)/cdrom/${MACHINE}; \ 123 cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \ 124 echo Copying $$(pwd) to $$release_destdir ...; \ 125 ${TOOL_PAX} \ 126 -rw -pe -v \ 127 ${CDRELEASE_EXCLUDE} \ 128 . $$release_destdir; \ 129 cd $$curdir; \ 130 fi 131 if ${CDSOURCE}; then \ 132 if [ ! -d ${RELEASEDIR}/source ]; then \ 133 echo "Missing ${RELEASEDIR}/source, aborting"; \ 134 exit 1; \ 135 fi; \ 136 ${MKDIR} cdrom/source; \ 137 curdir=$$(pwd); \ 138 release_destdir=$$(pwd)/cdrom/source; \ 139 cd ${RELEASEDIR}/source; \ 140 echo Copying $$(pwd) to $$release_destdir ...; \ 141 ${TOOL_PAX} \ 142 -rw -pe -v \ 143 . $$release_destdir; \ 144 cd $$curdir; \ 145 fi 146 if [ "X${CDRUNTIME}}" != "X" ]; then \ 147 curdir=$$(pwd); \ 148 release_destdir=$${curdir}/cdrom; \ 149 cd $$release_destdir; \ 150 cd ${DESTDIR}; \ 151 for cde in ${CDRUNTIME}; \ 152 do \ 153 ${TOOL_PAX} -rw -pp -v $${cde} $$release_destdir;\ 154 done; \ 155 cd $$curdir; \ 156 fi 157 if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \ 158 curdir=`pwd`; \ 159 skipflag=""; \ 160 cdextra_skip="${CDEXTRA_SKIP}"; \ 161 if [ "X$${cdextra_skip}" != "X" ]; then \ 162 rm -f cdskip; \ 163 for skip in $${cdextra_skip}; \ 164 do \ 165 echo $${skip} >> cdskip; \ 166 done; \ 167 skipflag="-X $${curdir}/cdskip"; \ 168 fi; \ 169 cdextra="${CDEXTRA}"; \ 170 cdbuildextra="${CDBUILDEXTRA}"; \ 171 for cde in $${cdextra} $${cdbuildextra}; \ 172 do \ 173 release_destdir=$${curdir}/cdrom; \ 174 if [ -f $${cde} ]; then \ 175 echo Copying $${cde} to $$release_destdir ...; \ 176 ${CP} $${cde} $${release_destdir}; \ 177 elif [ -d $${cde} ]; then \ 178 cd $${cde}; \ 179 echo Copying $$(pwd) to $$release_destdir ...; \ 180 ${TOOL_MTREE} -c $${skipflag} | \ 181 ${TOOL_PAX} -rw -pe -v -M \ 182 $$release_destdir; \ 183 else \ 184 echo "Missing $${cde}, aborting"; \ 185 exit 1; \ 186 fi; \ 187 cd $$curdir; \ 188 done; \ 189 fi 190 191image: 192 ${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom 193 194.if ${CDRELEASE} == false 195release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 196 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 197 ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR} 198 199iso_image: 200.else 201release: 202 203iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 204 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 205 ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR} 206.endif 207 208clean: 209 ${RM} -fr cdrom 210 211prepare_md_post: .PHONY 212image_md_post: .PHONY 213image_md_pre: .PHONY 214 215.include <bsd.prog.mk> 216