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