Replace previous change by different test
[minix.git] / distrib / common / Makefile.bootcd
blobbfbf9bca42bf8c525c820c5dd588c4fcedd4a342
1 #       $NetBSD: Makefile.bootcd,v 1.20 2012/08/17 16:57:59 riz Exp $
3 # Makefile snipped to create a CD/DVD ISO
6 # XXX TODO:
7 # 1) merge with src/distrib/cdrom
8 # 2) teach makefs to add data from more than 1 directory (see below)
11 # Required variables:
12 #       CDBASE          Basename of the iso
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 #       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
41 CDRELEASE?=     false
42 CDSOURCE?=      false
43 .if ${CDRELEASE} == false
44 CDROMS_RELEASEDIR?=     ${MACHINE}/installation/cdrom
45 .else
46 CDROMS_RELEASEDIR?=     images
47 .endif
48 .if defined(CDRELEASE_NOISOS)
49 CDRELEASE_EXCLUDE=      -s ',./installation/cdrom.*,,gp'
50 .endif
51 .if !defined(CDRELEASE_LIVEIMAGE)
52 CDRELEASE_EXCLUDE+=     -s ',./installation/liveimage.*,,gp'
53 .endif
54 .if !defined(CDRELEASE_INSTALLIMAGE)
55 CDRELEASE_EXCLUDE+=     -s ',./installation/installimage.*,,gp'
56 .endif
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}
68 .else
69 _CDMAKEFSOPTIONS=       rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
70 .endif
72 # Stuff that should come from elsewhere - XXX where? - HF
73 CP?=            cp
74 RM?=            rm
75 MKDIR?=         mkdir -p
76 CHMOD?=         chmod
77 ECHO?=          echo
79 .if ${CDRELEASE} == false
80 CDIMAGE=        ${CDBASE}.iso
81 .else
82 CDIMAGE=        NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso
83 .endif
85 CLEANFILES+=    ${CDIMAGE}
86 CLEANFILES+=    bootxx.${MACHINE}
89 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
91 .if defined(CDINSTKERNEL)
92 _INSTKERNELNOBJDIR!=    cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
93 .endif
94 .if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
95 .if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
96 BOOT2=boot.${MACHINE}
97 .else
98 BOOT2=boot
99 .endif
100 .endif
102 prepare:
103         ${MKDIR} cdrom
104 .if defined(CDKERNELS)
105 .for kernel target in ${CDKERNELS}
106         ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
107 .endfor
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}
116 .endif
117 .endif
118 .endif
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
125 copy-releasedir:
126         ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE}
127         if ${CDRELEASE}; then                                           \
128                 if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then            \
129                         echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
130                         exit 1;                                         \
131                 fi;                                                     \
132                 ${MKDIR} cdrom/${MACHINE};                              \
133                 curdir=$$(pwd);                                         \
134                 release_destdir=$$(pwd)/cdrom/${MACHINE};               \
135                 cd ${RELEASEDIR}/${RELEASEMACHINEDIR};                  \
136                 echo Copying $$(pwd) to $$release_destdir ...;          \
137                 ${TOOL_PAX}                                             \
138                         -rw -pe -v                                      \
139                         ${CDRELEASE_EXCLUDE}                            \
140                         . $$release_destdir;                            \
141                 cd $$curdir;                                            \
142         fi
143         if ${CDSOURCE}; then                                            \
144                 if [ ! -d ${RELEASEDIR}/source ]; then                  \
145                         echo "Missing ${RELEASEDIR}/source, aborting";  \
146                         exit 1;                                         \
147                 fi;                                                     \
148                 ${MKDIR} cdrom/source;                                  \
149                 curdir=$$(pwd);                                         \
150                 release_destdir=$$(pwd)/cdrom/source;                   \
151                 cd ${RELEASEDIR}/source;                                \
152                 echo Copying $$(pwd) to $$release_destdir ...;          \
153                 ${TOOL_PAX}                                             \
154                         -rw -pe -v                                      \
155                         . $$release_destdir;                            \
156                 cd $$curdir;                                            \
157         fi
158         if [ "X${CDRUNTIME}}" != "X" ]; then                            \
159                 curdir=$$(pwd);                                         \
160                 release_destdir=$${curdir}/cdrom;                       \
161                 cd $$release_destdir;                                   \
162                 cd ${DESTDIR};                                          \
163                 for cde in ${CDRUNTIME};                                \
164                 do                                                      \
165                         ${TOOL_PAX} -rw -pp -v $${cde} $$release_destdir;\
166                 done;                                                   \
167                 cd $$curdir;                                            \
168         fi
169         if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then                \
170                 curdir=`pwd`;                                           \
171                 skipflag="";                                            \
172                 cdextra_skip="${CDEXTRA_SKIP}";                         \
173                 if [ "X$${cdextra_skip}" != "X" ]; then                 \
174                         rm -f cdskip;                                   \
175                         for skip in $${cdextra_skip};                   \
176                         do                                              \
177                                 echo $${skip} >> cdskip;                \
178                         done;                                           \
179                         skipflag="-X $${curdir}/cdskip";                \
180                 fi;                                                     \
181                 cdextra="${CDEXTRA}";                                   \
182                 cdbuildextra="${CDBUILDEXTRA}";                         \
183                 for cde in $${cdextra} $${cdbuildextra};                \
184                 do                                                      \
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                       \
190                                 cd $${cde};                             \
191                                 echo Copying $$(pwd) to $$release_destdir ...;  \
192                                 ${TOOL_MTREE} -c $${skipflag} |         \
193                                         ${TOOL_PAX} -rw -pe -v -M       \
194                                         $$release_destdir;              \
195                         else                                            \
196                                 echo "Missing $${cde}, aborting";       \
197                                 exit 1;                                 \
198                         fi;                                             \
199                         cd $$curdir;                                    \
200                 done;                                                   \
201         fi
203 image:
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}
211 iso_image:
212 .else
213 release:
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}
218 .endif
220 clean:
221         ${RM} -fr cdrom
223 prepare_md_post: .PHONY
224 image_md_post: .PHONY
225 image_md_pre: .PHONY
227 .include <bsd.prog.mk>