1 # $NetBSD: Makefile.bootcd,v 1.20 2012/08/17 16:57:59 riz Exp $
3 # Makefile snipped to create a CD/DVD ISO
7 # 1) merge with src/distrib/cdrom
8 # 2) teach makefs to add data from more than 1 directory (see below)
12 # CDBASE Basename of the iso
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:
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)
39 BOOT?= ${DESTDIR}/usr/mdec/boot
40 BOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660
43 .if ${CDRELEASE} == false
44 CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom
46 CDROMS_RELEASEDIR?= images
48 .if defined(CDRELEASE_NOISOS)
49 CDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp'
51 .if !defined(CDRELEASE_LIVEIMAGE)
52 CDRELEASE_EXCLUDE+= -s ',./installation/liveimage.*,,gp'
54 .if !defined(CDRELEASE_INSTALLIMAGE)
55 CDRELEASE_EXCLUDE+= -s ',./installation/installimage.*,,gp'
58 .include <bsd.sys.mk> # for HOST_SH
59 .include <bsd.own.mk> # For PRINTOBJDIR
60 .include <bsd.kernobj.mk> # For KERNSRCDIR
62 DISTRIBVER!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh
63 DISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
64 ISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z
65 PUBLISHER?= The_NetBSD_Project
66 .if defined(CDMAKEFSOPTIONS)
67 _CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS}
69 _CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
72 # Stuff that should come from elsewhere - XXX where? - HF
79 .if ${CDRELEASE} == false
80 CDIMAGE= ${CDBASE}.iso
82 CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso
85 CLEANFILES+= ${CDIMAGE}
86 CLEANFILES+= bootxx.${MACHINE}
89 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
91 .if defined(CDINSTKERNEL)
92 _INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
94 .if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
95 .if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
104 .if defined(CDKERNELS)
105 .for kernel target in ${CDKERNELS}
106 ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
108 .if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
109 ${RM} -f cdrom/${BOOT2}
110 ${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
111 ${RM} -f bootxx.${MACHINE}
112 ${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
113 ${CHMOD} +w bootxx.${MACHINE}
114 .if defined(CDBOOTOPTIONS)
115 ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
120 # Copy $RELEASEDIR/${MACHINE} in the CDROM dir
122 # XXX This could be done a lot easier if makefs(8) could
123 # XXX include more than one directory on the image - HF
126 ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE}
127 if ${CDRELEASE}; then \
128 if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \
129 echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
132 ${MKDIR} cdrom/${MACHINE}; \
134 release_destdir=$$(pwd)/cdrom/${MACHINE}; \
135 cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \
136 echo Copying $$(pwd) to $$release_destdir ...; \
139 ${CDRELEASE_EXCLUDE} \
140 . $$release_destdir; \
143 if ${CDSOURCE}; then \
144 if [ ! -d ${RELEASEDIR}/source ]; then \
145 echo "Missing ${RELEASEDIR}/source, aborting"; \
148 ${MKDIR} cdrom/source; \
150 release_destdir=$$(pwd)/cdrom/source; \
151 cd ${RELEASEDIR}/source; \
152 echo Copying $$(pwd) to $$release_destdir ...; \
155 . $$release_destdir; \
158 if [ "X${CDRUNTIME}}" != "X" ]; then \
160 release_destdir=$${curdir}/cdrom; \
161 cd $$release_destdir; \
163 for cde in ${CDRUNTIME}; \
165 ${TOOL_PAX} -rw -pp -v $${cde} $$release_destdir;\
169 if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \
172 cdextra_skip="${CDEXTRA_SKIP}"; \
173 if [ "X$${cdextra_skip}" != "X" ]; then \
175 for skip in $${cdextra_skip}; \
177 echo $${skip} >> cdskip; \
179 skipflag="-X $${curdir}/cdskip"; \
181 cdextra="${CDEXTRA}"; \
182 cdbuildextra="${CDBUILDEXTRA}"; \
183 for cde in $${cdextra} $${cdbuildextra}; \
185 release_destdir=$${curdir}/cdrom; \
186 if [ -f $${cde} ]; then \
187 echo Copying $${cde} to $$release_destdir ...; \
188 ${CP} $${cde} $${release_destdir}; \
189 elif [ -d $${cde} ]; then \
191 echo Copying $$(pwd) to $$release_destdir ...; \
192 ${TOOL_MTREE} -c $${skipflag} | \
193 ${TOOL_PAX} -rw -pe -v -M \
196 echo "Missing $${cde}, aborting"; \
204 ${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom
206 .if ${CDRELEASE} == false
207 release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
208 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
209 ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
215 iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
216 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
217 ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
223 prepare_md_post: .PHONY
224 image_md_post: .PHONY
227 .include <bsd.prog.mk>