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