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