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