No empty .Rs/.Re
[netbsd-mini2440.git] / distrib / common / Makefile.bootcd
blob9d99f4eb08158bb96c5cc623278f80f83fbf2728
1 #       $NetBSD: Makefile.bootcd,v 1.16 2008/12/02 10:06:00 hubertf 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?=     iso
47 .endif
48 .if defined(CDRELEASE_NOISOS)
49 CDRELEASE_EXCLUDE=      -s ',./installation/cdrom.*,,gp'
50 .endif
52 .include <bsd.sys.mk>           # for HOST_SH
53 .include <bsd.own.mk>           # For PRINTOBJDIR
54 .include <bsd.kernobj.mk>       # For KERNSRCDIR
56 DISTRIBREV!=    ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
57 ISO_VOLID!=     echo NETBSD_${DISTRIBREV} | tr a-z A-Z
58 PUBLISHER?= The_NetBSD_Project
59 .if defined(CDMAKEFSOPTIONS)
60 _CDMAKEFSOPTIONS=       rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS}
61 .else
62 _CDMAKEFSOPTIONS=       rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
63 .endif
65 # Stuff that should come from elsewhere - XXX where? - HF
66 CP?=            cp
67 RM?=            rm
68 MKDIR?=         mkdir -p
69 CHMOD?=         chmod
70 ECHO?=          echo
73 CLEANFILES+=    ${CDBASE}.iso
74 CLEANFILES+=    bootxx.${MACHINE}
77 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
79 .if defined(CDINSTKERNEL)
80 _INSTKERNELNOBJDIR!=    cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
81 .endif
82 .if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
83 .if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
84 BOOT2=boot.${MACHINE}
85 .else
86 BOOT2=boot
87 .endif
88 .endif
90 prepare:
91         ${MKDIR} cdrom
92 .if defined(CDKERNELS)
93 .for kernel target in ${CDKERNELS}
94         ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
95 .endfor
96 .if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
97         ${RM} -f cdrom/${BOOT2}
98         ${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
99         ${RM} -f bootxx.${MACHINE}
100         ${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
101         ${CHMOD} +w bootxx.${MACHINE}
102 .if defined(CDBOOTOPTIONS)
103         ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
104 .endif
105 .endif
106 .endif
108 # Copy $RELEASEDIR/${MACHINE} in the CDROM dir
110 # XXX This could be done a lot easier if makefs(8) could
111 # XXX include more than one directory on the image - HF
113 copy-releasedir:
114         ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDBASE}.iso
115         if ${CDRELEASE}; then                                           \
116                 if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then            \
117                         echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
118                         exit 1;                                         \
119                 fi;                                                     \
120                 ${MKDIR} cdrom/${MACHINE};                              \
121                 curdir=$$(pwd);                                         \
122                 release_destdir=$$(pwd)/cdrom/${MACHINE};               \
123                 cd ${RELEASEDIR}/${RELEASEMACHINEDIR};                  \
124                 echo Copying $$(pwd) to $$release_destdir ...;          \
125                 ${TOOL_PAX}                                             \
126                         -rw -pe -v                                      \
127                         ${CDRELEASE_EXCLUDE}                            \
128                         . $$release_destdir;                            \
129                 cd $$curdir;                                            \
130         fi
131         if ${CDSOURCE}; then                                            \
132                 if [ ! -d ${RELEASEDIR}/source ]; then                  \
133                         echo "Missing ${RELEASEDIR}/source, aborting";  \
134                         exit 1;                                         \
135                 fi;                                                     \
136                 ${MKDIR} cdrom/source;                                  \
137                 curdir=$$(pwd);                                         \
138                 release_destdir=$$(pwd)/cdrom/source;                   \
139                 cd ${RELEASEDIR}/source;                                \
140                 echo Copying $$(pwd) to $$release_destdir ...;          \
141                 ${TOOL_PAX}                                             \
142                         -rw -pe -v                                      \
143                         . $$release_destdir;                            \
144                 cd $$curdir;                                            \
145         fi
146         if [ "X${CDRUNTIME}}" != "X" ]; then                            \
147                 curdir=$$(pwd);                                         \
148                 release_destdir=$${curdir}/cdrom;                       \
149                 cd $$release_destdir;                                   \
150                 cd ${DESTDIR};                                          \
151                 for cde in ${CDRUNTIME};                                \
152                 do                                                      \
153                         ${TOOL_PAX} -rw -pp -v $${cde} $$release_destdir;\
154                 done;                                                   \
155                 cd $$curdir;                                            \
156         fi
157         if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then                \
158                 curdir=`pwd`;                                           \
159                 skipflag="";                                            \
160                 cdextra_skip="${CDEXTRA_SKIP}";                         \
161                 if [ "X$${cdextra_skip}" != "X" ]; then                 \
162                         rm -f cdskip;                                   \
163                         for skip in $${cdextra_skip};                   \
164                         do                                              \
165                                 echo $${skip} >> cdskip;                \
166                         done;                                           \
167                         skipflag="-X $${curdir}/cdskip";                \
168                 fi;                                                     \
169                 cdextra="${CDEXTRA}";                                   \
170                 cdbuildextra="${CDBUILDEXTRA}";                         \
171                 for cde in $${cdextra} $${cdbuildextra};                \
172                 do                                                      \
173                         release_destdir=$${curdir}/cdrom;               \
174                         if [ -f $${cde} ]; then                         \
175                                 echo Copying $${cde} to $$release_destdir ...;  \
176                                 ${CP} $${cde} $${release_destdir};      \
177                         elif [ -d $${cde} ]; then                       \
178                                 cd $${cde};                             \
179                                 echo Copying $$(pwd) to $$release_destdir ...;  \
180                                 ${TOOL_MTREE} -c $${skipflag} |         \
181                                         ${TOOL_PAX} -rw -pe -v -M       \
182                                         $$release_destdir;              \
183                         else                                            \
184                                 echo "Missing $${cde}, aborting";       \
185                                 exit 1;                                 \
186                         fi;                                             \
187                         cd $$curdir;                                    \
188                 done;                                                   \
189         fi
191 image:
192         ${TOOL_MAKEFS} -t cd9660 -o ${_CDMAKEFSOPTIONS:Q} ${CDBASE}.iso cdrom
194 .if ${CDRELEASE} == false
195 release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
196         ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
197         ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
199 iso_image:
200 .else
201 release:
203 iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
204         ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
205         ${RELEASE_INSTALL} ${CDBASE}.iso ${RELEASEDIR}/${CDROMS_RELEASEDIR}
206 .endif
208 clean:
209         ${RM} -fr cdrom
211 prepare_md_post: .PHONY
212 image_md_post: .PHONY
213 image_md_pre: .PHONY
215 .include <bsd.prog.mk>