Makefile revision 164206
162587Sitojun# $FreeBSD: head/release/Makefile 164206 2006-11-11 23:18:28Z ru $
295023Ssuz#
362587Sitojun# make release [BUILDNAME=somename] CHROOTDIR=/some/dir CVSROOT=/cvs/dir \
454263Sshin#     [RELEASETAG=tag]
554263Sshin#
654263Sshin# Where "/some/dir" is the pathname of a directory on a some filesystem with
754263Sshin# at least 1000MB of free space, "somename" is what you want the release to
854263Sshin# call itself, "/cvs/dir" is where our source repo resides and, optionally,
954263Sshin# which CVS "tag" name should be used when checking out the sources to build
1054263Sshin# the release (default is HEAD).
1154263Sshin#
1254263Sshin# Please note: the md(4) driver must be present in the kernel
1354263Sshin# (either by being compiled in or available as a kld(4) module),
1454263Sshin# otherwise the target 'release.8' and possibly others will fail.
1554263Sshin#
1654263Sshin# Note: If you add options to this file, please keep release(7) updated!
1754263Sshin#
1854263Sshin# Set these, release builder!
1954263Sshin#
2054263Sshin# Fixed version:
2154263Sshin#BUILDNAME=7.0-CURRENT
2254263Sshin#
2354263Sshin# Automatic SNAP versioning:
2454263SshinDATE != date +%Y%m%d
2554263SshinBASE = 7.0
2654263SshinBUILDNAME?=${BASE}-${DATE}-SNAP
2754263Sshin#
2854263Sshin#CHROOTDIR=/junk/release
2954263Sshin# If this is a -stable snapshot, then set
3054263Sshin#RELEASETAG=RELENG_6
3154263Sshin#
3254263Sshin# To test a release with a source tree containing patches and
3354263Sshin# other work. This tree will get copied instead of getting the
3454263Sshin# src/ tree from a CVS checkout. For "rerelease", this will NOT
35101739Srwatson# be copied; cvs update will be used instead.
3654263Sshin#EXTSRCDIR=/usr/src
3754263Sshin#
3854263Sshin# To use a checked-out ports collection directory instead of
3954263Sshin# checking out from a local CVS repository, set this option.
40101182Srwatson#EXTPORTSDIR=/usr/ports
4154263Sshin#
4254263Sshin# To add other options to the CVS subcommands (co,up), set
43129880Sphk#CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
4454263Sshin#
4554263Sshin# To add other options to the CVS command, set
4654263Sshin#CVSARGS="-lfq"
4754263Sshin#
4891270Sbrooks# To prefix the cvs command
4954263Sshin#CVSPREFIX="/usr/bin/time"
5062587Sitojun#
5179106Sbrooks# Where the CVS repository is
5254263Sshin#CVSROOT="/home/ncvs"
5354263Sshin#
5454263Sshin# Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
55130933Sbrooks# are building an official release.  Otherwise, we are building for
5654263Sshin# a branch.
5754263Sshin.if defined(RELEASETAG)
5854263SshinISRELEASE!=	expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
5954263Sshin.if ${ISRELEASE} != 0
6054263Sshin# Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
6154263SshinAUXRELEASETAG!=	echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
6254263SshinDOCRELEASETAG?=		${AUXRELEASETAG}
6378064SumePORTSRELEASETAG?=	${AUXRELEASETAG}
6478064Sume.endif
6554263Sshin.endif
6654263Sshin
6779106Sbrooks# If you want to pass flags to the world build such as -j X, use
6854263Sshin# WORLD_FLAGS.  Similarly, you can specify make flags for kernel
6954263Sshin# builds via KERNEL_FLAGS.
7054263Sshin#WORLD_FLAGS=-j4
7154263Sshin#KERNEL_FLAGS=-j4
7254263Sshin
7354263SshinTARGET_ARCH?=	${MACHINE_ARCH}
7454263Sshin.if ${TARGET_ARCH} == ${MACHINE_ARCH}
7554263SshinTARGET?=	${MACHINE}
7654263Sshin.else
7754263SshinTARGET?=	${TARGET_ARCH}
7862587Sitojun.endif
7954263SshinCROSSENV=	TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
8054263SshinCROSSMAKE=	${MAKE} ${CROSSENV}
8162587SitojunNATIVEMAKE=	${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
8254263Sshin
8354263Sshin# If you are using a local CVS repository with components stored in 
8454263Sshin# non-standard modules, override these on the make commandline or
8554263Sshin# in the environment.
8679106SbrooksRELEASESRCMODULE?=	src
8762587SitojunRELEASEDOCMODULE?=	doc
88127305SrwatsonRELEASEPORTSMODULE?=	ports
89127898Sru
90127305Srwatson# Uncomment this to disable the doc.1 target.  Docs normally require
91127305Srwatson# the ports tree, so NOPORTS can be set together with NODOC in order
92127305Srwatson# to have neither ports or docs.  If only NOPORTS is set to YES, but
9379106Sbrooks# docs are still desired, the DOMINIMALDOCPORTS logic below will only
9489065Smsmith# install the ports that are minimally required for the docs.  This is
9579106Sbrooks# intended as a compromise, less disk space is required than for using
9683998Sbrooks# the entire ports collection (and much less time due to the huge number
9783998Sbrooks# of directories it would create), but still quite a bit as well as some
9883998Sbrooks# CPU cycles (some of the programs are C++, and things like ghostscript
9983998Sbrooks# belong to the required ports nevertheless).
10083998Sbrooks#
101128209Sbrooks# Setting this also disables building of release note documentation
102128209Sbrooks# (RELNOTESng).
10379106Sbrooks#NODOC=  YES
104130933Sbrooks#NOPORTS=  YES
10579106Sbrooks
10692725Salfred# When retrieving ports using the pkg_add -r method, set your proxies to these.
10779106Sbrooks# src/release/${arch}/mkisoimages.sh can use these.
10891270Sbrooks#HTTP_PROXY?=	www.example.com
10991270Sbrooks#FTP_PROXY?=	ftp.example.com
11091270Sbrooks
11162587Sitojun# When creating ISO images, point ${CD_PACKAGE_TREE} to a directory containing
11262587Sitojun# the package split by an earlier invocation of the 'package-split' target.
11391270Sbrooks#CD_PACKAGE_TREE=	/path/to/pkg
11462587Sitojun
11562587Sitojun# Extra source tarballs; each argument is a pair of source dir and
11662587Sitojun# distribution name.  The dist name should not exceed 7 characters
11795023Ssuz# (another "s" for "source" will be prepended).
11862587Sitojun#EXTRA_SRC=	games/fortune fortune
11962587Sitojun
12062587Sitojun# Modify this definition if you want the release notes 
12162587Sitojun# and other release documentation in a language other than English.
12262587SitojunRELNOTES_LANG?=	en_US.ISO8859-1
12391270Sbrooks
12491270Sbrooks# As an alternative to installing the entire ports collection (which
12562587Sitojun# can take a huge amount of time, in particular on slower disks),
12691270Sbrooks# setting ${MINIMALDOCPORTS} allows to install and build just those
12791270Sbrooks# ports that are really required for getting the docs up & running.
12891270Sbrooks.if defined(NOPORTS) && !defined(NODOC)
12991270SbrooksDOMINIMALDOCPORTS=	YES
13091270Sbrooks.include "Makefile.inc.docports"
13191270SbrooksRELEASEPORTSMODULE=	${MINIMALDOCPORTS}
13291270Sbrooks.endif
13391270Sbrooks
13491270Sbrooks# Helper variable
13591270Sbrooks.if defined(NOPORTS)
13691270Sbrooks.if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
13791270SbrooksNOPORTSATALL=	YES
13891270Sbrooks.endif
139128209Sbrooks.endif
14079106Sbrooks
14179106Sbrooks#
14292081Smux# Doing 'make index' in /usr/ports requires Perl.
14354263SshinMAKEINDEXPORTS=	lang/perl5.8
14478064Sume# By default, documentation (Handbook, FAQ, etc.) is built for all
14554263Sshin# the languages.  To speed up building, set the DOC_LANG to just
146131672Sbms# the languages you need.  (The language for the release notes is
14779106Sbrooks# controlled by the RELNOTES_LANG variable above.)
14879106Sbrooks#DOC_LANG=	en_US.ISO8859-1
149121816SbrooksDOCPORTS=	textproc/docproj
15079106Sbrooks# Set this to wherever the distfiles required by release procedures.
151105293Sume.if defined(DOCDISTFILES)
152105293Sume# Respect DOCDISTFILES which is used before.
153127305SrwatsonRELEASEDISTFILES?=	${DOCDISTFILES}
154105293Sume.else
155127305SrwatsonRELEASEDISTFILES?=	${.CURDIR}/../../ports/distfiles
156105293Sume.endif
157105293Sume# Set this to 1 if you want -P to be used for automatic keyboard detection
158105293Sume# on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
159105293SumeAUTO_KEYBOARD_DETECT?= 0
160105293Sume
161105293Sume.if !defined(NODOC)
162105293SumeDIST_DOCS_ARCH_INDEP=	readme errata
163105293SumeDIST_DOCS_ARCH_DEP=	installation relnotes hardware
16479106Sbrooks.endif
16562587Sitojun
166105293Sume# Things which without too much trouble can be considered variables
16779106Sbrooks# BASE_DISTS are special in that they get full /etc installation sets.
16879106Sbrooks#
16978064SumeOTHER_DISTS?=	catpages manpages games proflibs dict info doc ${ARCH_DISTS}
17079106SbrooksBASE_DISTS?=	base
17179106Sbrooks.if ${TARGET_ARCH} == "amd64"
17278064SumeARCH_DISTS?=	lib32
17379106Sbrooks.endif
17479106SbrooksDISTRIBUTIONS?=	${BASE_DISTS} ${OTHER_DISTS}
17579106Sbrooks
17679106Sbrooks#
17779106Sbrooks# Build and package both GENERIC and SMP kernels if the target
17879106Sbrooks# has both configuration files.  Otherwise only GENERIC is done.
17983998Sbrooks#
18083998Sbrooks.if exists(${.CURDIR}/../sys/${TARGET}/conf/SMP)
18179106SbrooksKERNELS_BASE?=	GENERIC SMP
18279106Sbrooks.else
183127305SrwatsonKERNELS_BASE?=	GENERIC
184127305Srwatson.endif
18579106Sbrooks
186127305Srwatson# mountpoint for filesystems.
18779106SbrooksMNT=			/mnt
18879106Sbrooks
189127305Srwatson# Various floppy image parameters.
190105293Sume#
191105293Sume
192105293Sume.undef MAKE_FLOPPIES
193105293Sume.if ${TARGET_ARCH} == "i386"
194105293SumeMAKE_FLOPPIES=		true
195105293Sume.if ${TARGET} == "pc98"
196105293SumeSMALLFLOPPYSIZE=	1200
19779106SbrooksSMALLFLOPPYSPLITSIZE=	1152
19879106SbrooksSMALLFLOPPYLABEL=	fd1200
19979106SbrooksSPLIT_MFSROOT=
20079106Sbrooks.endif
201105293SumeFLOPPYSIZE=		1440
20279106SbrooksFLOPPYSPLITSIZE=	1392
20383998SbrooksFLOPPYINODE=		40000
20483998SbrooksFLOPPYLABEL=		fd1440
20579106SbrooksBOOTINODE=		80000
20679106SbrooksMFSSIZE=		4320
20779106SbrooksMFSINODE=		8000
20879106SbrooksMFSLABEL=		minimum3
20979106Sbrooks.elif ${TARGET_ARCH} == "sparc64"
21079106SbrooksDISKLABEL=		sunlabel
211128209SbrooksMFSSIZE=		4096
212127305SrwatsonMFSINODE=		8192
213127305SrwatsonMFSLABEL=		auto
214127305SrwatsonMINIROOT=
215127305Srwatson.elif ${TARGET_ARCH} == "ia64"
216127305SrwatsonMFSSIZE=		8192
217127305SrwatsonMFSINODE=		8192
218127305SrwatsonMFSLABEL=		auto
219127305SrwatsonSEPARATE_LIVEFS=
220127305Srwatson.elif ${TARGET_ARCH} == "amd64"
221127305SrwatsonMAKE_FLOPPIES=		true
222127305SrwatsonFLOPPYSIZE=		1440
22379106SbrooksFLOPPYSPLITSIZE=	1392
22479106SbrooksFLOPPYINODE=		40000
22579106SbrooksFLOPPYLABEL=		fd1440
22679106SbrooksBOOTINODE=		80000
22779106SbrooksMFSSIZE=		4096
22879106SbrooksMFSINODE=		8192
229127305SrwatsonMFSLABEL=		auto
23079106SbrooksSPLIT_MFSROOT=
23179106Sbrooks.elif ${TARGET_ARCH} == "powerpc"
23279106SbrooksDISKLABEL=		""
233127305SrwatsonMFSSIZE=		4096
23483997SbrooksMFSINODE=		8192
23579106SbrooksMFSLABEL=		auto
23679106SbrooksSEPARATE_LIVEFS=
23779106Sbrooks.endif
23879106Sbrooks.if defined(NO_FLOPPIES)
23962587Sitojun.undef MAKE_FLOPPIES
24079106Sbrooks.endif
24179106Sbrooks
24279106Sbrooks.if exists(/sbin/bsdlabel)
24379106SbrooksDISKLABEL?=		bsdlabel
24479106Sbrooks.else
245127305SrwatsonDISKLABEL?=		disklabel
246127305Srwatson.endif
247127305Srwatson
248127305SrwatsonZIPNSPLIT=		gzip --no-name -9 -c | split -b 1392k -
249127305Srwatson
250127305Srwatson# Things which may get you into trouble if you change them
251127305SrwatsonMTREEFILES=		${.CURDIR}/../etc/mtree
252127305Srwatson_R?=			/R
253127305SrwatsonRD=			${_R}/stage
25479106SbrooksRND=			${RD}/release.doc
25579106SbrooksFD=			${_R}/ftp
25662587SitojunCD=			${_R}/cdrom
25779106SbrooksCD_BOOT=		${CD}/bootonly
258132199SphkCD_DISC1=		${CD}/disc1
259132199SphkCD_DISC2=		${CD}/disc2
26054263Sshin.if defined(SEPARATE_LIVEFS)
26179106SbrooksCD_LIVEFS=		${CD}/livefs
26254263Sshin.else
26354263SshinCD_LIVEFS=		${CD_DISC1}
26479106Sbrooks.endif
26579106Sbrooks_MK?=			${CHROOTDIR}/mk
26679106Sbrooks
26779106Sbrooks# Where the bootstrap ports (see DOCPORTS) get installed.
26879106SbrooksLOCALDIR=		/usr/local/bin
26954263Sshin
27079106Sbrooks.if ${TARGET} != ${MACHINE} && ${DISKLABEL} == "bsdlabel"
27183997SbrooksDOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ${TARGET}
27279106Sbrooks.else
273105293SumeDOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ""
27462587Sitojun.endif
27562587Sitojun
27662587SitojunCRUNCH_TARGETS=	boot
27762587Sitojun.if ${TARGET_ARCH} == "i386"
27862587SitojunCRUNCH_TARGETS+=fixit
27962587Sitojun.if ${TARGET} == "pc98"
28062587SitojunCRUNCH_TARGETS+=fixit-small
28162587Sitojun.endif
28262587Sitojun.endif
28362587Sitojun
28462587Sitojun.if defined(MAKE_FLOPPIES)
28562587SitojunEXTRAS= floppies.1
28662587Sitojun.if ${TARGET_ARCH} == "i386"
28762587SitojunEXTRAS+= floppies.2
28862587Sitojun.endif
28962587SitojunEXTRAS+= floppies.3
29062587Sitojun.endif
29162587SitojunEXTRAS+= ftp.1
29262587Sitojun.if !defined(NOCDROM)
29362587SitojunEXTRAS+= cdrom.1 cdrom.2 cdrom.3
29462587Sitojun.if defined(MAKE_ISOS)
29562587SitojunEXTRAS+= iso.1
29662587Sitojun.endif
29762587Sitojun.if ${TARGET} == "pc98"
29862587SitojunBOOTABLE="-G"
29962587Sitojun.else
30062587SitojunBOOTABLE="-b"
30162587Sitojun.endif
30262587Sitojun.endif
30362587Sitojun
30462587Sitojun.if !defined(NODOC)
30562587SitojunDOCREL= doc.1 doc.2
30662587Sitojun.endif
307105339Sume
308105339Sume.if !make(release) && !make(rerelease) && !make(package-split)
309105339SumeBINMAKE!=	cd ${.CURDIR}/..; ${MAKE} -V BINMAKE
310105339SumeWMAKEENV!=	cd ${.CURDIR}/..; \
31191327Sbrooks		${BINMAKE} ${CROSSENV} -f Makefile.inc1 -V WMAKEENV
31262587SitojunWMAKE=		${WMAKEENV} ${BINMAKE}
31362587Sitojun.endif
31462587Sitojun
31562587SitojunCVS_SRCARGS=	-P
31662587Sitojun.if defined(RELEASETAG)
31762587SitojunCVS_SRCARGS+=	-r ${RELEASETAG}
31862587Sitojun.endif
31962587Sitojun
32062587SitojunCVS_DOCARGS=	-P
32162587Sitojun.if defined(DOCRELEASETAG)
32262587SitojunCVS_DOCARGS+=	-r ${DOCRELEASETAG}
323105293Sume.endif
324105293Sume
32562587SitojunCVS_PORTSARGS=	-P
32662587Sitojun.if defined(PORTSRELEASETAG)
32762587SitojunCVS_PORTSARGS+=	-r ${PORTSRELEASETAG}
32862587Sitojun.endif
32962587Sitojun
33062587SitojunWORLDDIR?=	${.CURDIR}/..
33162587Sitojun
33262587Sitojunrelease rerelease:
33362587Sitojun.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
33462587Sitojun	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
33554263Sshin.endif
33654263Sshin.if defined(NOPORTSATALL) && !defined(NODOC)
33754263Sshin	@echo "Ports are required for building the docs.  Either set NODOC or"
33854263Sshin	@echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
33954263Sshin	@exit 1
34054263Sshin.endif
34154263Sshin.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
34278064Sume.for p in ${LOCAL_PATCHES}
343127898Sru.if !exists(${p})
34454263Sshin	@echo "The patch file ${p} does not exist!"
345127898Sru	@exit 1
34654263Sshin.endif
347101182Srwatson.endfor
348101182Srwatson.endif
349101739Srwatson.if defined(LOCAL_SCRIPT) && !exists(${LOCAL_SCRIPT})
350101739Srwatson	@echo "The local script ${LOCAL_SCRIPT} does not exist!"
351101739Srwatson	@exit 1
352101739Srwatson.endif
353101182Srwatson.if make(release)
354101182Srwatson.if exists(${CHROOTDIR})
35554263Sshin# The first command will fail on a handful of files that have their schg
35654263Sshin# flags set.  But it greatly speeds up the next two commands.
357127898Sru	# NB: clear any vestigial devfs mount, just in case
358127898Sru	-umount ${CHROOTDIR}/dev > /dev/null 2>&1
359127898Sru	-rm -rf ${CHROOTDIR} 2>/dev/null
36054263Sshin	-chflags -R 0 ${CHROOTDIR}/.
36154263Sshin	-rm -rf ${CHROOTDIR}
362127898Sru.endif
363127898Sru	mkdir -p ${CHROOTDIR}
364127898Sru	@echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
365127898Sru	cd ${WORLDDIR} && ${NATIVEMAKE} -DWITHOUT_GAMES -DWITHOUT_HTML -DWITHOUT_LIB32 \
366127898Sru	    -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE installworld DESTDIR=${CHROOTDIR}
367127898Sru	cd ${WORLDDIR} && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
368127898Sru	if [ -f /etc/resolv.conf ]; then \
369127898Sru		cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
370127898Sru	fi
371127898Sru.if defined(EXTLOCALDIR)
372127898Sru	rm -rf ${CHROOTDIR}/usr/local
373127898Sru	cd ${CHROOTDIR}/usr && cp -R -H ${EXTLOCALDIR} local
374127898Sru.endif
375127898Sru	rm -rf ${CHROOTDIR}/usr/src
376127898Sru.if defined(EXTSRCDIR)
37754263Sshin	cd ${CHROOTDIR}/usr && \
37854263Sshin	    cp -R -H ${EXTSRCDIR} src
379127303Srwatson.else
38054263Sshin	cd ${CHROOTDIR}/usr && \
38154263Sshin	    ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
38254263Sshin	    co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
38354263Sshin.endif
384127898Sru.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
385127898Sru.for p in ${LOCAL_PATCHES}
386127898Sru	patch -d ${CHROOTDIR}/usr/${RELEASESRCMODULE} ${PATCH_FLAGS} < ${p}
387127898Sru.endfor
388127898Sru.endif
389127898Sru.if defined(LOCAL_SCRIPT)
390127898Sru	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} \
391127898Sru	    RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
392127898Sru.endif
39362587Sitojun	rm -rf ${CHROOTDIR}/usr/ports
39454263Sshin.if !defined(NOPORTSATALL)
39554263Sshin.if defined(EXTPORTSDIR)
39654263Sshin	cd ${CHROOTDIR}/usr && cp -R -H ${EXTPORTSDIR} ports
39754263Sshin	# If there are distfiles downloaded removing them
39854263Sshin	rm -rf ports/distfiles/*
39954263Sshin.else
40054263Sshin	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
40154263Sshin	    co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
40254263Sshin.endif
40378064Sume.endif
404123922Ssam.if !defined(NODOC)
40554263Sshin	rm -rf ${CHROOTDIR}/usr/doc
40662587Sitojun.if defined(EXTDOCDIR)
40754263Sshin	cd ${CHROOTDIR}/usr && cp -R -H ${EXTDOCDIR} doc
40854263Sshin.else
40978064Sume	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
41078064Sume	    co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
41162587Sitojun.endif
41262587Sitojun	if [ -d ${RELEASEDISTFILES}/ ]; then \
41378064Sume		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
41454263Sshin	else \
41554263Sshin		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
41654263Sshin	fi
417105340Sume.if !defined(NO_PREFETCHDISTFILES)
41854263Sshin	@cd ${.CURDIR} && ${MAKE} fetch-distfiles
41954263Sshin.endif
42054263Sshin.endif
42154263Sshin.endif
422105340Sume.if make(rerelease)
42354263Sshin.if !defined(RELEASENOUPDATE) && !defined(EXTSRCDIR)
42454263Sshin.if !defined(RELEASETAG)
42554263Sshin	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
42662587Sitojun	    update ${CVSCMDARGS} -P -d -A
42754263Sshin.else
42878064Sume	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
42954263Sshin	    update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
43054263Sshin.endif
43154263Sshin	rm -f ${CHROOTDIR}/tmp/.world_done 
43278064Sume.if !defined(NOPORTS) && !defined(EXTPORTSDIR)
43378064Sume	cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
43454263Sshin	    update ${CVSCMDARGS} -P -d
43554263Sshin	rm -f ${CHROOTDIR}/tmp/.skip_ports_index
43654263Sshin.endif
43754263Sshin.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
438105338Sume	for i in ${MINIMALDOCPORTS}; do \
43954263Sshin	    ( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
44054263Sshin		update ${CVSCMDARGS} -P -d ) ; \
441105338Sume	done
44254263Sshin.endif
44369152Sjlemon.if !defined(NODOC)
44454263Sshin	cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
445105338Sume	    update ${CVSCMDARGS} -P -d
44654263Sshin.endif
44754263Sshin.endif
44854263Sshin.endif
44954263Sshin	# Add version information to those things that need it.
45054263Sshin	if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
451105338Sume		cd ${CHROOTDIR}/usr/src/sys/conf && \
452101182Srwatson		mv newvers.sh foo && \
453101182Srwatson		sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && \
454105338Sume		rm foo; \
455101182Srwatson	fi
456101182Srwatson	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
457105338Sume	echo "#!/bin/sh"			> ${_MK}
45878064Sume	echo "set -ex"				>> ${_MK}
459123922Ssam	echo "trap 'umount /dev || true' 0"	>> ${_MK}
46054263Sshin	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${_MK}
46154263Sshin.for var in \
46283998Sbrooks	AUTO_KEYBOARD_DETECT \
463105338Sume	BUILDNAME \
46483998Sbrooks	CD_PACKAGE_TREE \
46583998Sbrooks	DISTRIBUTIONS \
46683998Sbrooks	DOC_LANG \
46783998Sbrooks	DOMINIMALDOCPORTS \
46854263Sshin	EXTRA_SRC \
46954263Sshin	FTP_PASSIVE_MODE \
47054263Sshin	FTP_PROXY \
47154263Sshin	HTTP_PROXY \
47295023Ssuz	KERNELS \
47354263Sshin	KERNELS_BASE \
47495023Ssuz	KERNEL_FLAGS \
47554263Sshin	MAKE_FLOPPIES \
47695023Ssuz	MAKE_ISOS \
47795023Ssuz	NOCDROM \
47854263Sshin	NODOC \
47954263Sshin	NOPORTS \
48054263Sshin	NO_SHARED \
48154263Sshin	NOSRC \
48254263Sshin	NO_CPU_CFLAGS \
48354263Sshin	NO_CPU_COPTFLAGS \
48454263Sshin	NO_FLOPPIES \
48554263Sshin	RELEASETAG \
48654263Sshin	RELNOTES_LANG \
48754263Sshin	SEPARATE_LIVEFS \
48854263Sshin	TARGET \
48954263Sshin	TARGET_ARCH \
49054263Sshin	WORLD_FLAGS
49183998Sbrooks.if defined(${var})
492105338Sume	echo "export ${var}=\"${${var}}\""	>> ${_MK}
49383998Sbrooks.endif
49483998Sbrooks.endfor
49554263Sshin	# Don't remove this, or the build will fall over!
49654263Sshin	echo "export RELEASEDIR=${_R}"		>> ${_MK}
49754263Sshin	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${_MK}
498105338Sume	echo "export MANBUILDCAT=YES"		>> ${_MK}
499105338Sume	# NB: these may fail if the host is running w/o devfs
500111888Sjlemon	echo "umount /dev >/dev/null 2>&1 || true" >> ${_MK}
50154263Sshin	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true"	>> ${_MK}
50254263Sshin	echo "if [ ! -c /dev/null ]; then" >> ${_MK}
50362587Sitojun	echo "	echo /dev/null is not a device!" >> ${_MK}
50454263Sshin	echo "	exit 1" >> ${_MK}
50554263Sshin	echo "fi" >> ${_MK}
50654263Sshin	echo "if [ -x /etc/rc.d/ldconfig ]; then" >> ${_MK}
50754263Sshin	echo "	/etc/rc.d/ldconfig start"	>> ${_MK}
50854263Sshin	echo "else"				>> ${_MK}
50954263Sshin	echo "	ldconfig /lib /usr/lib /usr/local/lib || true" >> ${_MK}
51054263Sshin	echo "fi"				>> ${_MK}
51154263Sshin	echo "if [ ! -f /tmp/.world_done ]; then" >> ${_MK}
51254263Sshin	echo "	cd /usr/src"			>> ${_MK}
51362587Sitojun	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNO_CLEAN buildworld && \\" >> ${_MK}
514105339Sume	echo "	touch /tmp/.world_done || exit 1" >> ${_MK}
515105339Sume	echo "fi"				>> ${_MK}
516105339Sume	echo "if [ ! -f /tmp/.skip_ports_index ]; then" >> ${_MK}
517105339Sume	echo "	echo \">>> make index started on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
51854263Sshin	echo "	for i in ${MAKEINDEXPORTS}"	>> ${_MK}
51954263Sshin	echo "	do"			>> ${_MK}
520105293Sume	echo "		cd /usr/ports/\$${i}"	>> ${_MK}
52154263Sshin	echo "		env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \\" >> ${_MK}
52262587Sitojun	echo "		make all install clean BATCH=yes FORCE_PKG_REGISTER=yes" >> ${_MK}
52354263Sshin	echo "	done"				>> ${_MK}
52454263Sshin	echo "	cd /usr/ports"			>> ${_MK}
52554263Sshin	echo "	rm -f INDEX*"			>> ${_MK}
52654263Sshin	echo "	make index -DINDEX_PRISTINE"	>> ${_MK}
52754263Sshin	echo "	rm -f INDEX*.tmp"		>> ${_MK}
52854263Sshin	echo "	touch /tmp/.skip_ports_index"	>> ${_MK}
52954263Sshin	echo "	echo \">>> make index finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
53062587Sitojun	echo "fi"				>> ${_MK}
53154263Sshin	echo "cd /usr/src/release"		>> ${_MK}
53254263Sshin	echo "make obj"				>> ${_MK}
53362587Sitojun	echo "make \$${_RELTARGET}"		>> ${_MK}
53454263Sshin	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
535105339Sume	chmod 755 ${_MK}
536105339Sume.if defined(NOPORTS)
537105339Sume	touch ${CHROOTDIR}/tmp/.skip_ports_index
538105339Sume.endif
53954263Sshin	# Ensure md.ko is loaded if md(4) is not statically compiled into 
54062587Sitojun	# the kernel
54154263Sshin	-mdconfig 2>/dev/null
542105339Sume	env -i /usr/sbin/chroot `dirname ${_MK}` /`basename ${_MK}`
54354263Sshin
544105339Sumeclean:
54554263Sshin	rm -rf ${CRUNCH_TARGETS:S/$/_crunch/} release.[0-8] ${EXTRAS}
54654263Sshin
54754263Sshinfetch-distfiles:
54878064Sume	@for i in ${MAKEINDEXPORTS}; do \
54962587Sitojun		cd ${CHROOTDIR}/usr/ports/$$i && \
55078064Sume			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
55162587Sitojun			checksum-recursive ; \
55254263Sshin	done
55354263Sshin	@for i in ${DOCPORTS}; do \
55454263Sshin		cd ${CHROOTDIR}/usr/ports/$$i && \
55554263Sshin			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
55662587Sitojun			WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
55778064Sume			checksum-recursive ; \
55862587Sitojun	done
55962587Sitojun
56062587Sitojun# Clean out ${_R} and make the directory structure.
56162587Sitojunrelease.1:
56262587Sitojun	mkdir -p ${_R}
56362587Sitojun	-rm -rf ${_R}/* 2> /dev/null
56462587Sitojun	-chflags -R noschg ${_R}/.
56562587Sitojun	rm -rf ${_R}/*
56678064Sume	mkdir ${RD}
56778064Sume.if defined(MAKE_FLOPPIES)
56878064Sume	mkdir ${RD}/floppies
56978064Sume.endif
57078064Sume	mkdir ${RD}/trees
571105293Sume	for i in ${DISTRIBUTIONS}; do \
57291327Sbrooks		mkdir ${RD}/trees/$$i && \
573105293Sume		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
57462587Sitojun		    -p ${RD}/trees/$$i > /dev/null && \
57554263Sshin		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
57678064Sume		    -p ${RD}/trees/$$i/usr > /dev/null && \
57778064Sume		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
57878064Sume		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
57978064Sume		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
58078064Sume		    -p ${RD}/trees/$$i/var > /dev/null ; \
58178064Sume	done
58278064Sume	mkdir ${RD}/kernels
58378064Sume	for i in ${KERNELS_BASE} ${KERNELS}; do \
58478064Sume		mkdir -p ${RD}/kernels/$${i}; \
58578064Sume	done
58678064Sume	touch ${.TARGET}
58778064Sume
58878064Sume# Install the system into the various distributions.
58978064Sumerelease.2:
59078064Sume	cd ${.CURDIR}/.. && ${CROSSMAKE} distrib-dirs DESTDIR=${RD}/trees/base
59178064Sume	cd ${.CURDIR}/.. && ${CROSSMAKE} ${WORLD_FLAGS} distributeworld \
59278064Sume	    DISTDIR=${RD}/trees
59378064Sume	touch ${.TARGET}
59478064Sume
59578064Sume# Make and install the generic kernel(s).
59678064Sumerelease.3:
59778064Sume.for kernel in ${KERNELS_BASE} ${KERNELS}
59878064Sume	cd ${.CURDIR}/..; \
59978064Sume	${CROSSMAKE} ${KERNEL_FLAGS} \
60078064Sume 	    KERNCONF=${kernel} kernel \
60178064Sume 	    DESTDIR=${RD}/kernels KODIR=/${kernel}
60278064Sume.endfor
60378064Sume	touch ${.TARGET}
60478064Sume
60578064Sume# Make and install the three crunched binaries which live on the floppies.
60678064Sume# You are not supposed to like this :-)
60778064Sumerelease.4:
60878064Sume	rm -rf ${RD}/crunch
60978064Sume	mkdir -p ${RD}/crunch
61078064Sume.for j in ${CRUNCH_TARGETS}
61178064Sume.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
61278064Sume	rm -rf ${j}_crunch
61378064Sume	mkdir ${j}_crunch
61478064Sume	cd ${j}_crunch; ${WMAKEENV} MAKEFLAGS="-m ${.CURDIR}/../share/mk" \
61578064Sume	    crunchgen -o \
61678064Sume	    ${.CURDIR}/${TARGET}/${j}_crunch.conf
61778064Sume	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
61878064Sume	cd ${.CURDIR}/..; ${BINMAKE} -f Makefile.inc1 _build-tools
61978064Sume	cd ${j}_crunch; CFLAGS="-Os -pipe" ${WMAKE} -f ${j}_crunch.mk \
62078064Sume	    -DNO_CPU_CFLAGS all
62178064Sume	${WMAKEENV} strip -R .comment ${j}_crunch/${j}_crunch
62278064Sume	mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
62378064Sume.endif
62478064Sume.endfor
62578064Sume	touch ${.TARGET}
62678064Sume
62778064Sume#
62878064Sume# --==## Fix up the distributions. ##==--
62978064Sume#
63078064Sumerelease.5:
631105293Sume	# Create any "synthetic dists" now.
63262587Sitojun	@for i in ${DISTRIBUTIONS}; do \
63362587Sitojun		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
63462587Sitojun			echo -n "Running $$i dist creation script... "; \
63562587Sitojun			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
636105293Sume			echo "Done."; \
63754263Sshin		fi \
63862587Sitojun	done \
63962587Sitojun
64054263Sshin	# Remove all the directories we don't need.
64154263Sshin	-cd ${RD}/trees && \
64254263Sshin		(find ${OTHER_DISTS} -path '*/var/empty' | xargs chflags noschg; \
64354263Sshin		find ${OTHER_DISTS} -depth -type d -empty -print | xargs rmdir)
64454263Sshin	touch ${.TARGET}
64554263Sshin
64654263Sshin#
64754263Sshin# --==## Package up the tarballs from assembled trees ##==--
64854263Sshin#
64978064Sumerelease.6:
65054263Sshin	rm -rf ${RD}/dists
65178064Sume	mkdir -p ${RD}/dists
65254263Sshin	@for i in ${DISTRIBUTIONS} ; \
65378064Sume	do \
65454263Sshin		if [ -d ${RD}/trees/$${i} ] ; then \
65554263Sshin			cd ${.CURDIR} && $(MAKE) doTARBALL \
65654263Sshin				SD=${RD}/trees/$${i} \
65778064Sume				TN=$$i TD=$$i ARG="." && \
65854263Sshin			echo "$${i} distribution is finished."; \
65954263Sshin		fi ; \
66078064Sume	done
66154263Sshin	@for i in ${KERNELS_BASE} ${KERNELS} ; \
66254263Sshin	do \
66354263Sshin		if [ -d ${RD}/kernels/$${i} ] ; then \
66454263Sshin			cd ${.CURDIR} && $(MAKE) doTARBALL \
66554263Sshin				SD=${RD}/kernels \
66654263Sshin				TN=$$i TD=kernels ARG="$$i" && \
66778064Sume			echo "$${i} distribution is finished."; \
66878064Sume		fi ; \
66978064Sume	done
67054263Sshin.if !defined(NOPORTS)
67162587Sitojun	# XXX: Inline stripped version of doTARBALL
67254263Sshin	@rm -rf ${RD}/dists/ports/ports*
67354263Sshin	@mkdir -p ${RD}/dists/ports
67454263Sshin	@echo rolling ports/ports tarball
67554263Sshin	@tar --exclude CVS --exclude 'ports/distfiles/*' \
67654263Sshin	  -czf ${RD}/dists/ports/ports.tgz -C /usr ports
67754263Sshin	@cp ${.CURDIR}/scripts/ports-install.sh ${RD}/dists/ports/install.sh
67854263Sshin	@(cd ${RD}/dists/ports; \
67954263Sshin	  rm -f CHECKSUM.MD5 CHECKSUM.SHA256; \
68054263Sshin	  md5 * > .CHECKSUM.MD5; \
68178064Sume	  sha256 * > .CHECKSUM.SHA256; \
68254263Sshin	  mv .CHECKSUM.MD5 CHECKSUM.MD5; \
68378064Sume	  mv .CHECKSUM.SHA256 CHECKSUM.SHA256)
68454263Sshin	@echo "ports distribution is finished."
68578064Sume.endif
68654263Sshin	touch ${.TARGET}
68754263Sshin
68854263Sshin
68978064Sume#
69054263Sshin# --==## Make source dists ##==--
69154263Sshin#
69278064Sumerelease.7:
69354263Sshin.if !defined(NOSRC)
69454263Sshin	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
69554263Sshin		TD=src TN=sbase ARG="[A-Z]*"
69654263Sshin	@for i in `cd /usr/src && echo [a-z]*` ; do \
69754263Sshin		if [ -d /usr/src/$$i ] ; then \
69854263Sshin			cd ${.CURDIR} && $(MAKE) doTARBALL \
69978064Sume				TN=`echo s$$i | tr -d '.' | \
70078064Sume				    sed -e 's/usr/u/' \
70178064Sume					-e 's/kerberos5/krb5/'` \
70254263Sshin				SD=/usr/src TD=src ARG="$$i" ; \
70354263Sshin		fi ; \
70478064Sume	done
70578064Sume.if defined(EXTRA_SRC)
70678064Sume	@set ${EXTRA_SRC} && \
70778064Sume	while [ $$# -ge 2 ] ; do \
70878064Sume		if [ -d /usr/src/$$1 ] ; then \
70978064Sume			cd ${.CURDIR} && $(MAKE) doTARBALL \
71078064Sume				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
71178064Sume		fi && shift && shift ; \
71278064Sume	done
71378064Sume.endif
71478064Sume	(cd ${RD}/dists/src; \
71578064Sume	  rm -f CHECKSUM.MD5 CHECKSUM.SHA256; \
71678064Sume	  md5 * > .CHECKSUM.MD5; \
71778064Sume	  sha256 * > .CHECKSUM.SHA256; \
71878064Sume	  mv .CHECKSUM.MD5 CHECKSUM.MD5; \
71978064Sume	  mv .CHECKSUM.SHA256 CHECKSUM.SHA256)
72078064Sume	@echo "src distribution is finished."
72178064Sume.endif
72278064Sume	touch ${.TARGET}
72378064Sume
72478064Sume# Build the memory root filesystem.
72578064Sumerelease.8:
72678064Sume	cp ${RD}/trees/base/etc/disktab /etc
72778064Sume	rm -rf ${RD}/mfsfd
72878064Sume	mkdir ${RD}/mfsfd
72954263Sshin	cd ${RD}/mfsfd && \
73062587Sitojun		mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help \
73154263Sshin		var/empty
73254263Sshin	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
73354263Sshin		DIR=${RD}/mfsfd/stand ZIP=false
73454263Sshin	( cd ${RD}/mfsfd && \
73554263Sshin	  for dir in bin sbin ; do \
73654263Sshin		ln -sf /stand $$dir; \
73754263Sshin	  done )
73854263Sshin	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
73954263Sshin.if ${TARGET} == "pc98"
74079106Sbrooks	cp ${.CURDIR}/../etc/defaults/pccard.conf \
741127305Srwatson	    ${RD}/mfsfd/etc/defaults/pccard.conf
742127305Srwatson.endif
743127305Srwatson	cp ${.CURDIR}/../etc/master.passwd ${RD}/mfsfd/etc/master.passwd
744127305Srwatson	cp ${RD}/trees/base/etc/*pwd.db ${RD}/mfsfd/etc/
745127305Srwatson	( for F in defaults/rc.conf netconfig protocols ; do \
746127305Srwatson		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
747127305Srwatson		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
748105293Sume	  done )
749105293Sume	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
750105293Sume	    ${RD}/trees/base/etc/services | \
751105293Sume	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
752105293Sume	    > ${RD}/mfsfd/stand/etc/services
753105293Sume	grep 'operator' ${RD}/trees/base/etc/group \
754105293Sume	    > ${RD}/mfsfd/stand/etc/group
755105293Sume	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
756105293Sume	ln ${RD}/mfsfd/stand/etc/group ${RD}/mfsfd/etc/group
757105293Sume	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
758105293Sume	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
759105293Sume.if !defined(NODOC)
760105293Sume	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
761105293Sume	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
762127305Srwatson	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
763105293Sume	done
764105293Sume	@for i in ${DIST_DOCS_ARCH_DEP}; do \
765105293Sume	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
766105293Sume	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
767105293Sume	done
768105293Sume	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT \
769105293Sume	    ${RD}/mfsfd/stand/help/INSTALL.TXT
770105293Sume.endif
771105293Sume	-test -f ${.CURDIR}/install.cfg \
772105293Sume	    && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
773105293Sume	@mkdir -p ${RD}/mfsfd/boot
774105293Sume.if ${TARGET_ARCH} != "ia64" && ${TARGET_ARCH} != "powerpc"
775105293Sume	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
776105293Sume.endif
777105293Sume.if ${TARGET} == "i386" || ${TARGET_ARCH} == "amd64"
778105293Sume	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
779105293Sume.endif
780105293Sume	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
781105293Sume		tar xf - -C ${RD}/mfsfd/stand
782127305Srwatson	@mkdir -p ${RD}/mfsroot
783105293Sume	sh -e ${DOFS_SH} ${RD}/mfsroot/mfsroot ${RD} ${MNT} \
784105293Sume	    ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
785105293Sume	@gzip -9fnv ${RD}/mfsroot/mfsroot
786105293Sume	touch ${.TARGET}
787105293Sume
788127305SrwatsonKERNFLOPPYSET=		${RD}/floppyset/kern/kernel.gz
789105293Sume.if defined(SMALLFLOPPYSIZE)
790105293SumeSMALLKERNFLOPPYSET=	${RD}/floppyset/kern-small/kernel.gz
791105293Sume.endif
792105293Sume.if defined(SPLIT_MFSROOT)
793105293SumeMFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot/mfsroot.gz
794105293Sume.if defined(SMALLFLOPPYSIZE)
795105293SumeSMALLMFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot-small/mfsroot.gz
796105293Sume.endif
797105293Sume.endif
798105293Sume
799105293Sume# Build boot and install floppies.
800105293Sumefloppies.1:
801105293Sume	@gzip -9nc ${RD}/kernels/GENERIC/kernel > ${RD}/kernels/kernel.gz
802105293Sume	@echo "Making the kernel boot floppies..."
803105293Sume	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern \
804105293Sume	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz
805105293Sume.if defined(SMALLFLOPPYSIZE)
806111119Simp	@echo "Making the small kernel boot floppies..."
807105293Sume	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern-small \
808105293Sume	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz \
809105293Sume	    FDSIZE="SMALL"
810105293Sume.endif
811111119Simp.if defined(SPLIT_MFSROOT)
812105293Sume	@echo "Making the mfsroot boot floppies..."
813105293Sume	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot \
814105293Sume	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz
815105293Sume.if defined(SMALLFLOPPYSIZE)
816105293Sume	@echo "Making the small mfsroot boot floppies..."
817105293Sume	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot-small \
818105293Sume	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz \
819105293Sume	    FDSIZE="SMALL"
820105293Sume.endif
821105293Sume	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
822105293Sume	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
823105293Sume	    MFSROOTFILE="${MFSROOTFLOPPYSET}.split ${MFSROOTFLOPPYSET}.boot"
824105293Sume.if defined(SMALLFLOPPYSIZE)
825105293Sume	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
826105293Sume	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
827105293Sume	    MFSROOTFILE="${SMALLMFSROOTFLOPPYSET}.split ${SMALLMFSROOTFLOPPYSET}.boot" \
828105293Sume	    FDSIZE="SMALL"
829105293Sume.endif
830105293Sume.else	# !SPLIT_MFSROOT
831105293Sume	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
832105293Sume	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
833105293Sume	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz
834105293Sume.if defined(SMALLFLOPPYSIZE)
835105293Sume	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
836105293Sume	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
837105293Sume	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz \
838105293Sume	    FDSIZE="SMALL"
839105293Sume.endif
840105293Sume.endif	# SPLIT_MFSROOT
841105293Sume	touch ${.TARGET}
842105293Sume
843105293Sume# Build fixit floppy.
844105293Sumefloppies.2:
845105293Sume	@echo "Making fixit floppy."
846105293Sume	@rm -rf ${RD}/fixitfd
847105293Sume	@mkdir ${RD}/fixitfd
848105293Sume	@cd ${RD}/fixitfd && \
849105293Sume	    mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
850105293Sume	    usr/share/misc
851105293Sume	@cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
852105293Sume	    ${RD}/fixitfd/etc
853105293Sume	@sed -e 's/#.*//' ${RD}/trees/base/etc/protocols \
854105293Sume	    > ${RD}/fixitfd/etc/protocols
855105293Sume	@sed -e 's/#.*//' ${RD}/trees/base/usr/share/misc/scsi_modes \
856105293Sume	    > ${RD}/fixitfd/usr/share/misc/scsi_modes
857105293Sume	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
858105293Sume	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
85979106Sbrooks	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
860105293Sume	@chmod 555 ${RD}/fixitfd/stand/tar
861105293Sume.if defined(SMALLFLOPPYSIZE)
86279106Sbrooks	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit-small \
863105293Sume	    DIR=${RD}/fixitfd/stand ZIP=false
864105293Sume	@sh -e ${DOFS_SH} ${RD}/floppies/fixit-small.flp ${RD} ${MNT} \
86579106Sbrooks	    ${SMALLFLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${SMALLFLOPPYLABEL}
866105293Sume	@rm -rf ${RD}/fixitfd/stand
867105293Sume	@mkdir ${RD}/fixitfd/stand
86879106Sbrooks.endif
86979106Sbrooks	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
87079106Sbrooks	    DIR=${RD}/fixitfd/stand ZIP=false
87179106Sbrooks	@sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} ${MNT} \
87279106Sbrooks	    ${FLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${FLOPPYLABEL}
87379106Sbrooks	touch ${.TARGET}
87479106Sbrooks
87579106Sbrooks# Do our last minute floppies directory setup
876105293Sumefloppies.3:
877105293Sume.if !defined(NODOC)
878105293Sume	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
879105293Sume	    ${RD}/floppies/README.TXT
880105293Sume	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
881105293Sume	@(cd ${RD}/floppies; sha256 README.TXT *.flp > CHECKSUM.SHA256)
882105293Sume.else
883105293Sume	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
884105293Sume	@(cd ${RD}/floppies; sha256 *.flp > CHECKSUM.SHA256)
885105293Sume.endif
886105293Sume	touch ${.TARGET}
887105293Sume
888105293Sume#
88979106Sbrooks# --==## Setup a suitable ftp-area ##==--
890#
891ftp.1:
892	@echo "Setting up FTP distribution area"
893	@mkdir -p ${FD}
894	-@ln -s . ${FD}/${BUILDNAME}
895.if defined(MAKE_FLOPPIES)
896	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
897.endif
898	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
899.if !defined(NODOC)
900	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
901		cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
902		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
903		cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
904		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
905	done
906	@for i in ${DIST_DOCS_ARCH_DEP}; do \
907		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
908		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
909		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
910		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
911	done
912	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
913	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
914	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
915.endif
916	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
917	touch ${.TARGET}
918
919# Build a live filesystem cdrom image
920cdrom.1:
921	@echo "Building CDROM live filesystem image"
922	@mkdir -p ${CD_LIVEFS}
923	@for i in ${DISTRIBUTIONS} ; \
924	do \
925		if [ -d ${RD}/trees/$${i} ] ; then \
926			chflags -R noschg ${RD}/trees/$${i} || true ; \
927			( cd ${RD}/trees/$${i} && \
928			    find . -depth -print | cpio -dumpl ${CD_LIVEFS} ) ; \
929		fi \
930	done
931	@echo "Copy GENERIC kernel to boot area"
932	@cp -Rp ${RD}/kernels/GENERIC/ ${CD_LIVEFS}/boot/kernel
933	@rm -f ${CD_LIVEFS}/.profile
934	@cp ${.CURDIR}/fixit.profile ${CD_LIVEFS}/.profile
935	@ln -sf /rescue ${CD_LIVEFS}/stand
936	@echo "Setting up CDROM boot area"
937	@rm -f ${CD_LIVEFS}/boot/loader.conf
938	@cp ${RD}/mfsroot/mfsroot.gz ${CD_LIVEFS}/boot/mfsroot.gz
939	@echo 'mfsroot_load="YES"' > ${CD_LIVEFS}/boot/loader.conf
940	@echo 'mfsroot_type="mfs_root"' >> ${CD_LIVEFS}/boot/loader.conf
941	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_LIVEFS}/boot/loader.conf
942.if exists(${RD}/trees/base/boot/device.hints)
943	# Break the link to device.hints so we can modify it
944	@rm -f ${CD_LIVEFS}/boot/device.hints
945	@cp ${RD}/trees/base/boot/device.hints ${CD_LIVEFS}/boot/device.hints
946.endif
947	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_LIVEFS}/cdrom.inf
948	touch ${.TARGET}
949
950# Build disc1 and disc2 cdrom images
951cdrom.2:
952	@echo "Building CDROM disc1 filesystem image"
953	@mkdir -p ${CD_DISC1}/${BUILDNAME}
954.if defined(MAKE_FLOPPIES)
955	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
956.endif
957	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}/${BUILDNAME}
958.if !defined(NODOC)
959	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
960	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
961	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
962	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
963	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
964	done
965	@for i in ${DIST_DOCS_ARCH_DEP}; do \
966	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
967	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
968	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
969	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
970	done
971	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
972	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
973	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
974.endif
975.if defined(SEPARATE_LIVEFS)
976	@cp -Rp ${CD_LIVEFS}/boot ${CD_DISC1}
977	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
978.endif
979	@echo "CD_VOLUME = 1" >> ${CD_DISC1}/cdrom.inf
980	@echo "Building CDROM disc2 filesystem image"
981	@mkdir -p ${CD_DISC2}
982	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
983	@echo "CD_VOLUME = 2" >> ${CD_DISC2}/cdrom.inf
984.if !defined(NODOC)
985	@mkdir -p ${CD_DISC2}/usr/share/doc
986	@for i in `ls ${CD_LIVEFS}/usr/share/doc`; do \
987		if [ -L ${CD_LIVEFS}/usr/share/doc/$$i -o \
988		    -d /usr/doc/$$i ]; then \
989			mv ${CD_LIVEFS}/usr/share/doc/$$i \
990			    ${CD_DISC2}/usr/share/doc; \
991		fi \
992	done
993.endif
994	touch ${.TARGET}
995
996#
997# --==## Setup a suitable cdrom-area ##==--
998#
999cdrom.3:
1000.if defined(CD_BOOT)
1001	@echo "Building bootonly CDROM filesystem image"
1002	@mkdir -p ${CD_BOOT}
1003	@cp -Rp ${CD_LIVEFS}/boot ${CD_BOOT}
1004	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_BOOT}/cdrom.inf
1005.if defined(MINIROOT)
1006	@echo "Building bootonly UFS filesystem image"
1007	@mkdir -p ${FD}/miniroot
1008	@sh -e ${DOFS_SH} ${FD}/miniroot/miniroot.ufs \
1009	    ${RD} ${MNT} 0 ${CD_BOOT} 8192 auto
1010	@gzip -9v ${FD}/miniroot/miniroot.ufs
1011.endif
1012.endif
1013	touch ${.TARGET}
1014
1015.if make(iso.1)
1016.if defined(CD_PACKAGE_TREE)
1017.if exists(${CD_PACKAGE_TREE}/disc1)
1018CD_DISC1_PKGS=	${CD_PACKAGE_TREE}/disc1
1019.endif
1020.if exists(${CD_PACKAGE_TREE}/disc2)
1021CD_DISC2_PKGS=	${CD_PACKAGE_TREE}/disc2
1022.endif
1023.endif
1024.endif
1025
1026iso.1:
1027.if exists(${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh)
1028	@echo "Creating ISO images..."
1029.if defined(CD_BOOT)
1030	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
1031	    FreeBSD_bootonly \
1032	    ${CD}/${BUILDNAME}-${TARGET}-bootonly.iso ${CD_BOOT}
1033.endif
1034	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
1035	    FreeBSD_Install \
1036	    ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} \
1037	    ${CD_DISC1_PKGS}
1038	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh \
1039	    FreeBSD_Packages \
1040	    ${CD}/${BUILDNAME}-${TARGET}-disc2.iso ${CD_DISC2} \
1041	    ${CD_DISC2_PKGS}
1042.if defined(SEPARATE_LIVEFS)
1043	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
1044	    FreeBSD_LiveFS \
1045	    ${CD}/${BUILDNAME}-${TARGET}-livefs.iso ${CD_LIVEFS}
1046.endif
1047	@echo "Generating MD5 and SHA256 sums..."
1048	@(cd ${CD} && md5 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.MD5)
1049	@(cd ${CD} && sha256 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.SHA256)
1050	touch ${.TARGET}
1051.else
1052	@echo "Do not know how to create an ISO for ${TARGET_ARCH}."
1053.endif
1054
1055#
1056# --==## Documentation Project files such as the Handbook and FAQ ##==--
1057#
1058doc.1:
1059	@echo "Making docs..."
1060	@for i in ${DOCPORTS}; do \
1061	    cd /usr/ports/$$i && \
1062	    env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \
1063		make all install clean BATCH=yes WITHOUT_X11=yes JADETEX=no \
1064		WITHOUT_PYTHON=yes FORCE_PKG_REGISTER=yes; \
1065	done
1066	@cd /usr/doc && make all install 'FORMATS=html html-split txt' \
1067	    INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc \
1068	    URLS_ABSOLUTE=YES	
1069	touch ${.TARGET}
1070
1071#
1072# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
1073#
1074doc.2:
1075	@echo "Making release documentation..."
1076	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' \
1077	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${RND}
1078	touch ${.TARGET}
1079
1080# Various "subroutine" and other supporting targets.
1081
1082# RD=
1083# SD=
1084# TD=
1085# ARG=
1086doTARBALL:
1087.if !defined(SD)
1088	@echo "SD undefined in doTARBALL" && exit 1
1089.endif
1090.if !defined(TD)
1091	@echo "TD undefined in doTARBALL" && exit 1
1092.endif
1093.if !defined(ARG)
1094	@echo "ARG undefined in doTARBALL" && exit 1
1095.endif
1096	@rm -rf ${RD}/dists/${TD}/${TN}*
1097	@mkdir -p ${RD}/dists/${TD}
1098	@( cd ${SD} && \
1099		tn=`echo ${TN} | tr 'A-Z' 'a-z'` && \
1100		echo rolling ${TD}/$$tn tarball &&\
1101		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
1102		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
1103		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn \
1104		    > ${RD}/dists/${TD}/$$tn.inf && \
1105		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
1106			cp -p ${.CURDIR}/scripts/$${TD}-install.sh \
1107			    ${RD}/dists/${TD}/install.sh && \
1108			chmod +x ${RD}/dists/${TD}/install.sh; \
1109		fi && \
1110		if [ "${SD}" != "/usr/src" ]; then \
1111			mtree -c -i -p ${SD}/${ARG} \
1112			  -k gname,md5digest,mode,nlink,uname,size,link,type \
1113			  > ${RD}/dists/${TD}/$$tn.mtree ; \
1114		else \
1115			true; \
1116		fi; \
1117		( cd ${RD}/dists/${TD}; \
1118		rm -f CHECKSUM.MD5 CHECKSUM.SHA256; \
1119		md5 * > .CHECKSUM.MD5; \
1120		sha256 * > .CHECKSUM.SHA256; \
1121		mv .CHECKSUM.MD5 CHECKSUM.MD5; \
1122		mv .CHECKSUM.SHA256 CHECKSUM.SHA256) \
1123	)
1124
1125doRELEASE: release.1 release.2 ${DOCREL} release.3 release.4 \
1126    release.5 release.6 release.7 release.8 ${EXTRAS}
1127	@echo "Release done"
1128
1129floppies:
1130	@rm -f release.4 release.8 floppies.[123]
1131	@cd ${.CURDIR} && ${MAKE} release.4 release.8 floppies.1 floppies.2 \
1132	    floppies.3
1133	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
1134
1135installCRUNCH:
1136.if !defined(CRUNCH)
1137	@echo "CRUNCH undefined in installCRUNCH" && exit 1
1138.endif
1139.if !defined(DIR)
1140	@echo "DIR undefined in installCRUNCH" && exit 1
1141.endif
1142.if !defined(ZIP)
1143	@echo "ZIP undefined in installCRUNCH" && exit 1
1144.endif
1145	@if ${ZIP} ; then \
1146		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
1147	else \
1148		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
1149	fi
1150	@chmod 555 ${DIR}/${CRUNCH}_crunch
1151	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
1152		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
1153			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1154		done \
1155	else \
1156		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
1157			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1158		done \
1159	fi
1160
1161#
1162# --==## Build a floppy set for a splitfs file ##==--
1163#
1164# FLOPPYBASE - basename of floppy image files
1165# FLOPPYDESC - description of floppy set
1166# SPLITFILE - filename of the file to split
1167# FDSIZE - if specified and "small", small floppy is created
1168
1169.if make(makeFloppySet)
1170SPLITDIR=	${RD}/floppyset/${FLOPPYBASE}
1171.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1172FLPSPLITSIZE=	${SMALLFLOPPYSPLITSIZE}
1173FLPSIZE=	${SMALLFLOPPYSIZE}
1174FLPLABEL=	${SMALLFLOPPYLABEL}
1175.else
1176FLPSPLITSIZE=	${FLOPPYSPLITSIZE}
1177FLPSIZE=	${FLOPPYSIZE}
1178FLPLABEL=	${FLOPPYLABEL}
1179.endif
1180.endif
1181
1182makeFloppySet:
1183.if !defined(FLOPPYBASE)
1184	@echo "FLOPPYBASE undefined in ${.TARGET}" && exit 1
1185.endif
1186.if !defined(FLOPPYDESC)
1187	@echo "FLOPPYDESC undefined in ${.TARGET}" && exit 1
1188.endif
1189.if !defined(SPLITFILE)
1190	@echo "SPLITFILE undefined in ${.TARGET}" && exit 1
1191.endif
1192	sh ${.CURDIR}/scripts/split-file.sh ${SPLITFILE} \
1193	    ${RD}/floppyset/${FLOPPYBASE} ${FLPSPLITSIZE} "${FLOPPYDESC}"
1194	( splitfile=${SPLITDIR}/`basename ${SPLITFILE}`.split ; \
1195	lines=`cat $${splitfile} | wc -l`; \
1196	lines=$$(($$lines - 1)) ; \
1197	for line in `jot $$lines`; do \
1198		file=`head -n $$(($${line} + 1)) $${splitfile} | tail -1 | cut -f 1 -d ' '` ; \
1199		sh -e ${DOFS_SH} ${RD}/floppies/${FLOPPYBASE}$${line}.flp \
1200		${RD} ${MNT} ${FLPSIZE} ${SPLITDIR}/$${file} \
1201		${BOOTINODE} ${FLPLABEL}; \
1202	done )
1203
1204#
1205# --==## Build a boot floppy ##==--
1206#
1207# FSIMAGE - base floppy image name
1208# FDSIZE - if specified and "small", small floppy is created
1209# KERNFILE - path to kernel split file
1210# MFSROOTFILE - path to mfsroot split file
1211
1212.if make(buildBootFloppy)
1213IMAGEDIR=	${RD}/image.${FSIMAGE}
1214BOOTDIR=	${RD}/trees/base/boot
1215HINTSFILE=	${BOOTDIR}/device.hints
1216ACPI_KO=	${RD}/kernels/GENERIC/acpi.ko
1217IMAGEFILE=	${RD}/floppies/${FSIMAGE}.flp
1218.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1219FLPSIZE=	${SMALLFLOPPYSIZE}
1220FLPLABEL=	${SMALLFLOPPYLABEL}
1221.else
1222FLPSIZE=	${FLOPPYSIZE}
1223FLPLABEL=	${FLOPPYLABEL}
1224.endif
1225.endif
1226
1227buildBootFloppy:
1228.if !defined(FSIMAGE)
1229	@echo "FSIMAGE undefined in ${.TARGET}" && exit 1
1230.endif
1231.if !defined(KERNFILE)
1232	@echo "KERNFILE undefined in ${.TARGET}" && exit 1
1233.endif
1234.if !defined(MFSROOTFILE)
1235	@echo "MFSROOTFILE undefined in ${.TARGET}" && exit 1
1236.endif
1237	@echo "Running ${.TARGET} for ${FSIMAGE}"
1238	@rm -rf ${IMAGEDIR}
1239	@mkdir ${IMAGEDIR}
1240	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
1241	@mkdir -p ${IMAGEDIR}/boot
1242.if ${TARGET} == "i386"
1243	@${WMAKEENV} kgzip -v -l ${RD}/trees/base/usr/lib/kgzldr.o -o \
1244	    ${IMAGEDIR}/boot/loader ${BOOTDIR}/loader
1245.else
1246	@cp ${BOOTDIR}/loader ${IMAGEDIR}/boot
1247.endif
1248	@cp -Rp ${BOOTDIR}/*.4th ${BOOTDIR}/defaults ${BOOTDIR}/loader.help \
1249	    ${BOOTDIR}/loader.rc ${IMAGEDIR}/boot
1250.if exists(${HINTSFILE})
1251	@cp ${HINTSFILE} ${IMAGEDIR}/boot/device.hints
1252	@gzip -9n ${IMAGEDIR}/boot/device.hints
1253.endif
1254	@gzip -9n ${IMAGEDIR}/boot/*.4th ${IMAGEDIR}/boot/loader.help \
1255	    ${IMAGEDIR}/boot/defaults/loader.conf
1256	@echo 'bootfile="/kernel"' > ${IMAGEDIR}/boot/loader.conf
1257.if exists(${ACPI_KO})
1258	@gzip -9nc ${ACPI_KO} > ${IMAGEDIR}/acpi.ko.gz
1259	@echo 'acpi_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1260	@echo 'acpi_name="/acpi.ko"' >> ${IMAGEDIR}/boot/loader.conf
1261	@echo 'acpi_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1262.endif
1263	@echo 'mfsroot_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1264	@echo 'mfsroot_type="mfs_root"' >> ${IMAGEDIR}/boot/loader.conf
1265	@echo 'mfsroot_name="/mfsroot"' >> ${IMAGEDIR}/boot/loader.conf
1266.if !exists(${ACPI_KO})
1267	@echo 'mfsroot_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1268.endif
1269.if defined(SPLIT_MFSROOT)
1270	@echo 'mfsroot_after="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1271.endif
1272.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
1273.if ${AUTO_KEYBOARD_DETECT}
1274	@echo "-P" >> ${IMAGEDIR}/boot.config
1275.endif
1276.endif
1277	@rm -f ${IMAGEFILE}
1278	@cp ${KERNFILE} ${MFSROOTFILE} ${IMAGEDIR}
1279	sh -e ${DOFS_SH} ${IMAGEFILE} ${RD} ${MNT} ${FLPSIZE} ${IMAGEDIR} \
1280	    ${BOOTINODE} ${FLPLABEL}
1281	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1282
1283.if make(package-split)
1284# Targets related to making a package split
1285#
1286# PKG_COPY instructs the script to copy the actual package files rather than
1287#     make hard links
1288# PKG_TREE is the path to the package tree to be split
1289# PKG_DEST is the path to the destination tree to create the split in
1290# PKG_VERBOSE asks for verbose output of the layout process
1291# PKG_INDEX is the path to the INDEX file. By default ${PKG_TREE}/INDEX.
1292
1293.if defined(PKG_COPY)
1294PKG_DO_COPY=	cp
1295.else
1296PKG_DO_COPY=	ln
1297.endif
1298PKG_WRKIDX=	${PKG_DEST}/INDEX.master
1299PKG_ENV?=
1300.if defined(TARGET_ARCH)
1301PKG_ENV+=	PKG_ARCH=${TARGET_ARCH}
1302.endif
1303.if defined(PKG_VERBOSE)
1304PKG_ENV+=	PKG_VERBOSE=1
1305.endif
1306PKG_INDEX?=	${PKG_TREE}/INDEX
1307
1308package-split:
1309.if !defined(PKG_TREE)
1310	@echo "PKG_TREE must be defined" && exit 1
1311.endif
1312.if !defined(PKG_DEST)
1313	@echo "PKG_DEST must be defined" && exit 1
1314.endif
1315	@env ${PKG_ENV} python ${.CURDIR}/scripts/package-split.py \
1316	    ${PKG_INDEX} ${PKG_WRKIDX}
1317	@env ${PKG_ENV} sh ${.CURDIR}/scripts/package-trees.sh ${PKG_DO_COPY} \
1318	    ${PKG_WRKIDX} ${PKG_TREE} ${PKG_DEST}
1319.endif
1320
1321.include <bsd.obj.mk>
1322