Makefile revision 133828
128219Smsmith# $FreeBSD: head/release/Makefile 133828 2004-08-16 08:56:50Z obrien $
238061Smsmith#
328219Smsmith# make release [BUILDNAME=somename] CHROOTDIR=/some/dir CVSROOT=/cvs/dir \
428219Smsmith#     [RELEASETAG=tag]
528219Smsmith#
628219Smsmith# Where "/some/dir" is the pathname of a directory on a some filesystem with
728219Smsmith# at least 1000MB of free space, "somename" is what you want the release to
828219Smsmith# call itself, "/cvs/dir" is where our source repo resides and, optionally,
928219Smsmith# which CVS "tag" name should be used when checking out the sources to build
1028219Smsmith# the release (default is HEAD).
1128219Smsmith#
1228219Smsmith# Please note: the md(4) driver must be present in the kernel
1328219Smsmith# (either by being compiled in or available as a kld(4) module),
1428219Smsmith# otherwise the target 'release.8' and possibly others will fail.
1528219Smsmith#
1628219Smsmith# Note: If you add options to this file, please keep release(7) updated!
1728219Smsmith#
1828219Smsmith# Set these, release builder!
1928219Smsmith#
2028219Smsmith# Fixed version:
2128219Smsmith#BUILDNAME=5.2-RELEASE
2228219Smsmith#
2328219Smsmith# Automatic SNAP versioning:
2428219SmsmithDATE != date +%Y%m%d
2528219SmsmithBASE = 5.2
2633181SeivindBUILDNAME?=${BASE}-${DATE}-SNAP
2728219Smsmith#
2828219Smsmith#CHROOTDIR=/junk/release
2928219Smsmith# If this is a -stable snapshot, then set
3028219Smsmith#RELEASETAG=RELENG_4
3128219Smsmith#
3228219Smsmith# To test a release with a source tree containing patches and
3328219Smsmith# other work. This tree will get copied instead of getting the
3428219Smsmith# src/ tree from a CVS checkout. For "rerelease", this will NOT
3528219Smsmith# be copied; cvs update will be used instead.
3628219Smsmith#EXTSRCDIR=/usr/src
3728219Smsmith#
3828257Smsmith# To add other options to the CVS subcommands (co,up), set
3928219Smsmith#CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
4038061Smsmith#
4128219Smsmith# To add other options to the CVS command, set
4228219Smsmith#CVSARGS="-lfq"
4328219Smsmith#
4428219Smsmith# To prefix the cvs command
4528219Smsmith#CVSPREFIX="/usr/bin/time"
4628219Smsmith#
4728219Smsmith# Where the CVS repository is
4828219Smsmith#CVSROOT="/home/ncvs"
4928219Smsmith#
5028219Smsmith# Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
5128219Smsmith# are building an official release.  Otherwise, we are building for
5228219Smsmith# a branch.
5328219Smsmith.if defined(RELEASETAG)
5428219SmsmithISRELEASE!=	expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
5528219Smsmith.if ${ISRELEASE} != 0
5628219Smsmith# Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
5728219SmsmithAUXRELEASETAG!=	echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
5828219SmsmithDOCRELEASETAG?=		${AUXRELEASETAG}
5928219SmsmithPORTSRELEASETAG?=	${AUXRELEASETAG}
6028219Smsmith.endif
6128219Smsmith.endif
6228219Smsmith
6328219Smsmith# If you want to pass flags to the world build such as -j X, use
6428219Smsmith# WORLD_FLAGS.  Similarly, you can specify make flags for kernel
6528219Smsmith# builds via KERNEL_FLAGS.
6628219Smsmith# Similarly, you can specify make flags for make readmes via PORTREADMES_FLAGS.
6728219Smsmith#WORLD_FLAGS=-j4
6828219Smsmith#KERNEL_FLAGS=-j4
6928219Smsmith#PORTREADMES_FLAGS=-j4
7028219Smsmith
7128219SmsmithTARGET_ARCH?=	${MACHINE_ARCH}
7228219Smsmith.if ${TARGET_ARCH} == ${MACHINE_ARCH}
7328219SmsmithTARGET?=	${MACHINE}
7428219Smsmith.else
7528219SmsmithTARGET?=	${TARGET_ARCH}
7628219Smsmith.endif
7728219SmsmithCROSSENV=	TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
7828219SmsmithCROSSMAKE=	${MAKE} ${CROSSENV}
7928219SmsmithNATIVEMAKE=	${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
8028219Smsmith
8128219Smsmith# If you are using a local CVS repository with components stored in 
8228219Smsmith# non-standard modules, override these on the make commandline or
8328257Smsmith# in the environment.
8428257SmsmithRELEASESRCMODULE?=	src
8528257SmsmithRELEASEDOCMODULE?=	doc
8628257SmsmithRELEASEPORTSMODULE?=	ports
8728257Smsmith
8828257Smsmith# Uncomment this to disable the doc.1 target.  Docs normally require
8928257Smsmith# the ports tree, so NOPORTS can be set together with NODOC in order
9028257Smsmith# to have neither ports or docs.  If only NOPORTS is set to YES, but
9128257Smsmith# docs are still desired, the DOMINIMALDOCPORTS logic below will only
9228257Smsmith# install the ports that are minimally required for the docs.  This is
9328219Smsmith# intended as a compromise, less disk space is required than for using
9428257Smsmith# the entire ports collection (and much less time due to the huge number
9528257Smsmith# of directories it would create), but still quite a bit as well as some
9628257Smsmith# CPU cycles (some of the programs are C++, and things like ghostscript
9728257Smsmith# belong to the required ports nevertheless).
9828257Smsmith#
9928257Smsmith# Setting this also disables building of release note documentation
10028257Smsmith# (RELNOTESng).
10128257Smsmith#NODOC=  YES
10228257Smsmith#NOPORTS=  YES
10328257Smsmith
10428257Smsmith# Modify this definition if you want the release notes 
10528257Smsmith# and other release documentation in a language other than English.
10628257SmsmithRELNOTES_LANG?=	en_US.ISO8859-1
10728257Smsmith
10828257Smsmith# As an alternative to installing the entire ports collection (which
10928257Smsmith# can take a huge amount of time, in particular on slower disks),
11028257Smsmith# setting ${MINIMALDOCPORTS} allows to install and build just those
11128257Smsmith# ports that are really required for getting the docs up & running.
11228257Smsmith.if defined(NOPORTS) && !defined(NODOC)
11328257SmsmithDOMINIMALDOCPORTS=	YES
11428257Smsmith.include "Makefile.inc.docports"
11528257SmsmithRELEASEPORTSMODULE=	${MINIMALDOCPORTS}
11628257Smsmith.endif
11728257Smsmith
11828257Smsmith# Make changing names of disc1/disc2 CD's possible.
11928257SmsmithDISC1_LABEL?=	fbsd_miniinst
12028257SmsmithDISC1_NAME?=	miniinst
12128257SmsmithDISC2_LABEL?=	fbsd_livefs
12228257SmsmithDISC2_NAME?=	disc2
12328257Smsmith
12428257Smsmith# Helper variable
12528257Smsmith.if defined(NOPORTS)
12628257Smsmith.if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
12728257SmsmithNOPORTSATALL=	YES
12828257Smsmith.endif
12928257Smsmith.endif
13028257Smsmith
13128257Smsmith# By default, documentation (Handbook, FAQ, etc.) is built for all
13228257Smsmith# the languages.  To speed up building, set the DOC_LANG to just
13328257Smsmith# the languages you need.  (The language for the release notes is
13428257Smsmith# controlled by the RELNOTES_LANG variable above.)
13528257Smsmith#DOC_LANG=	en_US.ISO8859-1
13628257SmsmithDOCPORTS=	textproc/docproj
13728257Smsmith# Set this to wherever the distfiles required by release procedures.
13828257Smsmith.if defined(DOCDISTFILES)
13938061Smsmith# Respect DOCDISTFILES which is used before.
14028257SmsmithRELEASEDISTFILES?=	${DOCDISTFILES}
14128257Smsmith.else
14228257SmsmithRELEASEDISTFILES?=	${.CURDIR}/../../ports/distfiles
14328257Smsmith.endif
14428257Smsmith# Set this to 1 if you want -P to be used for automatic keyboard detection
14528257Smsmith# on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
14628257SmsmithAUTO_KEYBOARD_DETECT?= 0
14728257Smsmith
14838061Smsmith.if !defined(NODOC)
14938061SmsmithDIST_DOCS_ARCH_INDEP=	readme errata early-adopter
15038061SmsmithDIST_DOCS_ARCH_DEP=	installation relnotes hardware
15128257Smsmith.endif
15238061Smsmith
15338061Smsmith# Things which without too much trouble can be considered variables
15438061Smsmith# BASE_DISTS are special in that they get full /etc installation sets.
15538061Smsmith#
15638061Smsmith.if ${TARGET_ARCH} == "i386"
15738061SmsmithCOMPAT_DISTS?=	compat1x compat20 compat21 compat22 compat3x compat4x
15828257Smsmith.elif ${TARGET_ARCH} == "alpha"
15928257SmsmithCOMPAT_DISTS?=	compat4x
16028257Smsmith.endif
16128257SmsmithOTHER_DISTS?=	catpages manpages games proflibs dict info doc
16238061SmsmithBASE_DISTS?=	base
16338061SmsmithDISTRIBUTIONS?=	${BASE_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS}
16438061Smsmith
16528257Smsmith# mountpoint for filesystems.
16628257SmsmithMNT=			/mnt
16728257Smsmith
16828257Smsmith# Various floppy image parameters.
16928257Smsmith#
17038061Smsmith
17138061Smsmith.undef MAKE_FLOPPIES
17238061Smsmith.if ${TARGET_ARCH} == "i386"
17338061SmsmithMAKE_FLOPPIES=		true
17428257Smsmith.if ${TARGET} == "pc98"
17528257SmsmithSMALLFLOPPYSIZE=	1200
17628257SmsmithSMALLFLOPPYSPLITSIZE=	1152
17738061SmsmithSMALLFLOPPYLABEL=	fd1200
17828257SmsmithSPLIT_MFSROOT=
17928257Smsmith.endif
18028257SmsmithFLOPPYSIZE=		1440
18128257SmsmithFLOPPYSPLITSIZE=	1392
18228257SmsmithFLOPPYINODE=		40000
18328257SmsmithFLOPPYLABEL=		fd1440
18438061SmsmithBOOTINODE=		80000
18538061SmsmithMFSSIZE=		4320
18638061SmsmithMFSINODE=		8000
18738061SmsmithMFSLABEL=		minimum3
18838061Smsmith.elif ${TARGET_ARCH} == "alpha"
18938061SmsmithMAKE_FLOPPIES=		true
19028257SmsmithFLOPPYSIZE=		1440
19128257SmsmithFLOPPYSPLITSIZE=	1392
19228257SmsmithFLOPPYINODE=		40000
19328257SmsmithFLOPPYLABEL=		fd1440
19428257SmsmithBOOTINODE=		80000
19528257SmsmithMFSSIZE=		4320
19628257SmsmithMFSINODE=		8000
19728257SmsmithMFSLABEL=		auto
19828257SmsmithSPLIT_MFSROOT=
19928257Smsmith.elif ${TARGET_ARCH} == "sparc64"
20028257SmsmithDISKLABEL=		sunlabel
20128257SmsmithMFSSIZE=		4096
20228257SmsmithMFSINODE=		8192
20328257SmsmithMFSLABEL=		auto
20428257SmsmithMINIROOT=
20528257Smsmith.elif ${TARGET_ARCH} == "ia64"
20628257SmsmithMFSSIZE=		8192
20728257SmsmithMFSINODE=		8192
20828257SmsmithMFSLABEL=		auto
20928257Smsmith.elif ${TARGET_ARCH} == "amd64"
21028257SmsmithMFSSIZE=		4096
21128257SmsmithMFSINODE=		8192
21228257SmsmithMFSLABEL=		auto
21328257Smsmith.endif
21428257Smsmith
21528257Smsmith.if exists(/sbin/bsdlabel)
21628257SmsmithDISKLABEL?=		bsdlabel
21728257Smsmith.else
21828257SmsmithDISKLABEL?=		disklabel
21928257Smsmith.endif
22028257Smsmith
22128257SmsmithZIPNSPLIT=		gzip --no-name -9 -c | split -b 1392k -
22228257Smsmith
22328257Smsmith# Things which may get you into trouble if you change them
22428257SmsmithMTREEFILES=		${.CURDIR}/../etc/mtree
22528257Smsmith_R?=			/R
22628257SmsmithRD=			${_R}/stage
22728257SmsmithRND=			${RD}/release.doc
22828257SmsmithFD=			${_R}/ftp
22928257SmsmithCD=			${_R}/cdrom
23028257Smsmith.if ${TARGET} != "pc98"
23128257SmsmithCD_BOOT=		${CD}/bootonly
23238061Smsmith.endif
23338061SmsmithCD_DISC1=		${CD}/disc1
23428257SmsmithCD_DISC2=		${CD}/disc2
23528257Smsmith_MK?=			${CHROOTDIR}/mk
23628257Smsmith
23738061Smsmith# Where the bootstrap ports (see DOCPORTS) get installed.
23838061SmsmithLOCALDIR=		/usr/local/bin
23938061Smsmith
24038061Smsmith.if ${TARGET} != ${MACHINE} && ${DISKLABEL} == "bsdlabel"
24138061SmsmithDOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ${TARGET}
24228257Smsmith.else
24328257SmsmithDOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ""
24428257Smsmith.endif
24528219Smsmith
24628219SmsmithCRUNCH_TARGETS=	boot
24728219Smsmith.if ${TARGET_ARCH} == "i386"
24828219SmsmithCRUNCH_TARGETS+=fixit
24928219Smsmith.if ${TARGET} == "pc98"
25028219SmsmithCRUNCH_TARGETS+=fixit-small
25128219Smsmith.endif
25228219Smsmith.endif
25328219Smsmith
25428219Smsmith.if defined(MAKE_FLOPPIES)
25528219SmsmithEXTRAS= floppies.1
25628257Smsmith.if ${TARGET_ARCH} == "i386"
25728219SmsmithEXTRAS+= floppies.2
25828219Smsmith.endif
25928257SmsmithEXTRAS+= floppies.3
26028257Smsmith.endif
26128257SmsmithEXTRAS+= ftp.1
26228219Smsmith.if !defined(NOCDROM)
26328219SmsmithEXTRAS+= cdrom.1
26428219Smsmith.if defined(MAKE_ISOS)
26528219SmsmithEXTRAS+= iso.1
26628219Smsmith.endif
26728219Smsmith.if ${TARGET} == "pc98"
26828219SmsmithBOOTABLE=
26928219Smsmith.else
27028219SmsmithBOOTABLE="-b"
27128219Smsmith.endif
27228219Smsmith.endif
27328219Smsmith
27428219Smsmith.if !defined(NODOC)
27528219SmsmithDOCREL= doc.1 doc.2
27628219Smsmith.endif
27728219Smsmith
27828219Smsmith.if !make(release) && !make(rerelease)
27928219SmsmithBINMAKE!=	cd ${.CURDIR}/..; ${MAKE} -V BINMAKE
28028219SmsmithWMAKEENV!=	cd ${.CURDIR}/..; \
28128219Smsmith		${BINMAKE} ${CROSSENV} -f Makefile.inc1 -V WMAKEENV
28228219SmsmithWMAKE=		${WMAKEENV} ${BINMAKE}
28328257Smsmith.endif
28428219Smsmith
28528257SmsmithCVS_SRCARGS=	-P
28628219Smsmith.if defined(RELEASETAG)
28728257SmsmithCVS_SRCARGS+=	-r ${RELEASETAG}
28828257Smsmith.endif
28928219Smsmith
29028219SmsmithCVS_DOCARGS=	-P
29128257Smsmith.if defined(DOCRELEASETAG)
29228257SmsmithCVS_DOCARGS+=	-r ${DOCRELEASETAG}
29328219Smsmith.endif
29428257Smsmith
29528257SmsmithCVS_PORTSARGS=	-P
29628219Smsmith.if defined(PORTSRELEASETAG)
29728257SmsmithCVS_PORTSARGS+=	-r ${PORTSRELEASETAG}
29828257Smsmith.endif
29928257Smsmith
30028257SmsmithWORLDDIR?=	${.CURDIR}/..
30128257Smsmith
30228257Smsmithrelease rerelease:
30328257Smsmith.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
30428257Smsmith	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
30528257Smsmith.endif
30628219Smsmith.if defined(NOPORTSATALL) && !defined(NODOC)
30728257Smsmith	@echo "Ports are required for building the docs.  Either set NODOC or"
30828257Smsmith	@echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
30928257Smsmith	@exit 1
31028219Smsmith.endif
31128257Smsmith.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
31228219Smsmith.for p in ${LOCAL_PATCHES}
31328219Smsmith.if !exists(${p})
31428219Smsmith	@echo "The patch file ${p} does not exist!"
31538061Smsmith	@exit 1
31638061Smsmith.endif
31738061Smsmith.endfor
31838061Smsmith.endif
31938061Smsmith.if defined(LOCAL_SCRIPT) && !exists(${LOCAL_SCRIPT})
32038061Smsmith	@echo "The local script ${LOCAL_SCRIPT} does not exist!"
32138061Smsmith	@exit 1
32238061Smsmith.endif
32338061Smsmith.if make(release)
32438061Smsmith.if exists(${CHROOTDIR})
32538061Smsmith# The first command will fail on a handful of files that have their schg
32638061Smsmith# flags set.  But it greatly speeds up the next two commands.
32738061Smsmith	# NB: clear any vestigal devfs mount, just in case
32838061Smsmith	-umount ${CHROOTDIR}/dev > /dev/null 2>&1
32938061Smsmith	-rm -rf ${CHROOTDIR} 2>/dev/null
33038061Smsmith	-chflags -R noschg ${CHROOTDIR}/.
33138061Smsmith	-rm -rf ${CHROOTDIR}
33238061Smsmith.endif
33328257Smsmith	mkdir -p ${CHROOTDIR}
33428219Smsmith	@echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
33528257Smsmith	cd ${WORLDDIR} && ${NATIVEMAKE} -DNOGAMES -DNOHTML -DNOINFO -DNOMAN \
33628219Smsmith	    -DNOPROFILE installworld DESTDIR=${CHROOTDIR}
33728219Smsmith	cd ${WORLDDIR}/etc && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
33828257Smsmith	if [ -f /etc/resolv.conf ]; then \
33928219Smsmith		cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
34028219Smsmith	fi
34128219Smsmith.if defined(EXTLOCALDIR)
34228257Smsmith	rm -rf ${CHROOTDIR}/usr/local
34328257Smsmith	cd ${CHROOTDIR}/usr && cp -R -H ${EXTLOCALDIR} local
34428219Smsmith.endif
34528219Smsmith	rm -rf ${CHROOTDIR}/usr/src
34628219Smsmith.if defined(EXTSRCDIR)
34728219Smsmith	cd ${CHROOTDIR}/usr && \
34828219Smsmith	    cp -R -H ${EXTSRCDIR} src
34928257Smsmith.else
35028219Smsmith	cd ${CHROOTDIR}/usr && \
35128257Smsmith	    ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
35228219Smsmith	    co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
35328219Smsmith.endif
35428257Smsmith.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
35528219Smsmith.for p in ${LOCAL_PATCHES}
35628219Smsmith	patch -d ${CHROOTDIR}/usr/${RELEASESRCMODULE} ${PATCH_FLAGS} < ${p}
35728257Smsmith.endfor
35828257Smsmith.endif
35928219Smsmith.if defined(LOCAL_SCRIPT)
36028219Smsmith	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} \
36128219Smsmith	    RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
36228219Smsmith.endif
36328219Smsmith	rm -rf ${CHROOTDIR}/usr/ports
36428257Smsmith.if !defined(NOPORTSATALL)
36528219Smsmith	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
36628257Smsmith	    co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
36728257Smsmith.endif
36828257Smsmith.if !defined(NODOC)
36928219Smsmith	rm -rf ${CHROOTDIR}/usr/doc
37028219Smsmith.if defined(EXTDOCDIR)
37128257Smsmith	cd ${CHROOTDIR}/usr && cp -R -H ${EXTDOCDIR} doc
37228219Smsmith.else
37328257Smsmith	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
37428219Smsmith	    co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
37528219Smsmith.endif
37628257Smsmith	if [ -d ${RELEASEDISTFILES}/ ]; then \
37728257Smsmith		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
37828257Smsmith	else \
37928257Smsmith		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
38028219Smsmith	fi
38128257Smsmith.if !defined(NO_PREFETCHDISTFILES)
38228257Smsmith	@cd ${.CURDIR} && ${MAKE} fetch-distfiles
38328257Smsmith.endif
38428257Smsmith.endif
38528219Smsmith.endif
38628257Smsmith.if make(rerelease)
38728257Smsmith.if !defined(RELEASENOUPDATE)
38828257Smsmith.if !defined(RELEASETAG)
38928219Smsmith	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
39028257Smsmith	    update ${CVSCMDARGS} -P -d -A
39128257Smsmith.else
39228257Smsmith	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
39328257Smsmith	    update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
39428219Smsmith.endif
39528257Smsmith	rm -f ${CHROOTDIR}/tmp/.world_done 
39628257Smsmith.if !defined(NOPORTS)
39728219Smsmith	cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
39838061Smsmith	    update ${CVSCMDARGS} -P -d
39938061Smsmith.endif
40038061Smsmith.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
40138061Smsmith	for i in ${MINIMALDOCPORTS}; do \
40238061Smsmith	    ( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
40338061Smsmith		update ${CVSCMDARGS} -P -d ) ; \
40438061Smsmith	done
40538061Smsmith.endif
40638061Smsmith.if !defined(NODOC)
40728257Smsmith	cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
40828257Smsmith	    update ${CVSCMDARGS} -P -d
40928257Smsmith.endif
41028257Smsmith.endif
41128219Smsmith.endif
41228257Smsmith	# Add version information to those things that need it.
41328219Smsmith	if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
41428219Smsmith		cd ${CHROOTDIR}/usr/src/sys/conf && \
41528219Smsmith		mv newvers.sh foo && \
41628257Smsmith		sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && \
41728219Smsmith		rm foo; \
41828257Smsmith	fi
41928219Smsmith	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
42028219Smsmith	echo "#!/bin/sh"			> ${_MK}
42128257Smsmith	echo "set -ex"				>> ${_MK}
42228219Smsmith	echo "trap 'umount /dev || true' 0"	>> ${_MK}
42328257Smsmith	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${_MK}
42428219Smsmith.for var in \
42528219Smsmith	AUTO_KEYBOARD_DETECT \
42628257Smsmith	BOOT_CONFIG \
42728257Smsmith	BUILDNAME \
42828257Smsmith	CD_EXTRA_BITS \
42928219Smsmith	DISC1_LABEL \
43028257Smsmith	DISC1_NAME \
43128219Smsmith	DISC2_LABEL \
43228257Smsmith	DISC2_NAME \
43328257Smsmith	DISTRIBUTIONS \
43428219Smsmith	DOC_LANG \
43538061Smsmith	DOMINIMALDOCPORTS \
43638061Smsmith	EXTRA_SRC \
43738061Smsmith	FTP_PASSIVE_MODE \
43838061Smsmith	FTP_PROXY \
43938061Smsmith	HTTP_PROXY \
44038061Smsmith	KERNELS \
44128257Smsmith	KERNEL_FLAGS \
44228257Smsmith	MAKE_FLOPPIES \
44328219Smsmith	MAKE_ISOS \
44428219Smsmith	NOCDROM \
44528219Smsmith	NODOC \
446	NOPORTS \
447	NOSHARED \
448	NOSRC \
449	NO_CPU_CFLAGS \
450	NO_CPU_COPTFLAGS \
451	NO_SENDMAIL \
452	RELEASETAG \
453	RELNOTES_LANG \
454	TARGET \
455	TARGET_ARCH \
456	WORLD_FLAGS
457.if defined(${var})
458	echo "export ${var}=\"${${var}}\""	>> ${_MK}
459.endif
460.endfor
461	# Don't remove this, or the build will fall over!
462	echo "export RELEASEDIR=${_R}"		>> ${_MK}
463	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${_MK}
464	echo "export MANBUILDCAT=YES"		>> ${_MK}
465	# NB: these may fail if the host is running w/o devfs
466	echo "umount /dev >/dev/null 2>&1 || true" >> ${_MK}
467	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true"	>> ${_MK}
468	echo "if [ -x /etc/rc.d/ldconfig ]; then" >> ${_MK}
469	echo "	/etc/rc.d/ldconfig start"	>> ${_MK}
470	echo "else"				>> ${_MK}
471	echo "	ldconfig /lib /usr/lib /usr/local/lib || true" >> ${_MK}
472	echo "fi"				>> ${_MK}
473	echo "if [ ! -f /tmp/.world_done ]; then" >> ${_MK}
474	echo "	cd /usr/src"			>> ${_MK}
475	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNOCLEAN buildworld && \\" >> ${_MK}
476	echo "	touch /tmp/.world_done || exit 1" >> ${_MK}
477	echo "fi"				>> ${_MK}
478	echo "if [ ! -f /tmp/.skip_ports ]; then" >> ${_MK}
479	echo "	echo \">>> make readmes started on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
480	echo "	cd /usr/ports"			>> ${_MK}
481	echo "	make ${PORTREADMES_FLAGS} readmes" >> ${_MK}
482	echo "	touch /tmp/.skip_ports"		>> ${_MK}
483	echo "	echo \">>> make readmes finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
484	echo "fi"				>> ${_MK}
485	echo "cd /usr/src/release"		>> ${_MK}
486	echo "make obj"				>> ${_MK}
487	echo "make \$${_RELTARGET}"		>> ${_MK}
488	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
489	chmod 755 ${_MK}
490.if defined(NOPORTS) || defined(NOPORTREADMES)
491	touch ${CHROOTDIR}/tmp/.skip_ports
492.endif
493	# Ensure md.ko is loaded if md(4) is not statically compiled into 
494	# the kernel
495	-mdconfig 2>/dev/null
496	env -i /usr/sbin/chroot `dirname ${_MK}` /`basename ${_MK}`
497
498clean:
499	rm -rf ${CRUNCH_TARGETS:S/$/_crunch/} release.[0-8] ${EXTRAS}
500
501fetch-distfiles:
502	@for i in ${DOCPORTS}; do \
503		cd ${CHROOTDIR}/usr/ports/$$i && \
504			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
505			WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
506			checksum-recursive ; \
507	done
508
509# Clean out ${_R} and make the directory structure.
510release.1:
511	mkdir -p ${_R}
512	-rm -rf ${_R}/* 2> /dev/null
513	-chflags -R noschg ${_R}/.
514	rm -rf ${_R}/*
515	mkdir ${RD}
516.if defined(MAKE_FLOPPIES)
517	mkdir ${RD}/floppies
518.endif
519	mkdir ${RD}/trees
520	mkdir ${RD}/kernels
521	for i in ${DISTRIBUTIONS}; do \
522		mkdir ${RD}/trees/$$i && \
523		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
524		    -p ${RD}/trees/$$i > /dev/null && \
525		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
526		    -p ${RD}/trees/$$i/usr > /dev/null && \
527		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
528		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
529		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
530		    -p ${RD}/trees/$$i/var > /dev/null ; \
531	done
532	touch ${.TARGET}
533
534# Install the system into the various distributions.
535release.2:
536	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
537	cd ${.CURDIR}/.. && ${CROSSMAKE} distributeworld DISTDIR=${RD}/trees
538	touch ${.TARGET}
539
540# Make and install the generic kernel(s).
541release.3:
542.for kernel in ${KERNELS}
543	cd ${.CURDIR}/..; \
544	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
545	    KERNCONF=${kernel} INSTKERNNAME=${kernel} kernel \
546	    DESTDIR=${RD}/trees/base
547.endfor
548	# Install a standard boot kernel+modules.
549	cd ${.CURDIR}/..; \
550	${CROSSMAKE} ${KERNEL_FLAGS} \
551	    kernel \
552	    DESTDIR=${RD}/trees/base; \
553	cd ${.CURDIR}/..; \
554	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
555	    reinstallkernel -DINSTALL_DEBUG \
556	    DESTDIR=${RD}/trees/base
557	touch ${.TARGET}
558
559# Make and install the three crunched binaries which live on the floppies.
560# You are not supposed to like this :-)
561release.4:
562	rm -rf ${RD}/crunch
563	mkdir -p ${RD}/crunch
564.for j in ${CRUNCH_TARGETS}
565.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
566	rm -rf ${j}_crunch
567	mkdir ${j}_crunch
568	cd ${j}_crunch; ${WMAKEENV} crunchgen -o \
569	    ${.CURDIR}/${TARGET}/${j}_crunch.conf
570	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
571	cd ${.CURDIR}/..; ${BINMAKE} -f Makefile.inc1 _build-tools
572	cd ${j}_crunch; CFLAGS="-Os -pipe" ${WMAKE} -f ${j}_crunch.mk \
573	    -DNO_CPU_CFLAGS all
574	${WMAKEENV} strip -R .comment ${j}_crunch/${j}_crunch
575	mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
576.endif
577.endfor
578	touch ${.TARGET}
579
580#
581# --==## Fix up the distributions. ##==--
582#
583release.5:
584	# Create any "synthetic dists" now.
585	@for i in ${DISTRIBUTIONS}; do \
586		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
587			echo -n "Running $$i dist creation script... "; \
588			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
589			echo "Done."; \
590		fi \
591	done \
592
593	# Remove all the directories we don't need.
594	-cd ${RD}/trees && \
595		find ${OTHER_DISTS} ${COMPAT_DISTS} -depth -type d -print | xargs rmdir
596	touch ${.TARGET}
597
598#
599# --==## Package up the tarballs from assembled trees ##==--
600#
601release.6:
602	rm -rf ${RD}/dists
603	mkdir -p ${RD}/dists
604	@for i in ${DISTRIBUTIONS} ; \
605	do \
606		if [ -d ${RD}/trees/$${i} ] ; then \
607			cd ${.CURDIR} && $(MAKE) doTARBALL \
608				SD=${RD}/trees/$${i} \
609				TN=$$i TD=$$i ARG="." && \
610			echo "$${i} distribution is finished."; \
611		fi ; \
612	done
613.if !defined(NOPORTS)
614	# XXX: Inline stripped version of doTARBALL
615	@rm -rf ${RD}/dists/ports/ports*
616	@mkdir -p ${RD}/dists/ports
617	@echo rolling ports/ports tarball
618	@tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
619	  ${RD}/dists/ports/ports.tgz -C /usr ports
620	@cp ${.CURDIR}/scripts/ports-install.sh ${RD}/dists/ports/install.sh
621	@(cd ${RD}/dists/ports; \
622	  rm -f CHECKSUM.MD5; \
623	  md5 * > CHECKSUM.MD5)
624	@echo "ports distribution is finished."
625.endif
626	touch ${.TARGET}
627
628
629#
630# --==## Make source dists ##==--
631#
632release.7:
633.if !defined(NOSRC)
634	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
635		TD=src TN=sbase ARG="[A-Z]*"
636	@for i in `cd /usr/src && echo [a-z]*` ; do \
637		if [ -d /usr/src/$$i ] ; then \
638			cd ${.CURDIR} && $(MAKE) doTARBALL \
639				TN=`echo s$$i | tr -d '.' | \
640				    sed -e 's/usr/u/' \
641					-e 's/kerberos5/krb5/'` \
642				SD=/usr/src TD=src ARG="$$i" ; \
643		fi ; \
644	done
645.if defined(EXTRA_SRC)
646	@set ${EXTRA_SRC} && \
647	while [ $$# -ge 2 ] ; do \
648		if [ -d /usr/src/$$1 ] ; then \
649			cd ${.CURDIR} && $(MAKE) doTARBALL \
650				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
651		fi && shift && shift ; \
652	done
653.endif
654	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
655	@echo "src distribution is finished."
656.endif
657	touch ${.TARGET}
658
659# Build the memory root filesystem.
660release.8:
661	cp ${RD}/trees/base/etc/disktab /etc
662	rm -rf ${RD}/mfsfd
663	mkdir ${RD}/mfsfd
664	cd ${RD}/mfsfd && \
665		mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help
666	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
667		DIR=${RD}/mfsfd/stand ZIP=false
668	( cd ${RD}/mfsfd && \
669	  for dir in bin sbin ; do \
670		ln -sf /stand $$dir; \
671	  done )
672	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
673.if ${TARGET} == "pc98"
674	cp ${.CURDIR}/../etc/defaults/pccard.conf \
675	    ${RD}/mfsfd/etc/defaults/pccard.conf
676.endif
677	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
678	( for F in defaults/rc.conf netconfig protocols ; do \
679		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
680		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
681	  done )
682	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
683	    ${RD}/trees/base/etc/services | \
684	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
685	    > ${RD}/mfsfd/stand/etc/services
686	grep 'operator' ${RD}/trees/base/etc/group \
687	    > ${RD}/mfsfd/stand/etc/group
688	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
689	ln ${RD}/mfsfd/stand/etc/group ${RD}/mfsfd/etc/group
690	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
691	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
692.if !defined(NODOC)
693	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
694	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
695	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
696	done
697	@for i in ${DIST_DOCS_ARCH_DEP}; do \
698	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
699	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
700	done
701	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT \
702	    ${RD}/mfsfd/stand/help/INSTALL.TXT
703	@mv ${RD}/mfsfd/stand/help/EARLY-ADOPTER.TXT \
704	    ${RD}/mfsfd/stand/help/EARLY.TXT
705.endif
706	-test -f ${.CURDIR}/install.cfg \
707	    && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
708	@mkdir -p ${RD}/mfsfd/boot
709.if ${TARGET_ARCH} != "ia64"
710	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
711.endif
712.if ${TARGET} == "i386" || ${TARGET_ARCH} == "amd64"
713	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
714.endif
715	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
716		tar xf - -C ${RD}/mfsfd/stand
717	@mkdir -p ${RD}/mfsroot
718	sh -e ${DOFS_SH} ${RD}/mfsroot/mfsroot ${RD} ${MNT} \
719	    ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
720	@gzip -9fnv ${RD}/mfsroot/mfsroot
721	touch ${.TARGET}
722
723KERNFLOPPYSET=		${RD}/floppyset/kern/kernel.gz
724.if defined(SMALLFLOPPYSIZE)
725SMALLKERNFLOPPYSET=	${RD}/floppyset/kern-small/kernel.gz
726.endif
727.if defined(SPLIT_MFSROOT)
728MFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot/mfsroot.gz
729.if defined(SMALLFLOPPYSIZE)
730SMALLMFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot-small/mfsroot.gz
731.endif
732.endif
733
734# Build boot and install floppies.
735floppies.1:
736	@gzip -9nc ${RD}/trees/base/boot/kernel/kernel > ${RD}/kernels/kernel.gz
737	@echo "Making the kernel boot floppies..."
738	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern \
739	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz
740.if defined(SMALLFLOPPYSIZE)
741	@echo "Making the small kernel boot floppies..."
742	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern-small \
743	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz \
744	    FDSIZE="SMALL"
745.endif
746.if defined(SPLIT_MFSROOT)
747	@echo "Making the mfsroot boot floppies..."
748	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot \
749	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz
750.if defined(SMALLFLOPPYSIZE)
751	@echo "Making the small mfsroot boot floppies..."
752	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot-small \
753	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz \
754	    FDSIZE="SMALL"
755.endif
756	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
757	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
758	    MFSROOTFILE="${MFSROOTFLOPPYSET}.split ${MFSROOTFLOPPYSET}.boot"
759.if defined(SMALLFLOPPYSIZE)
760	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
761	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
762	    MFSROOTFILE="${SMALLMFSROOTFLOPPYSET}.split ${SMALLMFSROOTFLOPPYSET}.boot" \
763	    FDSIZE="SMALL"
764.endif
765.else	# !SPLIT_MFSROOT
766	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
767	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
768	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz
769.if defined(SMALLFLOPPYSIZE)
770	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
771	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
772	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz \
773	    FDSIZE="SMALL"
774.endif
775.endif	# SPLIT_MFSROOT
776	touch ${.TARGET}
777
778# Build fixit floppy.
779floppies.2:
780	@echo "Making fixit floppy."
781	@rm -rf ${RD}/fixitfd
782	@mkdir ${RD}/fixitfd
783	@cd ${RD}/fixitfd && \
784	    mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
785	    usr/share/misc
786	@cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
787	    ${RD}/fixitfd/etc
788	@sed -e 's/#.*//' ${RD}/trees/base/etc/protocols \
789	    > ${RD}/fixitfd/etc/protocols
790	@sed -e 's/#.*//' ${RD}/trees/base/usr/share/misc/scsi_modes \
791	    > ${RD}/fixitfd/usr/share/misc/scsi_modes
792	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
793	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
794	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
795	@chmod 555 ${RD}/fixitfd/stand/tar
796.if defined(SMALLFLOPPYSIZE)
797	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit-small \
798	    DIR=${RD}/fixitfd/stand ZIP=false
799	@sh -e ${DOFS_SH} ${RD}/floppies/fixit-small.flp ${RD} ${MNT} \
800	    ${SMALLFLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${SMALLFLOPPYLABEL}
801	@rm -rf ${RD}/fixitfd/stand
802	@mkdir ${RD}/fixitfd/stand
803.endif
804	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
805	    DIR=${RD}/fixitfd/stand ZIP=false
806	@sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} ${MNT} \
807	    ${FLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${FLOPPYLABEL}
808	touch ${.TARGET}
809
810# Do our last minute floppies directory setup
811floppies.3:
812.if !defined(NODOC)
813	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
814	    ${RD}/floppies/README.TXT
815	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
816.else
817	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
818.endif
819	touch ${.TARGET}
820
821#
822# --==## Setup a suitable ftp-area ##==--
823#
824ftp.1:
825	@echo "Setting up FTP distribution area"
826	@mkdir -p ${FD}
827	-@ln -s . ${FD}/${BUILDNAME}
828.if defined(MAKE_FLOPPIES)
829	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
830.endif
831	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
832.if !defined(NODOC)
833	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
834		cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
835		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
836		cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
837		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
838	done
839	@for i in ${DIST_DOCS_ARCH_DEP}; do \
840		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
841		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
842		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
843		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
844	done
845	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
846	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
847	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
848	@mv ${FD}/EARLY-ADOPTER.TXT ${FD}/EARLY.TXT
849	@mv ${FD}/EARLY-ADOPTER.HTM ${FD}/EARLY.HTM
850.endif
851	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
852	touch ${.TARGET}
853
854#
855# --==## Setup a suitable cdrom-area ##==--
856#
857cdrom.1:
858	@echo "Setting up CDROM distribution area"
859	@mkdir -p ${CD_BOOT} ${CD_DISC1} ${CD_DISC2}
860	-@ln -s . ${CD_DISC1}/${BUILDNAME}
861.if defined(MAKE_FLOPPIES)
862	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
863.endif
864	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
865	@for i in ${DISTRIBUTIONS} ; \
866	do \
867		if [ -d ${RD}/trees/$${i} ] ; then \
868			chflags -R noschg ${RD}/trees/$${i} || true ; \
869			( cd ${RD}/trees/$${i} && \
870			    find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
871		fi \
872	done
873	@rm -f ${CD_DISC2}/.profile
874	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
875	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
876	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
877.if !defined(NODOC)
878	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
879	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
880	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
881	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
882	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
883	done
884	@for i in ${DIST_DOCS_ARCH_DEP}; do \
885	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
886	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
887	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
888	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
889	done
890	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
891	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
892	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
893	@mv ${CD_DISC1}/EARLY-ADOPTER.TXT ${CD_DISC1}/EARLY.TXT
894	@mv ${CD_DISC1}/EARLY-ADOPTER.HTM ${CD_DISC1}/EARLY.HTM
895.endif
896.if ${TARGET} != "pc98"
897	@echo "Setting up boot area"
898	@rm -f ${CD_DISC2}/boot/loader.conf
899	@cp ${RD}/mfsroot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
900	@echo 'mfsroot_load="YES"' > ${CD_DISC2}/boot/loader.conf
901	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC2}/boot/loader.conf
902	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC2}/boot/loader.conf
903.if defined(CD_BOOT)
904	@cp -Rp ${CD_DISC2}/boot ${CD_BOOT}
905.if defined(MINIROOT)
906	@mkdir -p ${FD}/miniroot
907	@sh -e ${DOFS_SH} ${FD}/miniroot/miniroot.ufs \
908	    ${RD} ${MNT} 0 ${CD_BOOT} 8192 auto
909	@gzip -9v ${FD}/miniroot/miniroot.ufs
910.endif
911.endif
912	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
913.endif
914	touch ${.TARGET}
915
916iso.1:
917.if exists(${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh)
918	@echo "Creating ISO images..."
919.if defined(CD_BOOT)
920	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
921	    fbsd_bootonly \
922	    ${CD}/${BUILDNAME}-${TARGET}-bootonly.iso ${CD_BOOT}
923.endif
924	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
925	    ${DISC1_LABEL} \
926	    ${CD}/${BUILDNAME}-${TARGET}-${DISC1_NAME}.iso ${CD_DISC1}
927	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
928	    ${DISC2_LABEL} \
929	    ${CD}/${BUILDNAME}-${TARGET}-${DISC2_NAME}.iso ${CD_DISC2}
930.if defined(CD_EXTRA_BITS)
931	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
932	    fbsd_boot \
933	    ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} \
934	    ${CD_EXTRA_BITS} \
935	    && false
936.endif
937	@(cd ${CD} && md5 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.MD5)
938	touch ${.TARGET}
939.else
940	@echo "Do not know how to create an ISO for ${TARGET_ARCH}."
941.endif
942
943#
944# --==## Documentation Project files such as the Handbook and FAQ ##==--
945#
946doc.1:
947	@echo "Making docs..."
948	@for i in ${DOCPORTS}; do \
949	    cd /usr/ports/$$i && \
950	    env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \
951		make all install clean BATCH=yes WITHOUT_X11=yes JADETEX=no \
952		WITHOUT_PYTHON=yes FORCE_PKG_REGISTER=yes; \
953	done
954	@cd /usr/doc && make all install 'FORMATS=html html-split txt' \
955	    INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc \
956	    URLS_ABSOLUTE=YES	
957	touch ${.TARGET}
958
959#
960# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
961#
962doc.2:
963	@echo "Making release documentation..."
964	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' \
965	    INSTALL_COMPRESSED='' DOCDIR=${RND}
966	touch ${.TARGET}
967
968# Various "subroutine" and other supporting targets.
969
970# RD=
971# SD=
972# TD=
973# ARG=
974doTARBALL:
975.if !defined(SD)
976	@echo "SD undefined in doTARBALL" && exit 1
977.endif
978.if !defined(TD)
979	@echo "TD undefined in doTARBALL" && exit 1
980.endif
981.if !defined(ARG)
982	@echo "ARG undefined in doTARBALL" && exit 1
983.endif
984	@rm -rf ${RD}/dists/${TD}/${TN}*
985	@mkdir -p ${RD}/dists/${TD}
986	@( cd ${SD} && \
987		tn=`echo ${TN} | tr 'A-Z' 'a-z' | cut -c1-8` && \
988		echo rolling ${TD}/$$tn tarball &&\
989		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
990		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
991		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn \
992		    > ${RD}/dists/${TD}/$$tn.inf && \
993		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
994			cp -p ${.CURDIR}/scripts/$${TD}-install.sh \
995			    ${RD}/dists/${TD}/install.sh; \
996		fi && \
997		if [ "${SD}" != "/usr/src" ]; then \
998			mtree -c -i -p ${SD}/${ARG} \
999			  -k gname,md5digest,mode,nlink,uname,size,link,type \
1000			  > ${RD}/dists/${TD}/$$tn.mtree ; \
1001		else \
1002			true; \
1003		fi; \
1004		( cd ${RD}/dists/${TD}; \
1005		rm -f CHECKSUM.MD5; \
1006		md5 * > CHECKSUM.MD5 ) \
1007	)
1008
1009doRELEASE: release.1 release.2 ${DOCREL} release.3 release.4 \
1010    release.5 release.6 release.7 release.8 ${EXTRAS}
1011	@echo "Release done"
1012
1013floppies:
1014	@rm -f release.4 release.8 floppies.[123]
1015	@cd ${.CURDIR} && ${MAKE} release.4 release.8 floppies.1 floppies.2 \
1016	    floppies.3
1017	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
1018
1019installCRUNCH:
1020.if !defined(CRUNCH)
1021	@echo "CRUNCH undefined in installCRUNCH" && exit 1
1022.endif
1023.if !defined(DIR)
1024	@echo "DIR undefined in installCRUNCH" && exit 1
1025.endif
1026.if !defined(ZIP)
1027	@echo "ZIP undefined in installCRUNCH" && exit 1
1028.endif
1029	@if ${ZIP} ; then \
1030		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
1031	else \
1032		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
1033	fi
1034	@chmod 555 ${DIR}/${CRUNCH}_crunch
1035	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
1036		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
1037			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1038		done \
1039	else \
1040		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
1041			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1042		done \
1043	fi
1044
1045#
1046# --==## Build a floppy set for a splitfs file ##==--
1047#
1048# FLOPPYBASE - basename of floppy image files
1049# FLOPPYDESC - description of floppy set
1050# SPLITFILE - filename of the file to split
1051# FDSIZE - if specified and "small", small floppy is created
1052
1053.if make(makeFloppySet)
1054SPLITDIR=	${RD}/floppyset/${FLOPPYBASE}
1055.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1056FLPSPLITSIZE=	${SMALLFLOPPYSPLITSIZE}
1057FLPSIZE=	${SMALLFLOPPYSIZE}
1058FLPLABEL=	${SMALLFLOPPYLABEL}
1059.else
1060FLPSPLITSIZE=	${FLOPPYSPLITSIZE}
1061FLPSIZE=	${FLOPPYSIZE}
1062FLPLABEL=	${FLOPPYLABEL}
1063.endif
1064.endif
1065
1066makeFloppySet:
1067.if !defined(FLOPPYBASE)
1068	@echo "FLOPPYBASE undefined in ${.TARGET}" && exit 1
1069.endif
1070.if !defined(FLOPPYDESC)
1071	@echo "FLOPPYDESC undefined in ${.TARGET}" && exit 1
1072.endif
1073.if !defined(SPLITFILE)
1074	@echo "SPLITFILE undefined in ${.TARGET}" && exit 1
1075.endif
1076	sh ${.CURDIR}/scripts/split-file.sh ${SPLITFILE} \
1077	    ${RD}/floppyset/${FLOPPYBASE} ${FLPSPLITSIZE} "${FLOPPYDESC}"
1078	( splitfile=${SPLITDIR}/`basename ${SPLITFILE}`.split ; \
1079	lines=`cat $${splitfile} | wc -l`; \
1080	lines=$$((lines - 1)) ; \
1081	for line in `jot $$lines`; do \
1082		file=`head -n $$(($${line} + 1)) $${splitfile} | tail -1 | cut -f 1 -d ' '` ; \
1083		sh -e ${DOFS_SH} ${RD}/floppies/${FLOPPYBASE}$${line}.flp \
1084		${RD} ${MNT} ${FLPSIZE} ${SPLITDIR}/$${file} \
1085		${BOOTINODE} ${FLPLABEL}; \
1086	done )
1087
1088#
1089# --==## Build a boot floppy ##==--
1090#
1091# FSIMAGE - base floppy image name
1092# FDSIZE - if specified and "small", small floppy is created
1093# KERNFILE - path to kernel split file
1094# MFSROOTFILE - path to mfsroot split file
1095
1096.if make(buildBootFloppy)
1097IMAGEDIR=	${RD}/image.${FSIMAGE}
1098BOOTDIR=	${RD}/trees/base/boot
1099HINTSFILE=	${BOOTDIR}/device.hints
1100ACPI_KO=	${BOOTDIR}/kernel/acpi.ko
1101IMAGEFILE=	${RD}/floppies/${FSIMAGE}.flp
1102.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1103FLPSIZE=	${SMALLFLOPPYSIZE}
1104FLPLABEL=	${SMALLFLOPPYLABEL}
1105.else
1106FLPSIZE=	${FLOPPYSIZE}
1107FLPLABEL=	${FLOPPYLABEL}
1108.endif
1109.endif
1110
1111buildBootFloppy:
1112.if !defined(FSIMAGE)
1113	@echo "FSIMAGE undefined in ${.TARGET}" && exit 1
1114.endif
1115.if !defined(KERNFILE)
1116	@echo "KERNFILE undefined in ${.TARGET}" && exit 1
1117.endif
1118.if !defined(MFSROOTFILE)
1119	@echo "MFSROOTFILE undefined in ${.TARGET}" && exit 1
1120.endif
1121	@echo "Running ${.TARGET} for ${FSIMAGE}"
1122	@rm -rf ${IMAGEDIR}
1123	@mkdir ${IMAGEDIR}
1124	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
1125	@mkdir -p ${IMAGEDIR}/boot
1126.if ${TARGET} == "i386"
1127	@${WMAKEENV} kgzip -v -l ${RD}/trees/base/usr/lib/kgzldr.o -o \
1128	    ${IMAGEDIR}/boot/loader ${BOOTDIR}/loader
1129.else
1130	@cp ${BOOTDIR}/loader ${IMAGEDIR}/boot
1131.endif
1132	@cp -Rp ${BOOTDIR}/*.4th ${BOOTDIR}/defaults ${BOOTDIR}/loader.help \
1133	    ${BOOTDIR}/loader.rc ${IMAGEDIR}/boot
1134.if exists(${HINTSFILE})
1135	@gzip -9nc ${HINTSFILE} > ${IMAGEDIR}/boot/device.hints.gz
1136.endif
1137	@gzip -9n ${IMAGEDIR}/boot/*.4th ${IMAGEDIR}/boot/loader.help \
1138	    ${IMAGEDIR}/boot/defaults/loader.conf
1139	@echo 'bootfile="/kernel"' > ${IMAGEDIR}/boot/loader.conf
1140.if exists(${ACPI_KO})
1141	@gzip -9nc ${ACPI_KO} > ${IMAGEDIR}/acpi.ko.gz
1142	@echo 'acpi_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1143	@echo 'acpi_name="/acpi.ko"' >> ${IMAGEDIR}/boot/loader.conf
1144	@echo 'acpi_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1145.endif
1146	@echo 'mfsroot_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1147	@echo 'mfsroot_type="mfs_root"' >> ${IMAGEDIR}/boot/loader.conf
1148	@echo 'mfsroot_name="/mfsroot"' >> ${IMAGEDIR}/boot/loader.conf
1149.if !exists(${ACPI_KO})
1150	@echo 'mfsroot_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1151.endif
1152.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
1153	@echo "-P" >> ${IMAGEDIR}/boot.config
1154.endif
1155	@rm -f ${IMAGEFILE}
1156	@cp ${KERNFILE} ${MFSROOTFILE} ${IMAGEDIR}
1157	sh -e ${DOFS_SH} ${IMAGEFILE} ${RD} ${MNT} ${FLPSIZE} ${IMAGEDIR} \
1158	    ${BOOTINODE} ${FLPLABEL}
1159	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1160
1161.include <bsd.obj.mk>
1162