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