]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/Makefile
Copy xen includes in to RELENG_6 branch
[FreeBSD/FreeBSD.git] / release / Makefile
1 # $FreeBSD$
2 #
3 # make release [BUILDNAME=somename] CHROOTDIR=/some/dir CVSROOT=/cvs/dir \
4 #     [RELEASETAG=tag]
5 #
6 # Where "/some/dir" is the pathname of a directory on a some filesystem with
7 # at least 1000MB of free space, "somename" is what you want the release to
8 # call itself, "/cvs/dir" is where our source repo resides and, optionally,
9 # which CVS "tag" name should be used when checking out the sources to build
10 # the release (default is HEAD).
11 #
12 # Please note: the md(4) driver must be present in the kernel
13 # (either by being compiled in or available as a kld(4) module),
14 # otherwise the target 'release.8' and possibly others will fail.
15 #
16 # Note: If you add options to this file, please keep release(7) updated!
17 #
18 # Set these, release builder!
19 #
20 # Fixed version:
21 #BUILDNAME=6.4-STABLE
22 #
23 # Automatic SNAP versioning:
24 DATE != date +%Y%m%d
25 BASE = 6.4
26 BUILDNAME?=${BASE}-${DATE}-SNAP
27 #
28 #CHROOTDIR=/junk/release
29 # If this is a -stable snapshot, then set
30 #RELEASETAG=RELENG_6
31 #
32 # To test a release with a source tree containing patches and
33 # other work. This tree will get copied instead of getting the
34 # src/ tree from a CVS checkout. For "rerelease", this will NOT
35 # be copied; cvs update will be used instead.
36 #EXTSRCDIR=/usr/src
37 #
38 # To use a checked-out ports collection directory instead of
39 # checking out from a local CVS repository, set this option.
40 #EXTPORTSDIR=/usr/ports
41 #
42 # To add other options to the CVS subcommands (co,up), set
43 #CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
44 #
45 # To add other options to the CVS command, set
46 #CVSARGS="-lfq"
47 #
48 # To prefix the cvs command
49 #CVSPREFIX="/usr/bin/time"
50 #
51 # Where the CVS repository is
52 #CVSROOT="/home/ncvs"
53 #
54 # Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
55 # are building an official release.  Otherwise, we are building for
56 # a branch.
57 .if defined(RELEASETAG)
58 ISRELEASE!=     expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
59 .if ${ISRELEASE} != 0
60 # Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
61 AUXRELEASETAG!= echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
62 DOCRELEASETAG?=         ${AUXRELEASETAG}
63 PORTSRELEASETAG?=       ${AUXRELEASETAG}
64 .endif
65 .endif
66
67 # If you want to pass flags to the world build such as -j X, use
68 # WORLD_FLAGS.  Similarly, you can specify make flags for kernel
69 # builds via KERNEL_FLAGS.
70 #WORLD_FLAGS=-j4
71 #KERNEL_FLAGS=-j4
72
73 TARGET_ARCH?=   ${MACHINE_ARCH}
74 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
75 TARGET?=        ${MACHINE}
76 .else
77 TARGET?=        ${TARGET_ARCH}
78 .endif
79 CROSSENV=       TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
80 CROSSMAKE=      ${MAKE} ${CROSSENV}
81 NATIVEMAKE=     ${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
82
83 # If you are using a local CVS repository with components stored in 
84 # non-standard modules, override these on the make commandline or
85 # in the environment.
86 RELEASESRCMODULE?=      src
87 RELEASEDOCMODULE?=      doc
88 RELEASEPORTSMODULE?=    ports
89
90 # Uncomment this to disable the doc.1 target.  Docs normally require
91 # the ports tree, so NOPORTS can be set together with NODOC in order
92 # to have neither ports or docs.  If only NOPORTS is set to YES, but
93 # docs are still desired, the DOMINIMALDOCPORTS logic below will only
94 # install the ports that are minimally required for the docs.  This is
95 # intended as a compromise, less disk space is required than for using
96 # the entire ports collection (and much less time due to the huge number
97 # of directories it would create), but still quite a bit as well as some
98 # CPU cycles (some of the programs are C++, and things like ghostscript
99 # belong to the required ports nevertheless).
100 #
101 # Setting this also disables building of release note documentation
102 # (RELNOTESng).
103 #NODOC=  YES
104 #NOPORTS=  YES
105
106 # When retrieving ports using the pkg_add -r method, set your proxies to these.
107 # src/release/${arch}/mkisoimages.sh can use these.
108 #HTTP_PROXY?=   www.example.com
109 #FTP_PROXY?=    ftp.example.com
110
111 # When creating ISO images, point ${CD_PACKAGE_TREE} to a directory containing
112 # the package split by an earlier invocation of the 'package-split' target.
113 #CD_PACKAGE_TREE=       /path/to/pkg
114
115 # Extra source tarballs; each argument is a pair of source dir and
116 # distribution name.  The dist name should not exceed 7 characters
117 # (another "s" for "source" will be prepended).
118 #EXTRA_SRC=     games/fortune fortune
119
120 # Modify this definition if you want the release notes 
121 # and other release documentation in a language other than English.
122 RELNOTES_LANG?= en_US.ISO8859-1
123
124 # As an alternative to installing the entire ports collection (which
125 # can take a huge amount of time, in particular on slower disks),
126 # setting ${MINIMALDOCPORTS} allows to install and build just those
127 # ports that are really required for getting the docs up & running.
128 .if defined(NOPORTS) && !defined(NODOC)
129 DOMINIMALDOCPORTS=      YES
130 .include "Makefile.inc.docports"
131 RELEASEPORTSMODULE=     ${MINIMALDOCPORTS}
132 .endif
133
134 # Helper variable
135 .if defined(NOPORTS)
136 .if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
137 NOPORTSATALL=   YES
138 .endif
139 .endif
140
141 #
142 # Doing 'make index' in /usr/ports requires Perl.
143 MAKEINDEXPORTS= lang/perl5.8
144 # By default, documentation (Handbook, FAQ, etc.) is built for all
145 # the languages.  To speed up building, set the DOC_LANG to just
146 # the languages you need.  (The language for the release notes is
147 # controlled by the RELNOTES_LANG variable above.)
148 #DOC_LANG=      en_US.ISO8859-1
149 DOCPORTS=       textproc/docproj
150 # Set this to wherever the distfiles required by release procedures.
151 .if defined(DOCDISTFILES)
152 # Respect DOCDISTFILES which is used before.
153 RELEASEDISTFILES?=      ${DOCDISTFILES}
154 .else
155 RELEASEDISTFILES?=      ${.CURDIR}/../../ports/distfiles
156 .endif
157 # Set this to 1 if you want -P to be used for automatic keyboard detection
158 # on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
159 AUTO_KEYBOARD_DETECT?= 0
160
161 .if !defined(NODOC)
162 DIST_DOCS_ARCH_INDEP=   readme errata
163 DIST_DOCS_ARCH_DEP=     installation relnotes hardware
164 .endif
165
166 # Things which without too much trouble can be considered variables
167 # BASE_DISTS are special in that they get full /etc installation sets.
168 #
169 OTHER_DISTS?=   catpages manpages games proflibs dict info doc ${ARCH_DISTS}
170 BASE_DISTS?=    base
171 .if ${TARGET_ARCH} == "amd64"
172 ARCH_DISTS?=    lib32
173 .endif
174 DISTRIBUTIONS?= ${BASE_DISTS} ${OTHER_DISTS}
175
176 #
177 # Build and package both GENERIC and SMP kernels if the target
178 # has both configuration files.  Otherwise only GENERIC is done.
179 #
180 .if exists(${.CURDIR}/../sys/${TARGET}/conf/SMP)
181 KERNELS_BASE?=  GENERIC SMP
182 .else
183 KERNELS_BASE?=  GENERIC
184 .endif
185
186 # mountpoint for filesystems.
187 MNT=                    /mnt
188
189 # Various floppy image parameters.
190 #
191
192 .undef MAKE_FLOPPIES
193 .if ${TARGET_ARCH} == "i386"
194 MAKE_FLOPPIES=          true
195 .if ${TARGET} == "pc98"
196 SMALLFLOPPYSIZE=        1200
197 SMALLFLOPPYSPLITSIZE=   1152
198 SMALLFLOPPYLABEL=       fd1200
199 SPLIT_MFSROOT=
200 .endif
201 FLOPPYSIZE=             1440
202 FLOPPYSPLITSIZE=        1392
203 FLOPPYINODE=            40000
204 FLOPPYLABEL=            fd1440
205 BOOTINODE=              80000
206 MFSSIZE=                4320
207 MFSINODE=               8000
208 MFSLABEL=               minimum3
209 .elif ${TARGET_ARCH} == "alpha"
210 MAKE_FLOPPIES=          true
211 FLOPPYSIZE=             1440
212 FLOPPYSPLITSIZE=        1392
213 FLOPPYINODE=            40000
214 FLOPPYLABEL=            fd1440
215 BOOTINODE=              80000
216 MFSSIZE=                4320
217 MFSINODE=               8000
218 MFSLABEL=               auto
219 SPLIT_MFSROOT=
220 .elif ${TARGET_ARCH} == "sparc64"
221 DISKLABEL=              sunlabel
222 MFSSIZE=                4096
223 MFSINODE=               8192
224 MFSLABEL=               auto
225 MINIROOT=
226 .elif ${TARGET_ARCH} == "ia64"
227 MFSSIZE=                8192
228 MFSINODE=               8192
229 MFSLABEL=               auto
230 SEPARATE_LIVEFS=
231 .elif ${TARGET_ARCH} == "amd64"
232 MAKE_FLOPPIES=          true
233 FLOPPYSIZE=             1440
234 FLOPPYSPLITSIZE=        1392
235 FLOPPYINODE=            40000
236 FLOPPYLABEL=            fd1440
237 BOOTINODE=              80000
238 MFSSIZE=                4096
239 MFSINODE=               8192
240 MFSLABEL=               auto
241 SPLIT_MFSROOT=
242 .elif ${TARGET_ARCH} == "powerpc"
243 DISKLABEL=              ""
244 MFSSIZE=                4096
245 MFSINODE=               8192
246 MFSLABEL=               auto
247 SEPARATE_LIVEFS=
248 .endif
249 .if defined(NO_FLOPPIES)
250 .undef MAKE_FLOPPIES
251 .endif
252
253 .if exists(/sbin/bsdlabel)
254 DISKLABEL?=             bsdlabel
255 .else
256 DISKLABEL?=             disklabel
257 .endif
258
259 ZIPNSPLIT=              gzip --no-name -9 -c | split -b 1392k -
260
261 # Things which may get you into trouble if you change them
262 MTREEFILES=             ${.CURDIR}/../etc/mtree
263 _R?=                    /R
264 RD=                     ${_R}/stage
265 RND=                    ${RD}/release.doc
266 FD=                     ${_R}/ftp
267 CD=                     ${_R}/cdrom
268 CD_BOOT=                ${CD}/bootonly
269 CD_DISC1=               ${CD}/disc1
270 CD_DISC2=               ${CD}/disc2
271 CD_DISC3=               ${CD}/disc3
272 .if !defined(NODOC)
273 CD_DOCS=                ${CD}/docs
274 .endif
275 .if defined(SEPARATE_LIVEFS)
276 CD_LIVEFS=              ${CD}/livefs
277 .else
278 CD_LIVEFS=              ${CD_DISC1}
279 .endif
280 _MK?=                   ${CHROOTDIR}/mk
281
282 # Where the bootstrap ports (see DOCPORTS) get installed.
283 LOCALDIR=               /usr/local/bin
284
285 .if ${TARGET} != ${MACHINE} && ${DISKLABEL} == "bsdlabel"
286 DOFS_SH=        ${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ${TARGET}
287 .else
288 DOFS_SH=        ${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ""
289 .endif
290
291 CRUNCH_TARGETS= boot
292 .if ${TARGET_ARCH} == "i386"
293 CRUNCH_TARGETS+=fixit
294 .if ${TARGET} == "pc98"
295 CRUNCH_TARGETS+=fixit-small
296 .endif
297 .endif
298
299 .if defined(MAKE_FLOPPIES)
300 EXTRAS= floppies.1
301 .if ${TARGET_ARCH} == "i386"
302 EXTRAS+= floppies.2
303 .endif
304 EXTRAS+= floppies.3
305 .endif
306 EXTRAS+= ftp.1
307 .if !defined(NOCDROM)
308 EXTRAS+= cdrom.1 cdrom.2 cdrom.3
309 .if defined(MAKE_ISOS)
310 EXTRAS+= iso.1
311 .endif
312 .if ${TARGET} == "pc98"
313 BOOTABLE="-G"
314 .else
315 BOOTABLE="-b"
316 .endif
317 .endif
318
319 .if !defined(NODOC)
320 DOCREL= doc.1 doc.2
321 .endif
322
323 .if !make(release) && !make(rerelease) && !make(package-split)
324 BINMAKE!=       cd ${.CURDIR}/..; ${MAKE} -V BINMAKE
325 WMAKEENV!=      cd ${.CURDIR}/..; \
326                 ${BINMAKE} ${CROSSENV} -f Makefile.inc1 -V WMAKEENV
327 WMAKE=          ${WMAKEENV} ${BINMAKE}
328 .endif
329
330 CVS_SRCARGS=    -P
331 .if defined(RELEASETAG)
332 CVS_SRCARGS+=   -r ${RELEASETAG}
333 .endif
334
335 CVS_DOCARGS=    -P
336 .if defined(DOCRELEASETAG)
337 CVS_DOCARGS+=   -r ${DOCRELEASETAG}
338 .endif
339
340 CVS_PORTSARGS=  -P
341 .if defined(PORTSRELEASETAG)
342 CVS_PORTSARGS+= -r ${PORTSRELEASETAG}
343 .endif
344
345 WORLDDIR?=      ${.CURDIR}/..
346
347 release rerelease:
348 .if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
349         @echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
350 .endif
351 .if defined(NOPORTSATALL) && !defined(NODOC)
352         @echo "Ports are required for building the docs.  Either set NODOC or"
353         @echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
354         @exit 1
355 .endif
356 .if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
357 .for p in ${LOCAL_PATCHES}
358 .if !exists(${p})
359         @echo "The patch file ${p} does not exist!"
360         @exit 1
361 .endif
362 .endfor
363 .endif
364 .if defined(LOCAL_SCRIPT) && !exists(${LOCAL_SCRIPT})
365         @echo "The local script ${LOCAL_SCRIPT} does not exist!"
366         @exit 1
367 .endif
368 .if make(release)
369 .if exists(${CHROOTDIR})
370 # The first command will fail on a handful of files that have their schg
371 # flags set.  But it greatly speeds up the next two commands.
372         # NB: clear any vestigial devfs mount, just in case
373         -umount ${CHROOTDIR}/dev > /dev/null 2>&1
374         -rm -rf ${CHROOTDIR} 2>/dev/null
375         -chflags -R 0 ${CHROOTDIR}/.
376         -rm -rf ${CHROOTDIR}
377 .endif
378         mkdir -p ${CHROOTDIR}
379         @echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
380         cd ${WORLDDIR} && ${NATIVEMAKE} -DNO_GAMES -DNO_HTML -DNO_INFO \
381             -DNO_LIB32 -DNO_MAN -DNO_NLS -DNO_PROFILE installworld \
382             DESTDIR=${CHROOTDIR}
383         cd ${WORLDDIR} && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
384         if [ -f /etc/resolv.conf ]; then \
385                 cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
386         fi
387 .if defined(EXTLOCALDIR)
388         rm -rf ${CHROOTDIR}/usr/local
389         cd ${CHROOTDIR}/usr && cp -R -H ${EXTLOCALDIR} local
390 .endif
391         rm -rf ${CHROOTDIR}/usr/src
392 .if defined(EXTSRCDIR)
393         cd ${CHROOTDIR}/usr && \
394             cp -R -H ${EXTSRCDIR} src
395 .else
396         cd ${CHROOTDIR}/usr && \
397             ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
398             co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
399 .endif
400 .if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
401 .for p in ${LOCAL_PATCHES}
402         patch -d ${CHROOTDIR}/usr/${RELEASESRCMODULE} ${PATCH_FLAGS} < ${p}
403 .endfor
404 .endif
405 .if defined(LOCAL_SCRIPT)
406         cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} \
407             RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
408 .endif
409         rm -rf ${CHROOTDIR}/usr/ports
410 .if !defined(NOPORTSATALL)
411 .if defined(EXTPORTSDIR)
412         cd ${CHROOTDIR}/usr && cp -R -H ${EXTPORTSDIR} ports
413         # If there are distfiles downloaded removing them
414         rm -rf ports/distfiles/*
415 .else
416         cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
417             co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
418 .endif
419 .endif
420 .if !defined(NODOC)
421         rm -rf ${CHROOTDIR}/usr/doc
422 .if defined(EXTDOCDIR)
423         cd ${CHROOTDIR}/usr && cp -R -H ${EXTDOCDIR} doc
424 .else
425         cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
426             co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
427 .endif
428         if [ -d ${RELEASEDISTFILES}/ ]; then \
429                 cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
430         else \
431                 mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
432         fi
433 .if !defined(NO_PREFETCHDISTFILES)
434         @cd ${.CURDIR} && ${MAKE} fetch-distfiles
435 .endif
436 .endif
437 .endif
438 .if make(rerelease)
439 .if !defined(RELEASENOUPDATE)
440 .if !defined(RELEASETAG)
441         cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
442             update ${CVSCMDARGS} -P -d -A
443 .else
444         cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
445             update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
446 .endif
447         rm -f ${CHROOTDIR}/tmp/.world_done 
448 .if !defined(NOPORTS) && !defined(EXTPORTSDIR)
449         cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
450             update ${CVSCMDARGS} -P -d
451         rm -f ${CHROOTDIR}/tmp/.skip_ports_index
452 .endif
453 .if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
454         for i in ${MINIMALDOCPORTS}; do \
455             ( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
456                 update ${CVSCMDARGS} -P -d ) ; \
457         done
458 .endif
459 .if !defined(NODOC)
460         cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
461             update ${CVSCMDARGS} -P -d
462 .endif
463 .endif
464 .endif
465         # Add version information to those things that need it.
466         if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
467                 cd ${CHROOTDIR}/usr/src/sys/conf && \
468                 mv newvers.sh foo && \
469                 sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && \
470                 rm foo; \
471         fi
472         -test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
473         echo "#!/bin/sh"                        > ${_MK}
474         echo "set -ex"                          >> ${_MK}
475         echo "trap 'umount /dev || true' 0"     >> ${_MK}
476         echo "_RELTARGET=\$${1:-doRELEASE}"     >> ${_MK}
477 .for var in \
478         AUTO_KEYBOARD_DETECT \
479         BUILDNAME \
480         CD_PACKAGE_TREE \
481         DISTRIBUTIONS \
482         DOC_LANG \
483         DOMINIMALDOCPORTS \
484         EXTRA_SRC \
485         FTP_PASSIVE_MODE \
486         FTP_PROXY \
487         HTTP_PROXY \
488         KERNELS \
489         KERNELS_BASE \
490         KERNEL_FLAGS \
491         MAKE_FLOPPIES \
492         MAKE_ISOS \
493         NOCDROM \
494         NODOC \
495         NOPORTS \
496         NO_SHARED \
497         NOSRC \
498         NO_CPU_CFLAGS \
499         NO_CPU_COPTFLAGS \
500         NO_FLOPPIES \
501         NO_SENDMAIL \
502         RELEASETAG \
503         RELNOTES_LANG \
504         SEPARATE_LIVEFS \
505         TARGET \
506         TARGET_ARCH \
507         WORLD_FLAGS
508 .if defined(${var})
509         echo "export ${var}=\"${${var}}\""      >> ${_MK}
510 .endif
511 .endfor
512         # Don't remove this, or the build will fall over!
513         echo "export RELEASEDIR=${_R}"          >> ${_MK}
514         echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"    >> ${_MK}
515         echo "export MANBUILDCAT=YES"           >> ${_MK}
516         # NB: these may fail if the host is running w/o devfs
517         echo "umount /dev >/dev/null 2>&1 || true" >> ${_MK}
518         echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true"        >> ${_MK}
519         echo "if [ -x /etc/rc.d/ldconfig ]; then" >> ${_MK}
520         echo "  /etc/rc.d/ldconfig start"       >> ${_MK}
521         echo "else"                             >> ${_MK}
522         echo "  ldconfig /lib /usr/lib /usr/local/lib || true" >> ${_MK}
523         echo "fi"                               >> ${_MK}
524         echo "if [ ! -f /tmp/.world_done ]; then" >> ${_MK}
525         echo "  cd /usr/src"                    >> ${_MK}
526         echo "  ${CROSSMAKE} ${WORLD_FLAGS} -DNO_CLEAN buildworld && \\" >> ${_MK}
527         echo "  touch /tmp/.world_done || exit 1" >> ${_MK}
528         echo "fi"                               >> ${_MK}
529         echo "if [ ! -f /tmp/.skip_ports_index ]; then" >> ${_MK}
530         echo "  echo \">>> make index started on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
531         echo "  for i in ${MAKEINDEXPORTS}"     >> ${_MK}
532         echo "  do"                     >> ${_MK}
533         echo "          cd /usr/ports/\$${i}"   >> ${_MK}
534         echo "          env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \\" >> ${_MK}
535         echo "          make all install clean BATCH=yes FORCE_PKG_REGISTER=yes" >> ${_MK}
536         echo "  done"                           >> ${_MK}
537         echo "  cd /usr/ports"                  >> ${_MK}
538         echo "  rm -f INDEX*"                   >> ${_MK}
539         echo "  make index -DINDEX_PRISTINE"    >> ${_MK}
540         echo "  rm -f INDEX*.tmp"               >> ${_MK}
541         echo "  touch /tmp/.skip_ports_index"   >> ${_MK}
542         echo "  echo \">>> make index finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
543         echo "fi"                               >> ${_MK}
544         echo "cd /usr/src/release"              >> ${_MK}
545         echo "make obj"                         >> ${_MK}
546         echo "make \$${_RELTARGET}"             >> ${_MK}
547         echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
548         chmod 755 ${_MK}
549 .if defined(NOPORTS)
550         touch ${CHROOTDIR}/tmp/.skip_ports_index
551 .endif
552         # Ensure md.ko is loaded if md(4) is not statically compiled into 
553         # the kernel
554         -mdconfig 2>/dev/null
555         env -i /usr/sbin/chroot `dirname ${_MK}` /`basename ${_MK}`
556
557 clean:
558         rm -rf ${CRUNCH_TARGETS:S/$/_crunch/} release.[0-8] ${EXTRAS}
559
560 fetch-distfiles:
561         @for i in ${MAKEINDEXPORTS}; do \
562                 cd ${CHROOTDIR}/usr/ports/$$i && \
563                         make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
564                         checksum-recursive ; \
565         done
566         @for i in ${DOCPORTS}; do \
567                 cd ${CHROOTDIR}/usr/ports/$$i && \
568                         make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
569                         WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
570                         checksum-recursive ; \
571         done
572
573 # Clean out ${_R} and make the directory structure.
574 release.1:
575         mkdir -p ${_R}
576         -rm -rf ${_R}/* 2> /dev/null
577         -chflags -R noschg ${_R}/.
578         rm -rf ${_R}/*
579         mkdir ${RD}
580 .if defined(MAKE_FLOPPIES)
581         mkdir ${RD}/floppies
582 .endif
583         mkdir ${RD}/trees
584         for i in ${DISTRIBUTIONS}; do \
585                 mkdir ${RD}/trees/$$i && \
586                 mtree -deU -f ${MTREEFILES}/BSD.root.dist \
587                     -p ${RD}/trees/$$i > /dev/null && \
588                 mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
589                     -p ${RD}/trees/$$i/usr > /dev/null && \
590                 mtree -deU -f ${MTREEFILES}/BSD.include.dist \
591                     -p ${RD}/trees/$$i/usr/include > /dev/null && \
592                 mtree -deU -f ${MTREEFILES}/BSD.var.dist \
593                     -p ${RD}/trees/$$i/var > /dev/null ; \
594         done
595         mkdir ${RD}/kernels
596         for i in ${KERNELS_BASE} ${KERNELS}; do \
597                 mkdir -p ${RD}/kernels/$${i}; \
598         done
599         touch ${.TARGET}
600
601 # Install the system into the various distributions.
602 release.2:
603         cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
604         cd ${.CURDIR}/.. && ${CROSSMAKE} ${WORLD_FLAGS} distributeworld \
605             DISTDIR=${RD}/trees
606         touch ${.TARGET}
607
608 # Make and install the generic kernel(s).
609 release.3:
610 .for kernel in ${KERNELS_BASE} ${KERNELS}
611         cd ${.CURDIR}/..; \
612         ${CROSSMAKE} ${KERNEL_FLAGS} \
613             KERNCONF=${kernel} kernel \
614             DESTDIR=${RD}/kernels KODIR=/${kernel}
615 .endfor
616         touch ${.TARGET}
617
618 # Make and install the three crunched binaries which live on the floppies.
619 # You are not supposed to like this :-)
620 release.4:
621         rm -rf ${RD}/crunch
622         mkdir -p ${RD}/crunch
623 .for j in ${CRUNCH_TARGETS}
624 .if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
625         rm -rf ${j}_crunch
626         mkdir ${j}_crunch
627         cd ${j}_crunch; ${WMAKEENV} crunchgen -o \
628             ${.CURDIR}/${TARGET}/${j}_crunch.conf
629         cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
630         cd ${.CURDIR}/..; ${BINMAKE} -f Makefile.inc1 _build-tools
631         cd ${j}_crunch; CFLAGS="-Os -pipe" ${WMAKE} -f ${j}_crunch.mk \
632             -DNO_CPU_CFLAGS all
633         ${WMAKEENV} strip -R .comment ${j}_crunch/${j}_crunch
634         mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
635 .endif
636 .endfor
637         touch ${.TARGET}
638
639 #
640 # --==## Fix up the distributions. ##==--
641 #
642 release.5:
643         # Create any "synthetic dists" now.
644         @for i in ${DISTRIBUTIONS}; do \
645                 if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
646                         echo -n "Running $$i dist creation script... "; \
647                         env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
648                         echo "Done."; \
649                 fi \
650         done \
651
652         # Remove all the directories we don't need.
653         -cd ${RD}/trees && \
654                 (find ${OTHER_DISTS} -path '*/var/empty' | xargs chflags noschg; \
655                 find ${OTHER_DISTS} -depth -type d -print | xargs rmdir)
656         touch ${.TARGET}
657
658 #
659 # --==## Package up the tarballs from assembled trees ##==--
660 #
661 release.6:
662         rm -rf ${RD}/dists
663         mkdir -p ${RD}/dists
664         @for i in ${DISTRIBUTIONS} ; \
665         do \
666                 if [ -d ${RD}/trees/$${i} ] ; then \
667                         cd ${.CURDIR} && $(MAKE) doTARBALL \
668                                 SD=${RD}/trees/$${i} \
669                                 TN=$$i TD=$$i ARG="." && \
670                         echo "$${i} distribution is finished."; \
671                 fi ; \
672         done
673         @for i in ${KERNELS_BASE} ${KERNELS} ; \
674         do \
675                 if [ -d ${RD}/kernels/$${i} ] ; then \
676                         cd ${.CURDIR} && $(MAKE) doTARBALL \
677                                 SD=${RD}/kernels \
678                                 TN=$$i TD=kernels ARG="$$i" && \
679                         echo "$${i} distribution is finished."; \
680                 fi ; \
681         done
682 .if !defined(NOPORTS)
683         # XXX: Inline stripped version of doTARBALL
684         @rm -rf ${RD}/dists/ports/ports*
685         @mkdir -p ${RD}/dists/ports
686         @echo rolling ports/ports tarball
687         @tar --exclude CVS --exclude 'ports/distfiles/*' \
688           -czf ${RD}/dists/ports/ports.tgz -C /usr ports
689         @cp ${.CURDIR}/scripts/ports-install.sh ${RD}/dists/ports/install.sh
690         @(cd ${RD}/dists/ports; \
691           rm -f CHECKSUM.MD5 CHECKSUM.SHA256; \
692           md5 * > .CHECKSUM.MD5; \
693           sha256 * > .CHECKSUM.SHA256; \
694           mv .CHECKSUM.MD5 CHECKSUM.MD5; \
695           mv .CHECKSUM.SHA256 CHECKSUM.SHA256)
696         @echo "ports distribution is finished."
697 .endif
698         touch ${.TARGET}
699
700
701 #
702 # --==## Make source dists ##==--
703 #
704 release.7:
705 .if !defined(NOSRC)
706         @cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
707                 TD=src TN=sbase ARG="[A-Z]*"
708         @for i in `cd /usr/src && echo [a-z]*` ; do \
709                 if [ -d /usr/src/$$i ] ; then \
710                         cd ${.CURDIR} && $(MAKE) doTARBALL \
711                                 TN=`echo s$$i | tr -d '.' | \
712                                     sed -e 's/usr/u/' \
713                                         -e 's/kerberos5/krb5/'` \
714                                 SD=/usr/src TD=src ARG="$$i" ; \
715                 fi ; \
716         done
717 .if defined(EXTRA_SRC)
718         @set ${EXTRA_SRC} && \
719         while [ $$# -ge 2 ] ; do \
720                 if [ -d /usr/src/$$1 ] ; then \
721                         cd ${.CURDIR} && $(MAKE) doTARBALL \
722                                 SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
723                 fi && shift && shift ; \
724         done
725 .endif
726         (cd ${RD}/dists/src; \
727           rm -f CHECKSUM.MD5 CHECKSUM.SHA256; \
728           md5 * > .CHECKSUM.MD5; \
729           sha256 * > .CHECKSUM.SHA256; \
730           mv .CHECKSUM.MD5 CHECKSUM.MD5; \
731           mv .CHECKSUM.SHA256 CHECKSUM.SHA256)
732         @echo "src distribution is finished."
733 .endif
734         touch ${.TARGET}
735
736 # Build the memory root filesystem.
737 release.8:
738         cp ${RD}/trees/base/etc/disktab /etc
739         rm -rf ${RD}/mfsfd
740         mkdir ${RD}/mfsfd
741         cd ${RD}/mfsfd && \
742                 mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help \
743                 var/empty
744         @cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
745                 DIR=${RD}/mfsfd/stand ZIP=false
746         ( cd ${RD}/mfsfd && \
747           for dir in bin sbin ; do \
748                 ln -sf /stand $$dir; \
749           done )
750         cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
751 .if ${TARGET} == "pc98"
752         cp ${.CURDIR}/../etc/defaults/pccard.conf \
753             ${RD}/mfsfd/etc/defaults/pccard.conf
754 .endif
755         cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
756         cp ${.CURDIR}/../etc/master.passwd ${RD}/mfsfd/etc/master.passwd
757         cp ${RD}/trees/base/etc/*pwd.db ${RD}/mfsfd/etc/
758         ( for F in defaults/rc.conf netconfig protocols ; do \
759                 sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
760                 ${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
761           done )
762         grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
763             ${RD}/trees/base/etc/services | \
764             sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
765             > ${RD}/mfsfd/stand/etc/services
766         grep 'operator' ${RD}/trees/base/etc/group \
767             > ${RD}/mfsfd/stand/etc/group
768         ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
769         ln ${RD}/mfsfd/stand/etc/group ${RD}/mfsfd/etc/group
770         ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
771         cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
772 .if !defined(NODOC)
773         @for i in ${DIST_DOCS_ARCH_INDEP}; do \
774           cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
775               ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
776         done
777         @for i in ${DIST_DOCS_ARCH_DEP}; do \
778           cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
779               ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
780         done
781         @mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT \
782             ${RD}/mfsfd/stand/help/INSTALL.TXT
783 .endif
784         -test -f ${.CURDIR}/install.cfg \
785             && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
786         @mkdir -p ${RD}/mfsfd/boot
787 .if ${TARGET_ARCH} != "ia64" && ${TARGET_ARCH} != "powerpc"
788         @cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
789 .endif
790 .if ${TARGET} == "i386" || ${TARGET_ARCH} == "amd64"
791         @cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
792 .endif
793         @tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
794                 tar xf - -C ${RD}/mfsfd/stand
795         @mkdir -p ${RD}/mfsroot
796         sh -e ${DOFS_SH} ${RD}/mfsroot/mfsroot ${RD} ${MNT} \
797             ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
798         @gzip -9fnv ${RD}/mfsroot/mfsroot
799         touch ${.TARGET}
800
801 KERNFLOPPYSET=          ${RD}/floppyset/kern/kernel.gz
802 .if defined(SMALLFLOPPYSIZE)
803 SMALLKERNFLOPPYSET=     ${RD}/floppyset/kern-small/kernel.gz
804 .endif
805 .if defined(SPLIT_MFSROOT)
806 MFSROOTFLOPPYSET=       ${RD}/floppyset/mfsroot/mfsroot.gz
807 .if defined(SMALLFLOPPYSIZE)
808 SMALLMFSROOTFLOPPYSET=  ${RD}/floppyset/mfsroot-small/mfsroot.gz
809 .endif
810 .endif
811
812 # Build boot and install floppies.
813 floppies.1:
814         @gzip -9nc ${RD}/kernels/GENERIC/kernel > ${RD}/kernels/kernel.gz
815         @echo "Making the kernel boot floppies..."
816         @cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern \
817             FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz
818 .if defined(SMALLFLOPPYSIZE)
819         @echo "Making the small kernel boot floppies..."
820         @cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern-small \
821             FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz \
822             FDSIZE="SMALL"
823 .endif
824 .if defined(SPLIT_MFSROOT)
825         @echo "Making the mfsroot boot floppies..."
826         @cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot \
827             FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz
828 .if defined(SMALLFLOPPYSIZE)
829         @echo "Making the small mfsroot boot floppies..."
830         @cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot-small \
831             FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz \
832             FDSIZE="SMALL"
833 .endif
834         @cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
835             KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
836             MFSROOTFILE="${MFSROOTFLOPPYSET}.split ${MFSROOTFLOPPYSET}.boot"
837 .if defined(SMALLFLOPPYSIZE)
838         @cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
839             KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
840             MFSROOTFILE="${SMALLMFSROOTFLOPPYSET}.split ${SMALLMFSROOTFLOPPYSET}.boot" \
841             FDSIZE="SMALL"
842 .endif
843 .else   # !SPLIT_MFSROOT
844         @cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
845             KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
846             MFSROOTFILE=${RD}/mfsroot/mfsroot.gz
847 .if defined(SMALLFLOPPYSIZE)
848         @cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
849             KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
850             MFSROOTFILE=${RD}/mfsroot/mfsroot.gz \
851             FDSIZE="SMALL"
852 .endif
853 .endif  # SPLIT_MFSROOT
854         touch ${.TARGET}
855
856 # Build fixit floppy.
857 floppies.2:
858         @echo "Making fixit floppy."
859         @rm -rf ${RD}/fixitfd
860         @mkdir ${RD}/fixitfd
861         @cd ${RD}/fixitfd && \
862             mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
863             usr/share/misc
864         @cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
865             ${RD}/fixitfd/etc
866         @sed -e 's/#.*//' ${RD}/trees/base/etc/protocols \
867             > ${RD}/fixitfd/etc/protocols
868         @sed -e 's/#.*//' ${RD}/trees/base/usr/share/misc/scsi_modes \
869             > ${RD}/fixitfd/usr/share/misc/scsi_modes
870         @cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
871         @cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
872         @cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
873         @chmod 555 ${RD}/fixitfd/stand/tar
874 .if defined(SMALLFLOPPYSIZE)
875         @cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit-small \
876             DIR=${RD}/fixitfd/stand ZIP=false
877         @sh -e ${DOFS_SH} ${RD}/floppies/fixit-small.flp ${RD} ${MNT} \
878             ${SMALLFLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${SMALLFLOPPYLABEL}
879         @rm -rf ${RD}/fixitfd/stand
880         @mkdir ${RD}/fixitfd/stand
881 .endif
882         @cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
883             DIR=${RD}/fixitfd/stand ZIP=false
884         @sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} ${MNT} \
885             ${FLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${FLOPPYLABEL}
886         touch ${.TARGET}
887
888 # Do our last minute floppies directory setup
889 floppies.3:
890 .if !defined(NODOC)
891         @cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
892             ${RD}/floppies/README.TXT
893         @(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
894         @(cd ${RD}/floppies; sha256 README.TXT *.flp > CHECKSUM.SHA256)
895 .else
896         @(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
897         @(cd ${RD}/floppies; sha256 *.flp > CHECKSUM.SHA256)
898 .endif
899         touch ${.TARGET}
900
901 #
902 # --==## Setup a suitable ftp-area ##==--
903 #
904 ftp.1:
905         @echo "Setting up FTP distribution area"
906         @mkdir -p ${FD}
907         -@ln -s . ${FD}/${BUILDNAME}
908 .if defined(MAKE_FLOPPIES)
909         @cd ${RD} && find floppies -print | cpio -dumpl ${FD}
910 .endif
911         @cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
912 .if !defined(NODOC)
913         @for i in ${DIST_DOCS_ARCH_INDEP}; do \
914                 cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
915                     ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
916                 cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
917                     ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
918         done
919         @for i in ${DIST_DOCS_ARCH_DEP}; do \
920                 cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
921                     ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
922                 cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
923                     ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
924         done
925         @cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
926         @mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
927         @mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
928 .endif
929         @echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
930         touch ${.TARGET}
931
932 # Build a live filesystem cdrom image
933 cdrom.1:
934         @echo "Building CDROM live filesystem image"
935         @mkdir -p ${CD_LIVEFS}
936         @for i in ${DISTRIBUTIONS} ; \
937         do \
938                 if [ -d ${RD}/trees/$${i} ] ; then \
939                         chflags -R noschg ${RD}/trees/$${i} || true ; \
940                         ( cd ${RD}/trees/$${i} && \
941                             find . -depth -print | cpio -dumpl ${CD_LIVEFS} ) ; \
942                 fi \
943         done
944         @echo "Copy GENERIC kernel to boot area"
945         @cp -Rp ${RD}/kernels/GENERIC/ ${CD_LIVEFS}/boot/kernel
946         @rm -f ${CD_LIVEFS}/.profile
947         @cp ${.CURDIR}/fixit.profile ${CD_LIVEFS}/.profile
948         @ln -sf /rescue ${CD_LIVEFS}/stand
949         @echo "Setting up CDROM boot area"
950         @rm -f ${CD_LIVEFS}/boot/loader.conf
951         @cp ${RD}/mfsroot/mfsroot.gz ${CD_LIVEFS}/boot/mfsroot.gz
952         @echo 'mfsroot_load="YES"' > ${CD_LIVEFS}/boot/loader.conf
953         @echo 'mfsroot_type="mfs_root"' >> ${CD_LIVEFS}/boot/loader.conf
954         @echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_LIVEFS}/boot/loader.conf
955 .if exists(${RD}/trees/base/boot/device.hints)
956         # Break the link to device.hints so we can modify it
957         @rm -f ${CD_LIVEFS}/boot/device.hints
958         @cp ${RD}/trees/base/boot/device.hints ${CD_LIVEFS}/boot/device.hints
959 .endif
960         @echo "CD_VERSION = ${BUILDNAME}" > ${CD_LIVEFS}/cdrom.inf
961         touch ${.TARGET}
962
963 # Build disc1, disc2 and disc3 cdrom images
964 cdrom.2:
965         @echo "Building CDROM disc1 filesystem image"
966         @mkdir -p ${CD_DISC1}/${BUILDNAME}
967 .if defined(MAKE_FLOPPIES)
968         @cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
969 .endif
970         @cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}/${BUILDNAME}
971 .if !defined(NODOC)
972         @for i in ${DIST_DOCS_ARCH_INDEP}; do \
973           cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
974               ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
975           cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
976               ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
977         done
978         @for i in ${DIST_DOCS_ARCH_DEP}; do \
979           cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
980               ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
981           cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
982               ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
983         done
984         @cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
985         @mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
986         @mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
987 .endif
988 .if defined(SEPARATE_LIVEFS)
989         @cp -Rp ${CD_LIVEFS}/boot ${CD_DISC1}
990         @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
991 .endif
992         @echo "CD_VOLUME = 1" >> ${CD_DISC1}/cdrom.inf
993         @echo "Building CDROM disc2 filesystem image"
994         @mkdir -p ${CD_DISC2}
995         @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
996         @echo "CD_VOLUME = 2" >> ${CD_DISC2}/cdrom.inf
997         @echo "Building CDROM disc3 filesystem image"
998         @mkdir -p ${CD_DISC3}
999         @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC3}/cdrom.inf
1000         @echo "CD_VOLUME = 3" >> ${CD_DISC3}/cdrom.inf
1001 .if !defined(NODOC)
1002         @echo "Building CDROM docs filesystem image"
1003         @mkdir -p ${CD_DOCS}
1004         @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DOCS}/cdrom.inf
1005         @mkdir -p ${CD_DOCS}/usr/share/doc
1006         @for i in `ls ${CD_LIVEFS}/usr/share/doc`; do \
1007                 if [ -L ${CD_LIVEFS}/usr/share/doc/$$i -o \
1008                     -d /usr/doc/$$i ]; then \
1009                         mv ${CD_LIVEFS}/usr/share/doc/$$i \
1010                             ${CD_DOCS}/usr/share/doc; \
1011                 fi \
1012         done
1013 .endif
1014         touch ${.TARGET}
1015
1016 #
1017 # --==## Setup a suitable cdrom-area ##==--
1018 #
1019 cdrom.3:
1020 .if defined(CD_BOOT)
1021         @echo "Building bootonly CDROM filesystem image"
1022         @mkdir -p ${CD_BOOT}
1023         @cp -Rp ${CD_LIVEFS}/boot ${CD_BOOT}
1024         @echo "CD_VERSION = ${BUILDNAME}" > ${CD_BOOT}/cdrom.inf
1025 .if defined(MINIROOT)
1026         @echo "Building bootonly UFS filesystem image"
1027         @mkdir -p ${FD}/miniroot
1028         @sh -e ${DOFS_SH} ${FD}/miniroot/miniroot.ufs \
1029             ${RD} ${MNT} 0 ${CD_BOOT} 8192 auto
1030         @gzip -9v ${FD}/miniroot/miniroot.ufs
1031 .endif
1032 .endif
1033         touch ${.TARGET}
1034
1035 .if make(iso.1)
1036 .if defined(CD_PACKAGE_TREE)
1037 .if exists(${CD_PACKAGE_TREE}/disc1)
1038 CD_DISC1_PKGS=  ${CD_PACKAGE_TREE}/disc1
1039 .endif
1040 .if exists(${CD_PACKAGE_TREE}/disc2)
1041 CD_DISC2_PKGS=  ${CD_PACKAGE_TREE}/disc2
1042 .endif
1043 .if exists(${CD_PACKAGE_TREE}/disc3)
1044 CD_DISC3_PKGS=  ${CD_PACKAGE_TREE}/disc3
1045 .endif
1046 .endif
1047 .endif
1048
1049 iso.1:
1050 .if exists(${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh)
1051         @echo "Creating ISO images..."
1052 .if defined(CD_BOOT)
1053         @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
1054             FreeBSD_bootonly \
1055             ${CD}/${BUILDNAME}-${TARGET}-bootonly.iso ${CD_BOOT}
1056 .endif
1057         @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
1058             FreeBSD_Install \
1059             ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} \
1060             ${CD_DISC1_PKGS}
1061         @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh \
1062             FreeBSD_Packages \
1063             ${CD}/${BUILDNAME}-${TARGET}-disc2.iso ${CD_DISC2} \
1064             ${CD_DISC2_PKGS}
1065         @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh \
1066             FreeBSD_Packages_2 \
1067             ${CD}/${BUILDNAME}-${TARGET}-disc3.iso ${CD_DISC3} \
1068             ${CD_DISC3_PKGS}
1069 .if !defined(NODOC)
1070         @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh \
1071             FreeBSD_Documentation \
1072             ${CD}/${BUILDNAME}-${TARGET}-docs.iso ${CD_DOCS}
1073 .endif
1074 .if defined(SEPARATE_LIVEFS)
1075         @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
1076             FreeBSD_LiveFS \
1077             ${CD}/${BUILDNAME}-${TARGET}-livefs.iso ${CD_LIVEFS}
1078 .endif
1079         @echo "Generating MD5 and SHA256 sums..."
1080         @(cd ${CD} && md5 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.MD5)
1081         @(cd ${CD} && sha256 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.SHA256)
1082         touch ${.TARGET}
1083 .else
1084         @echo "Do not know how to create an ISO for ${TARGET_ARCH}."
1085 .endif
1086
1087 #
1088 # --==## Documentation Project files such as the Handbook and FAQ ##==--
1089 #
1090 doc.1:
1091         @echo "Making docs..."
1092         @for i in ${DOCPORTS}; do \
1093             cd /usr/ports/$$i && \
1094             env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \
1095                 make all install clean BATCH=yes WITHOUT_X11=yes JADETEX=no \
1096                 WITHOUT_PYTHON=yes FORCE_PKG_REGISTER=yes; \
1097         done
1098         @cd /usr/doc && make all install 'FORMATS=html html-split txt' \
1099             INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc \
1100             URLS_ABSOLUTE=YES   
1101         touch ${.TARGET}
1102
1103 #
1104 # --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
1105 #
1106 doc.2:
1107         @echo "Making release documentation..."
1108         @cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' \
1109             INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${RND}
1110         touch ${.TARGET}
1111
1112 # Various "subroutine" and other supporting targets.
1113
1114 # RD=
1115 # SD=
1116 # TD=
1117 # ARG=
1118 doTARBALL:
1119 .if !defined(SD)
1120         @echo "SD undefined in doTARBALL" && exit 1
1121 .endif
1122 .if !defined(TD)
1123         @echo "TD undefined in doTARBALL" && exit 1
1124 .endif
1125 .if !defined(ARG)
1126         @echo "ARG undefined in doTARBALL" && exit 1
1127 .endif
1128         @rm -rf ${RD}/dists/${TD}/${TN}*
1129         @mkdir -p ${RD}/dists/${TD}
1130         @( cd ${SD} && \
1131                 tn=`echo ${TN} | tr 'A-Z' 'a-z'` && \
1132                 echo rolling ${TD}/$$tn tarball &&\
1133                 tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
1134                 ${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
1135                 sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn \
1136                     > ${RD}/dists/${TD}/$$tn.inf && \
1137                 if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
1138                         cp -p ${.CURDIR}/scripts/$${TD}-install.sh \
1139                             ${RD}/dists/${TD}/install.sh && \
1140                         chmod +x ${RD}/dists/${TD}/install.sh; \
1141                 fi && \
1142                 if [ "${SD}" != "/usr/src" ]; then \
1143                         mtree -c -i -p ${SD}/${ARG} \
1144                           -k gname,md5digest,mode,nlink,uname,size,link,type \
1145                           > ${RD}/dists/${TD}/$$tn.mtree ; \
1146                 else \
1147                         true; \
1148                 fi; \
1149                 ( cd ${RD}/dists/${TD}; \
1150                 rm -f CHECKSUM.MD5 CHECKSUM.SHA256; \
1151                 md5 * > .CHECKSUM.MD5; \
1152                 sha256 * > .CHECKSUM.SHA256; \
1153                 mv .CHECKSUM.MD5 CHECKSUM.MD5; \
1154                 mv .CHECKSUM.SHA256 CHECKSUM.SHA256) \
1155         )
1156
1157 doRELEASE: release.1 release.2 ${DOCREL} release.3 release.4 \
1158     release.5 release.6 release.7 release.8 ${EXTRAS}
1159         @echo "Release done"
1160
1161 floppies:
1162         @rm -f release.4 release.8 floppies.[123]
1163         @cd ${.CURDIR} && ${MAKE} release.4 release.8 floppies.1 floppies.2 \
1164             floppies.3
1165         @cd ${RD} && find floppies -print | cpio -dumpl ${FD}
1166
1167 installCRUNCH:
1168 .if !defined(CRUNCH)
1169         @echo "CRUNCH undefined in installCRUNCH" && exit 1
1170 .endif
1171 .if !defined(DIR)
1172         @echo "DIR undefined in installCRUNCH" && exit 1
1173 .endif
1174 .if !defined(ZIP)
1175         @echo "ZIP undefined in installCRUNCH" && exit 1
1176 .endif
1177         @if ${ZIP} ; then \
1178                 gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
1179         else \
1180                 ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
1181         fi
1182         @chmod 555 ${DIR}/${CRUNCH}_crunch
1183         @if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
1184                 for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
1185                         ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1186                 done \
1187         else \
1188                 for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
1189                         ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1190                 done \
1191         fi
1192
1193 #
1194 # --==## Build a floppy set for a splitfs file ##==--
1195 #
1196 # FLOPPYBASE - basename of floppy image files
1197 # FLOPPYDESC - description of floppy set
1198 # SPLITFILE - filename of the file to split
1199 # FDSIZE - if specified and "small", small floppy is created
1200
1201 .if make(makeFloppySet)
1202 SPLITDIR=       ${RD}/floppyset/${FLOPPYBASE}
1203 .if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1204 FLPSPLITSIZE=   ${SMALLFLOPPYSPLITSIZE}
1205 FLPSIZE=        ${SMALLFLOPPYSIZE}
1206 FLPLABEL=       ${SMALLFLOPPYLABEL}
1207 .else
1208 FLPSPLITSIZE=   ${FLOPPYSPLITSIZE}
1209 FLPSIZE=        ${FLOPPYSIZE}
1210 FLPLABEL=       ${FLOPPYLABEL}
1211 .endif
1212 .endif
1213
1214 makeFloppySet:
1215 .if !defined(FLOPPYBASE)
1216         @echo "FLOPPYBASE undefined in ${.TARGET}" && exit 1
1217 .endif
1218 .if !defined(FLOPPYDESC)
1219         @echo "FLOPPYDESC undefined in ${.TARGET}" && exit 1
1220 .endif
1221 .if !defined(SPLITFILE)
1222         @echo "SPLITFILE undefined in ${.TARGET}" && exit 1
1223 .endif
1224         sh ${.CURDIR}/scripts/split-file.sh ${SPLITFILE} \
1225             ${RD}/floppyset/${FLOPPYBASE} ${FLPSPLITSIZE} "${FLOPPYDESC}"
1226         ( splitfile=${SPLITDIR}/`basename ${SPLITFILE}`.split ; \
1227         lines=`cat $${splitfile} | wc -l`; \
1228         lines=$$(($$lines - 1)) ; \
1229         for line in `jot $$lines`; do \
1230                 file=`head -n $$(($${line} + 1)) $${splitfile} | tail -1 | cut -f 1 -d ' '` ; \
1231                 sh -e ${DOFS_SH} ${RD}/floppies/${FLOPPYBASE}$${line}.flp \
1232                 ${RD} ${MNT} ${FLPSIZE} ${SPLITDIR}/$${file} \
1233                 ${BOOTINODE} ${FLPLABEL}; \
1234         done )
1235
1236 #
1237 # --==## Build a boot floppy ##==--
1238 #
1239 # FSIMAGE - base floppy image name
1240 # FDSIZE - if specified and "small", small floppy is created
1241 # KERNFILE - path to kernel split file
1242 # MFSROOTFILE - path to mfsroot split file
1243
1244 .if make(buildBootFloppy)
1245 IMAGEDIR=       ${RD}/image.${FSIMAGE}
1246 BOOTDIR=        ${RD}/trees/base/boot
1247 HINTSFILE=      ${BOOTDIR}/device.hints
1248 ACPI_KO=        ${RD}/kernels/GENERIC/acpi.ko
1249 IMAGEFILE=      ${RD}/floppies/${FSIMAGE}.flp
1250 .if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1251 FLPSIZE=        ${SMALLFLOPPYSIZE}
1252 FLPLABEL=       ${SMALLFLOPPYLABEL}
1253 .else
1254 FLPSIZE=        ${FLOPPYSIZE}
1255 FLPLABEL=       ${FLOPPYLABEL}
1256 .endif
1257 .endif
1258
1259 buildBootFloppy:
1260 .if !defined(FSIMAGE)
1261         @echo "FSIMAGE undefined in ${.TARGET}" && exit 1
1262 .endif
1263 .if !defined(KERNFILE)
1264         @echo "KERNFILE undefined in ${.TARGET}" && exit 1
1265 .endif
1266 .if !defined(MFSROOTFILE)
1267         @echo "MFSROOTFILE undefined in ${.TARGET}" && exit 1
1268 .endif
1269         @echo "Running ${.TARGET} for ${FSIMAGE}"
1270         @rm -rf ${IMAGEDIR}
1271         @mkdir ${IMAGEDIR}
1272         @echo "Setting up /boot directory for ${FSIMAGE} floppy"
1273         @mkdir -p ${IMAGEDIR}/boot
1274 .if ${TARGET} == "i386"
1275         @${WMAKEENV} kgzip -v -l ${RD}/trees/base/usr/lib/kgzldr.o -o \
1276             ${IMAGEDIR}/boot/loader ${BOOTDIR}/loader
1277 .else
1278         @cp ${BOOTDIR}/loader ${IMAGEDIR}/boot
1279 .endif
1280         @cp -Rp ${BOOTDIR}/*.4th ${BOOTDIR}/defaults ${BOOTDIR}/loader.help \
1281             ${BOOTDIR}/loader.rc ${IMAGEDIR}/boot
1282 .if exists(${HINTSFILE})
1283         @cp ${HINTSFILE} ${IMAGEDIR}/boot/device.hints
1284         @gzip -9n ${IMAGEDIR}/boot/device.hints
1285 .endif
1286         @gzip -9n ${IMAGEDIR}/boot/*.4th ${IMAGEDIR}/boot/loader.help \
1287             ${IMAGEDIR}/boot/defaults/loader.conf
1288         @echo 'bootfile="/kernel"' > ${IMAGEDIR}/boot/loader.conf
1289 .if exists(${ACPI_KO})
1290         @gzip -9nc ${ACPI_KO} > ${IMAGEDIR}/acpi.ko.gz
1291         @echo 'acpi_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1292         @echo 'acpi_name="/acpi.ko"' >> ${IMAGEDIR}/boot/loader.conf
1293         @echo 'acpi_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1294 .endif
1295         @echo 'mfsroot_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1296         @echo 'mfsroot_type="mfs_root"' >> ${IMAGEDIR}/boot/loader.conf
1297         @echo 'mfsroot_name="/mfsroot"' >> ${IMAGEDIR}/boot/loader.conf
1298 .if !exists(${ACPI_KO})
1299         @echo 'mfsroot_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1300 .endif
1301 .if defined(SPLIT_MFSROOT)
1302         @echo 'mfsroot_after="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1303 .endif
1304 .if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
1305 .if ${AUTO_KEYBOARD_DETECT}
1306         @echo "-P" >> ${IMAGEDIR}/boot.config
1307 .endif
1308 .endif
1309         @rm -f ${IMAGEFILE}
1310         @cp ${KERNFILE} ${MFSROOTFILE} ${IMAGEDIR}
1311         sh -e ${DOFS_SH} ${IMAGEFILE} ${RD} ${MNT} ${FLPSIZE} ${IMAGEDIR} \
1312             ${BOOTINODE} ${FLPLABEL}
1313         @echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1314
1315 .if make(package-split)
1316 # Targets related to making a package split
1317 #
1318 # PKG_COPY instructs the script to copy the actual package files rather than
1319 #     make hard links
1320 # PKG_TREE is the path to the package tree to be split
1321 # PKG_DEST is the path to the destination tree to create the split in
1322 # PKG_VERBOSE asks for verbose output of the layout process
1323 # PKG_INDEX is the path to the INDEX file. By default ${PKG_TREE}/INDEX.
1324
1325 .if defined(PKG_COPY)
1326 PKG_DO_COPY=    cp
1327 .else
1328 PKG_DO_COPY=    ln
1329 .endif
1330 PKG_WRKIDX=     ${PKG_DEST}/INDEX.master
1331 PKG_ENV?=
1332 .if defined(TARGET_ARCH)
1333 PKG_ENV+=       PKG_ARCH=${TARGET_ARCH}
1334 .endif
1335 .if defined(PKG_VERBOSE)
1336 PKG_ENV+=       PKG_VERBOSE=1
1337 .endif
1338 PKG_INDEX?=     ${PKG_TREE}/INDEX
1339
1340 package-split:
1341 .if !defined(PKG_TREE)
1342         @echo "PKG_TREE must be defined" && exit 1
1343 .endif
1344 .if !defined(PKG_DEST)
1345         @echo "PKG_DEST must be defined" && exit 1
1346 .endif
1347         @env ${PKG_ENV} python ${.CURDIR}/scripts/package-split.py \
1348             ${PKG_INDEX} ${PKG_WRKIDX}
1349         @env ${PKG_ENV} sh ${.CURDIR}/scripts/package-trees.sh ${PKG_DO_COPY} \
1350             ${PKG_WRKIDX} ${PKG_TREE} ${PKG_DEST}
1351 .endif
1352
1353 .include <bsd.obj.mk>