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