Makefile.bootcd revision 1.12
1# $NetBSD: Makefile.bootcd,v 1.12 2007/11/20 16:12:50 sborrill 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 directory containing extra stuff to put on CD 19# BOOT Defaults to $DESTDIR/usr/mdec/boot 20# BOOTXX_CD9660 Defaults to $DESTDIR/usr/mdec/bootxx_cd9660 21# CDBOOTOPTIONS Options for installboot, eg -o console=com0,speed=9600 22# CDMAKEFSOPTIONS Options for makefs, eg bootimage=i386;bootxx,no-emul-boot 23# CDROMS_RELEASEDIR Where to install ${CDBASE}.iso 24# CDINSTKERNEL instkernel directory (relative to ${.CURDIR}) 25# CDKERNELS couples of the form: 26# source name_on_cd 27# source kernels are copied from ${CDINSTKERNEL} (or its obj dir) 28# note that as of yet, bootxx_cd9660 can't load kernel names of more than 29# 8 chars (though they can be in a sub-directory meaning the pathname is 30# longer than 8 chars) 31# 32 33BOOT?= ${DESTDIR}/usr/mdec/boot 34BOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660 35CDRELEASE?= false 36CDSOURCE?= false 37.if ${CDRELEASE} == false 38CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom 39.else 40CDROMS_RELEASEDIR?= iso 41.endif 42.if defined(CDRELEASE_NOISOS) 43CDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp' 44.endif 45 46.include <bsd.sys.mk> # for HOST_SH 47.include <bsd.own.mk> # For PRINTOBJDIR 48.include <bsd.kernobj.mk> # For KERNSRCDIR 49 50DISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s 51ISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z 52PUBLISHER?= The_NetBSD_Project 53.if defined(CDMAKEFSOPTIONS) 54_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS} 55.else 56_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER} 57.endif 58 59# Stuff that should come from elsewhere - XXX where? - HF 60CP?= cp 61RM?= rm 62MKDIR?= mkdir -p 63CHMOD?= chmod 64 65 66CLEANFILES+= ${CDBASE}.iso 67CLEANFILES+= bootxx.${MACHINE} 68 69 70.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 71 72.if defined(CDINSTKERNEL) 73_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 74.endif 75.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 76.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 77BOOT2=boot.${MACHINE} 78.else 79BOOT2=boot 80.endif 81.endif 82 83prepare: 84 ${MKDIR} cdrom 85.if defined(CDKERNELS) 86.for kernel target in ${CDKERNELS} 87 ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 88.endfor 89.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 90 ${RM} -f cdrom/${BOOT2} 91 ${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 92 ${RM} -f bootxx.${MACHINE} 93 ${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 94 ${CHMOD} +w bootxx.${MACHINE} 95.if defined(CDBOOTOPTIONS) 96 ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 97.endif 98.endif 99.endif 100 101# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 102# 103# XXX This could be done a lot easier if makefs(8) could 104# XXX include more than one directory on the image - HF 105# 106copy-releasedir: 107 ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso 108 if ${CDRELEASE}; then \ 109 if [ ! -d ${RELEASEDIR}/${MACHINE} ]; then \ 110 echo "Missing ${RELEASEDIR}/${MACHINE}, aborting"; \ 111 exit 1; \ 112 fi; \ 113 ${MKDIR} cdrom/${MACHINE}; \ 114 curdir=$$(pwd); \ 115 release_destdir=$$(pwd)/cdrom/${MACHINE}; \ 116 cd ${RELEASEDIR}/${MACHINE}; \ 117 echo Copying $$(pwd) to $$release_destdir ...; \ 118 ${TOOL_PAX} \ 119 -rw -pe -v \ 120 ${CDRELEASE_EXCLUDE} \ 121 . $$release_destdir; \ 122 cd $$curdir; \ 123 fi 124 if ${CDSOURCE}; then \ 125 if [ ! -d ${RELEASEDIR}/source ]; then \ 126 echo "Missing ${RELEASEDIR}/source, aborting"; \ 127 exit 1; \ 128 fi; \ 129 ${MKDIR} cdrom/source; \ 130 curdir=$$(pwd); \ 131 release_destdir=$$(pwd)/cdrom/source; \ 132 cd ${RELEASEDIR}/source; \ 133 echo Copying $$(pwd) to $$release_destdir ...; \ 134 ${TOOL_PAX} \ 135 -rw -pe -v \ 136 . $$release_destdir; \ 137 cd $$curdir; \ 138 fi 139 if [ "X${CDEXTRA}" != "X" ]; then \ 140 if [ ! -d ${CDEXTRA} ]; then \ 141 echo "Missing ${CDEXTRA}, aborting"; \ 142 exit 1; \ 143 fi; \ 144 curdir=$$(pwd); \ 145 release_destdir=$$(pwd)/cdrom; \ 146 cd ${CDEXTRA}; \ 147 echo Copying $$(pwd) to $$release_destdir ...; \ 148 ${TOOL_PAX} \ 149 -rw -pe -v \ 150 . $$release_destdir; \ 151 cd $$curdir; \ 152 fi 153 154image: 155 ${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom 156 157.if ${CDRELEASE} == false 158release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image .WAIT image_md_post 159 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 160 ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR} 161 162iso_image: 163.else 164release: 165 166iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image .WAIT image_md_post 167 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 168 ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR} 169.endif 170 171clean: 172 ${RM} -fr cdrom 173 174prepare_md_post: .PHONY 175image_md_post: .PHONY 176 177 178.include <bsd.prog.mk> 179