Makefile revision 105529
169408Sache# $FreeBSD: head/release/Makefile 105529 2002-10-20 16:27:11Z matusita $
269408Sache#
369408Sache# make release CHROOTDIR=/some/dir BUILDNAME=somename CVSROOT=/cvs/dir \
469408Sache#	[ RELEASETAG=tag ]
569408Sache#
669408Sache# Where "/some/dir" is the pathname of a directory on a some filesystem with
769408Sache# at least 1000MB of free space, "somename" is what you want the release to
869408Sache# call itself, "/cvs/dir" is where our source repo resides and, optionally,
969408Sache# which CVS "tag" name should be used when checking out the sources to build
1069408Sache# the release (default is HEAD).
1169408Sache#
1269408Sache# Please note: the md(4) driver must be compiled into your kernel
1369408Sache# or available as a kld(4)-style kernel module,
1469408Sache# otherwise the target 'release.9' and possibly others will fail.
1569408Sache#
1669408Sache# Note:  "/some/dir" cannot reside on a filesystem mounted with
1769408Sache# the "nodev" option, otherwise the chrooted "buildworld" will likely
1869408Sache# fail.
1969408Sache#
2069408Sache# Note: If you add options to this file, please keep release(7) updated!
2169408Sache#
2269408Sache# Set these, release builder!
2369408Sache#
2469408Sache# Fixed version:
2569408Sache#BUILDNAME=5.0-RELEASE
2669408Sache#
2769408Sache# Automatic SNAP versioning:
2869408SacheDATE != date +%Y%m%d
2969408SacheBASE = 5.0
3069408SacheBUILDNAME?=${BASE}-${DATE}-SNAP
3169408Sache#
3269408Sache#CHROOTDIR=/junk/release
3369408Sache# If this is a -stable snapshot, then set
3469408Sache#RELEASETAG=RELENG_4
3569408Sache# If you want to add other options to CVS commands, then set
3669408Sache#CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
3769408Sache#
3869408Sache# Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
3969408Sache# are building an official release.  Otherwise, we are building for
4069408Sache# a branch.
4169408Sache.if defined(RELEASETAG)
4269408SacheISRELEASE!=	expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
4369408Sache.if ${ISRELEASE} != 0
4469408Sache# Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
4569408SacheAUXRELEASETAG!=	echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
4669408SacheDOCRELEASETAG?=		${AUXRELEASETAG}
4769408SachePORTSRELEASETAG?=	${AUXRELEASETAG}
4869408Sache.endif
4969408Sache.endif
5069408Sache
5169408Sache# If you want to pass flags to the world build such as -j X, use
5269408Sache# WORLD_FLAGS.  Similarly, you can specify make flags for kernel
5369408Sache# builds via KERNEL_FLAGS.
5469408Sache#WORLD_FLAGS=-j4
5569408Sache#KERNEL_FLAGS=-j4
5669408Sache
5769408SacheTARGET_ARCH?=	${MACHINE_ARCH}
5869408Sache.if ${TARGET_ARCH} == ${MACHINE_ARCH}
5969408SacheTARGET?=	${MACHINE}
6069408Sache.else
6169408SacheTARGET?=	${TARGET_ARCH}
6269408Sache.endif
6369408SacheCROSSMAKE=	${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
6469408SacheNATIVEMAKE=	${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
6569408Sache
6669408Sache# If you are using a local CVS repository with components stored in 
6769408Sache# non-standard modules, override these on the make commandline or
6869408Sache# in the environment.
6969408SacheRELEASESRCMODULE?=	src
7069408SacheRELEASEDOCMODULE?=	doc
7169408SacheRELEASEPORTSMODULE?=	ports
7269408Sache
7369408Sache# Uncomment this to disable the doc.1 target.  Docs normally require
7469408Sache# the ports tree, so NOPORTS can be set together with NODOC in order
7569408Sache# to have neither ports or docs.  If only NOPORTS is set to YES, but
7669408Sache# docs are still desired, the DOMINIMALDOCPORTS logic below will only
7769408Sache# install the ports that are minimally required for the docs.  This is
7869408Sache# intended as a compromise, less disk space is required than for using
7969408Sache# the entire ports collection (and much less time due to the huge number
8069408Sache# of directories it would create), but still quite a bit as well as some
8169408Sache# CPU cycles (some of the programs are C++, and things like ghostscript
8269408Sache# belong to the required ports nevertheless).
8369408Sache#
8469408Sache# Setting this also disables building of release note documentation
8569408Sache# (RELNOTESng).
8669408Sache#NODOC=  YES
8769408Sache#NOPORTS=  YES
8869408Sache
8969408Sache# Modify this definition if you want the release notes 
9069408Sache# and other release documentation in a language other than English.
9169408SacheRELNOTES_LANG?=	en_US.ISO8859-1
9269408Sache
9369408Sache# As an alternative to installing the entire ports collection (which
9469408Sache# can take a huge amount of time, in particular on slower disks),
9569408Sache# setting ${MINIMALDOCPORTS} allows to install and build just those
9669408Sache# ports that are really required for getting the docs up & running.
9769408Sache.if defined(NOPORTS) && !defined(NODOC)
9869408SacheDOMINIMALDOCPORTS=	YES
9969408Sache.include "Makefile.inc.docports"
10069408Sache.endif
10169408Sache
10269408Sache# Helper variable
10369408Sache.if defined(NOPORTS)
10469408Sache.if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
10569408SacheNOPORTSATALL=	YES
10669408Sache.endif
10769408Sache.endif
10869408Sache
10969408Sache# By default, documentation (Handbook, FAQ, etc.) is built for all
11069408Sache# the languages.  To speed up building, set the DOC_LANG to just
11169408Sache# the languages you need.  (The language for the release notes is
11269408Sache# controlled by the RELNOTES_LANG variable above.)
11369408Sache#DOC_LANG=	en_US.ISO8859-1
11469408SacheDOCPORTS=	textproc/docproj
11569408Sache# Set this to wherever the distfiles required by release procedures.
11669408Sache.if defined(DOCDISTFILES)
11769408Sache# Respect DOCDISTFILES which is used before.
11869408SacheRELEASEDISTFILES?=	${DOCDISTFILES}
11969408Sache.else
12069408SacheRELEASEDISTFILES?=	${.CURDIR}/../../ports/distfiles
12169408Sache.endif
12269408Sache# Set this to 1 if you want -P to be used for automatic keyboard detection
12369408Sache# on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
12469408SacheAUTO_KEYBOARD_DETECT?= 0
12569408Sache
12669408Sache.if !defined(NODOC)
12769408SacheDIST_DOCS_ARCH_INDEP=	readme errata
12869408SacheDIST_DOCS_ARCH_DEP=	installation relnotes hardware
12969408Sache.endif
13069408Sache
13169408Sache# Things which without too much trouble can be considered variables
13269408Sache# BASE_DISTS are special in that they get full /etc installation sets.
13369408Sache#
13469408Sache.if ${TARGET_ARCH} == "i386"
13569408SacheCOMPAT_DISTS?=	compat1x compat20 compat21 compat22 compat3x compat4x
13669408Sache.else
13769408SacheCOMPAT_DISTS?=	compat4x
13869408Sache.endif
13969408SacheOTHER_DISTS?=	catpages manpages games proflibs dict info doc
14069408SacheCRYPTO_DISTS?=	crypto krb4 krb5
14169408SacheBASE_DISTS?=	base
14269408SacheDISTRIBUTIONS?=	${BASE_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS}
14369408Sache
14469408SacheBOOT1=	etc/defaults/rc.conf
14569408Sache
14669408Sache# mountpoint for filesystems.
14769408SacheMNT=			/mnt
14869408Sache
14969408Sache# Various floppy image parameters.
15069408Sache#
15169408Sache
15269408Sache.if ${TARGET_ARCH} == "i386"
15369408Sache.if ${TARGET} == "pc98"
15469408SacheSMALLBOOTSIZE=		1200
15569408SacheDRIVERSIZE=		1440
15669408SacheBOOTSIZE=		1440
15769408SacheFIXITSIZE=		1440
15869408SacheMFSSIZE=		4320
15969408SacheDRIVERINODE=		80000
16069408SacheBOOTINODE=		80000
16169408SacheFIXITINODE=		40000
16269408SacheMFSINODE=		8000
16369408SacheSMALLBOOTLABEL=		fd1200
16469408SacheDRIVERLABEL=		fd1440
16569408SacheBOOTLABEL=		fd1440
16669408SacheFIXITLABEL=		fd1440
16769408SacheMFSLABEL=		minimum3
16869408Sache.else
16969408SacheDRIVERSIZE=		1440
17069408SacheBOOTSIZE=		1440
17169408SacheFIXITSIZE=		1440
17269408SacheMFSSIZE=		4320
17369408SacheBIGBOOTSIZE=		2880
17469408SacheDRIVERINODE=		40000
17569408SacheBOOTINODE=		80000
17669408SacheFIXITINODE=		40000
17769408SacheMFSINODE=		8000
17869408SacheDRIVERLABEL=		fd1440
17969408SacheBOOTLABEL=		fd1440
18069408SacheFIXITLABEL=		fd1440
18169408SacheMFSLABEL=		minimum3
18269408SacheBIGBOOTLABEL=		minimum2
18369408Sache.endif
18469408Sache.elif ${TARGET_ARCH} == "alpha"
18569408SacheDRIVERSIZE=		1440
18669408SacheBOOTSIZE=		1440
18769408SacheFIXITSIZE=		2880
18869408SacheMFSSIZE=		4320
18969408SacheBIGBOOTSIZE=		2880
19069408SacheDRIVERINODE=		80000
19169408SacheBOOTINODE=		80000
19269408SacheFIXITINODE=		40000
19369408SacheMFSINODE=		8000
19469408SacheDRIVERLABEL=		fd1440
19569408SacheBOOTLABEL=		fd1440
19669408SacheFIXITLABEL=		minimum2
19769408SacheMFSLABEL=		auto
19869408SacheBIGBOOTLABEL=		minimum2
19969408Sache.elif ${TARGET_ARCH} == "sparc64"
20069408SacheBIGBOOTSIZE=		4096
20169408SacheMFSSIZE=		4096
20269408SacheBOOTINODE=		8192
20369408SacheMFSINODE=		8192
20469408SacheBIGBOOTLABEL=		auto
20569408SacheMFSLABEL=		auto
20669408Sache.endif
20769408Sache
20869408SacheZIPNSPLIT=		gzip --no-name -9 -c | split -b 240640 -
20969408Sache
21069408Sache# Things that need to be recompiled with Kerberos support.
21169408Sache.if exists(${.CURDIR}/../kerberosIV) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
21269408SacheK4PROGS!=	cd ${.CURDIR}/../kerberosIV; ${MAKE} -V KPROGS
21369408Sache.endif
21469408Sache.if exists(${.CURDIR}/../kerberos5) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
21569408SacheK5PROGS!=	cd ${.CURDIR}/../kerberos5; ${MAKE} -V KPROGS
21669408Sache.endif
21769408Sache
21869408Sache# Things that need to be compiled without crypto support in releases
21969408Sache.if !defined(FIXCRYPTO)
22069408SacheFIXCRYPTO=	bin/ed usr.sbin/ppp usr.sbin/pppd usr.sbin/tcpdump/tcpdump 
22169408Sache.if !defined(NO_SENDMAIL)
22269408SacheFIXCRYPTO+=	usr.sbin/sendmail
22369408Sache.endif
22469408Sache.endif
22569408Sache
22669408Sache
22769408Sache# Things which may get you into trouble if you change them
22869408SacheMTREEFILES=		${.CURDIR}/../etc/mtree
22969408Sache_R?=			/R
23069408SacheRD=			${_R}/stage
23169408SacheRND=			${RD}/release.doc
23269408SacheFD=			${_R}/ftp
23369408SacheCD=			${_R}/cdrom
23469408SacheCD_DISC1=		${CD}/disc1
23569408SacheCD_DISC2=		${CD}/disc2
23669408Sache
23769408Sache# Where the bootstrap ports (see DOCPORTS) get installed.
23869408SacheLOCALDIR=		/usr/local/bin
23969408Sache
24069408Sache.if ${TARGET_ARCH} == "sparc64"
24169408SacheCRUNCH_TARGETS= boot
24269408SacheFIXIT_TARGET=
24369408Sache.endif
24469408Sache
24569408Sache.if !defined(CRUNCH_TARGETS)
24669408SacheCRUNCH_TARGETS=	boot fixit
24769408Sache.endif
24869408Sache
24969408Sache.if !defined(FIXIT_TARGET)
25069408SacheFIXIT_TARGET= release.10
25169408Sache.endif
25269408Sache
25369408SacheEXTRAS= cdrom.1 ftp.1
25469408Sache.if defined(MAKE_ISOS)
25569408SacheEXTRAS+= iso.1
25669408Sache.if ${TARGET} != "pc98"
25769408SacheBOOTABLE="-b"
25869408Sache.endif
25969408Sache.endif
26069408Sache
26169408Sache.if !defined(NODOC)
26269408SacheDOCREL= doc.1 doc.2
26369408Sache.endif
26469408Sache
26569408Sache.if !defined(NOPORTREADMES)
26669408SacheMAKEREADMES=	make readmes PORTSDIR=${CHROOTDIR}/usr/ports
26769408Sache.else
26869408SacheMAKEREADMES=	true
26969408Sache.endif
27069408Sache
27169408SacheTMAKE!=		echo MAKEFLAGS=\"-m ${.CURDIR}/../share/mk\"; \
27269408Sache		cd ${.CURDIR}/..; ${MAKE} -f Makefile.inc1 -V TMAKE
27369408SacheWMAKEENV!=	echo MAKEFLAGS=\"-m ${.CURDIR}/../share/mk\"; \
27469408Sache		cd ${.CURDIR}/..; ${CROSSMAKE} -f Makefile.inc1 -V WMAKEENV
27569408SacheWMAKE=		${WMAKEENV} ${MAKE}
27669408Sache
27769408Sachererelease release:
27869408Sache.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
27969408Sache	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
28069408Sache.endif
28169408Sache.if defined(NOPORTSATALL) && !defined(NODOC)
28269408Sache	@echo "Ports are required for building the docs.  Either set NODOC or"
28369408Sache	@echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
28469408Sache	@exit 1
28569408Sache.endif
28669408Sache.if make(release)
28769408Sache.if exists(${CHROOTDIR})
28869408Sache# The first command will fail on a handful of files that have their schg
28969408Sache# flags set.  But it greatly speeds up the next two commands.
29069408Sache	# NB: clear any vestigal devfs mount, just in case
29169408Sache	-umount ${CHROOTDIR}/dev > /dev/null 2>&1
29269408Sache	-rm -rf ${CHROOTDIR} 2>/dev/null
29369408Sache	-chflags -R noschg ${CHROOTDIR}/.
29469408Sache	-rm -rf ${CHROOTDIR}
29569408Sache.endif
29669408Sache	mkdir -p ${CHROOTDIR}
29769408Sache	@echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
29869408Sache	cd ${.CURDIR}/.. && ${NATIVEMAKE} -DNOGAMES -DNOHTML -DNOINFO -DNOMAN \
29969408Sache	    -DNOPROFILE installworld DESTDIR=${CHROOTDIR}
30069408Sache	cd ${.CURDIR}/../etc && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
30169408Sache	if [ -f /etc/resolv.conf ]; then \
30269408Sache		cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
30369408Sache	fi
30469408Sache.if !defined(RELEASETAG)
30569408Sache	cd ${CHROOTDIR}/usr && rm -rf src && \
30669408Sache		cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P ${RELEASESRCMODULE}
30769408Sache.else
30869408Sache	cd ${CHROOTDIR}/usr && rm -rf src && \
30969408Sache		cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P -r ${RELEASETAG} ${RELEASESRCMODULE}
31069408Sache.endif
31169408Sache.if defined(LOCAL_PATCHES) && exists(${LOCAL_PATCHES})
31269408Sache	cd ${CHROOTDIR}/usr/src && patch ${PATCH_FLAGS} < ${LOCAL_PATCHES}
31369408Sache.endif
31469408Sache.if defined(LOCAL_SCRIPT) && exists(${LOCAL_SCRIPT})
31569408Sache	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
31669408Sache.endif
31769408Sache.if !defined(NOPORTS)
31869408Sache.if defined(PORTSRELEASETAG)
31969408Sache	cd ${CHROOTDIR}/usr && rm -rf ports && cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P -r ${PORTSRELEASETAG} ${RELEASEPORTSMODULE} && cd ports && ${MAKEREADMES}
32069408Sache.else
32169408Sache	cd ${CHROOTDIR}/usr && rm -rf ports && cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P ${RELEASEPORTSMODULE} && cd ports && ${MAKEREADMES}
32269408Sache.endif
32369408Sache.elif defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
32469408Sache.if defined(PORTSRELEASETAG)
32569408Sache	cd ${CHROOTDIR}/usr && rm -rf ports && cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P -r ${PORTSRELEASETAG} ${MINIMALDOCPORTS}
32669408Sache.else
32769408Sache	cd ${CHROOTDIR}/usr && rm -rf ports && cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P ${MINIMALDOCPORTS}
32869408Sache.endif
32969408Sache.endif
33069408Sache.if !defined(NODOC)
33169408Sache.if defined(DOCRELEASETAG)
33269408Sache	cd ${CHROOTDIR}/usr && rm -rf doc && cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P -r ${DOCRELEASETAG} ${RELEASEDOCMODULE}
33369408Sache.else
33469408Sache	cd ${CHROOTDIR}/usr && rm -rf doc && cvs -R -d ${CVSROOT} co ${CVSCMDARGS} -P ${RELEASEDOCMODULE}
33569408Sache.endif
33669408Sache	if [ -d ${RELEASEDISTFILES}/ ]; then \
33769408Sache		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
33869408Sache	else \
33969408Sache		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
34069408Sache	fi
34169408Sache.if defined(PREFETCHDISTFILES)
34269408Sache	@for i in ${DOCPORTS}; do \
34369408Sache		cd ${CHROOTDIR}/usr/ports/$$i && \
34469408Sache			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
34569408Sache			WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
34669408Sache			fetch-recursive ; \
34769408Sache	done
34869408Sache.endif
34969408Sache.endif
35069408Sache.endif
35169408Sache.if make(rerelease)
35269408Sache.if !defined(RELEASENOUPDATE)
35369408Sache.if !defined(RELEASETAG)
35469408Sache	cd ${CHROOTDIR}/usr/src && cvs -R -q update ${CVSCMDARGS} -P -d -A
35569408Sache.else
35669408Sache	cd ${CHROOTDIR}/usr/src && cvs -R -q update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
35769408Sache.endif
35869408Sache.if !defined(NOPORTS)
35969408Sache	cd ${CHROOTDIR}/usr/ports && cvs -R -q update ${CVSCMDARGS} -P -d
36069408Sache.endif
36169408Sache.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
36269408Sache	for i in ${MINIMALDOCPORTS}; do \
36369408Sache		( cd ${CHROOTDIR}/usr/$$i && cvs -R -q update ${CVSCMDARGS} -P -d ) ; \
36469408Sache	done
36569408Sache.endif
36669408Sache.if !defined(NODOC)
36769408Sache	cd ${CHROOTDIR}/usr/doc && cvs -R -q update ${CVSCMDARGS} -P -d
36869408Sache.endif
36969408Sache.endif
37069408Sache.endif
37169408Sache	# Add version information to those things that need it.
37269408Sache	( cd ${CHROOTDIR}/usr/src/sys/conf && \
37369408Sache	  mv newvers.sh foo && \
37469408Sache	  sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && rm foo )
37569408Sache	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
37669408Sache	echo "#!/bin/sh"			> ${CHROOTDIR}/mk
37769408Sache	echo "set -ex"				>> ${CHROOTDIR}/mk
37869408Sache	echo "trap 'umount /dev || true' 0"	>> ${CHROOTDIR}/mk
37969408Sache	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${CHROOTDIR}/mk
38069408Sache.for var in \
38169408Sache	AUTO_KEYBOARD_DETECT BOOT_CONFIG BUILDNAME \
38269408Sache	CD_EXTRA_BITS DISTRIBUTIONS DOC_LANG DOMINIMALDOCPORTS \
38369408Sache	EXTRA_SRC FIXCRYPTO KERNELS KERNEL_FLAGS \
38469408Sache	MAKE_ISOS NODOC NOKERBEROS NOPORTS NOSHARED \
38569408Sache	NOSRC NO_SENDMAIL RELEASETAG \
38669408Sache	RELNOTES_LANG TARGET TARGET_ARCH WORLD_FLAGS
38769408Sache.if defined(${var})
38869408Sache	echo "export ${var}=\"${${var}}\""	>> ${CHROOTDIR}/mk
38969408Sache.endif
39069408Sache.endfor
39169408Sache	# Don't remove this, or the build will fall over!
39269408Sache	echo "export RELEASEDIR=${_R}"		>> ${CHROOTDIR}/mk
39369408Sache	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${CHROOTDIR}/mk
39469408Sache	echo "export MANBUILDCAT=YES"		>> ${CHROOTDIR}/mk
39569408Sache	# NB: these may fail if the host is running w/o devfs
39669408Sache	echo "umount /dev >/dev/null 2>&1 || true" >> ${CHROOTDIR}/mk
39769408Sache	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true" \
39869408Sache						>> ${CHROOTDIR}/mk
39969408Sache	echo "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
40069408Sache	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
40169408Sache	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNOCLEAN buildworld && \\" >> ${CHROOTDIR}/mk
40269408Sache	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
40369408Sache	echo "fi"				>> ${CHROOTDIR}/mk
40469408Sache	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
40569408Sache	echo "make obj"				>> ${CHROOTDIR}/mk
40669408Sache	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
40769408Sache	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${CHROOTDIR}/mk
40869408Sache	chmod 755 ${CHROOTDIR}/mk
40969408Sache	env -i /usr/sbin/chroot ${CHROOTDIR} /mk
41069408Sache
41169408Sacheclean:
41269408Sache	rm -rf boot_crunch release.[0-9]
41369408Sache
41469408Sache# Clean out ${_R} and make the directory structure.
41569408Sacherelease.1:
41669408Sache	mkdir -p ${_R}
41769408Sache	-rm -rf ${_R}/* 2> /dev/null
41869408Sache	-chflags -R noschg ${_R}/.
41969408Sache	rm -rf ${_R}/*
42069408Sache	mkdir ${RD}
42169408Sache	mkdir ${RD}/floppies
42269408Sache	mkdir ${RD}/trees
42369408Sache	mkdir ${RD}/kernels
42469408Sache	for i in ${DISTRIBUTIONS} ; do \
42569408Sache		mkdir ${RD}/trees/$$i && \
42669408Sache		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
42769408Sache		    -p ${RD}/trees/$$i > /dev/null && \
42869408Sache		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
42969408Sache		    -p ${RD}/trees/$$i/usr > /dev/null && \
43069408Sache		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
43169408Sache		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
43269408Sache		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
43369408Sache		    -p ${RD}/trees/$$i/var > /dev/null ; \
43469408Sache	done
43569408Sache	touch release.1
43669408Sache
43769408Sache# Install the system into the various distributions.
43869408Sacherelease.2:
43969408Sache	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
44069408Sache	cd ${.CURDIR}/.. && ${CROSSMAKE} distributeworld DISTDIR=${RD}/trees
44169408Sache	touch release.2
44269408Sache
44369408Sache# Build and install crypto, krb4 and krb5 distributions.
44469408Sacherelease.3:
44569408Sache	# Handle some grief caused by the munition braindeadness.
44669408Sache	cd ${.CURDIR}/..; \
44769408Sache	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DNOCRYPT \
44869408Sache	    SUBDIR_OVERRIDE="${FIXCRYPTO}" \
44969408Sache	    buildworld distributeworld DISTDIR=${RD}/trees
45069408Sache.if exists(${.CURDIR}/../kerberosIV) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
45169408Sache	cd ${.CURDIR}/..; \
45269408Sache	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DMAKE_KERBEROS4 \
45369408Sache	    SUBDIR_OVERRIDE="kerberosIV ${K4PROGS}" \
45469408Sache	    buildworld distributeworld DISTDIR=${RD}/trees
45569408Sache.endif
45669408Sache.if exists(${.CURDIR}/../kerberos5) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
45769408Sache	cd ${.CURDIR}/..; \
45869408Sache	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DMAKE_KERBEROS5 \
45969408Sache	    SUBDIR_OVERRIDE="kerberos5 ${K5PROGS}" \
46069408Sache	    buildworld distributeworld DISTDIR=${RD}/trees
46169408Sache	rm -f ${RD}/trees/krb5/usr/share/info/dir
46269408Sache.endif
46369408Sache	-chflags -R noschg ${RD}/trees
46469408Sache	touch release.3
46569408Sache
46669408Sache# Make and install the generic kernel(s).
46769408Sacherelease.4:
46869408Sache.for kernel in ${KERNELS}
46969408Sache	cd ${.CURDIR}/..; \
47069408Sache	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
47169408Sache	    KERNCONF=${kernel} INSTKERNNAME=${kernel} kernel \
47269408Sache	    DESTDIR=${RD}/trees/base
47369408Sache.endfor
47469408Sache	# Install a standard boot kernel+modules.
47569408Sache	cd ${.CURDIR}/..; \
47669408Sache	${CROSSMAKE} ${KERNEL_FLAGS} \
47769408Sache	    kernel \
47869408Sache	    DESTDIR=${RD}/trees/base; \
47969408Sache	cd ${.CURDIR}/..; \
48069408Sache	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
48169408Sache	    reinstallkernel -DINSTALL_DEBUG \
48269408Sache	    DESTDIR=${RD}/trees/base
48369408Sache	touch release.4
48469408Sache
48569408Sache# Make and install the three crunched binaries which live on the floppies.
48669408Sache# You are not supposed to like this :-)
48769408Sacherelease.5:
48869408Sache	rm -rf ${RD}/crunch
48969408Sache	mkdir -p ${RD}/crunch
49069408Sache.for j in ${CRUNCH_TARGETS}
49169408Sache	rm -rf ${j}_crunch
49269408Sache	mkdir ${j}_crunch
49369408Sache.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
49469408Sache	cd ${j}_crunch; ${WMAKEENV} crunchgen -o ${.CURDIR}/${TARGET}/${j}_crunch.conf
49569408Sache.else
49669408Sache	cd ${j}_crunch; ${WMAKEENV} crunchgen -o ${.CURDIR}/${j}_crunch.conf
49769408Sache.endif
49869408Sache	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
49969408Sache	cd ${.CURDIR}/..; ${TMAKE} build-tools
50069408Sache	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk \
50169408Sache	    CFLAGS="-Os -pipe" -DNO_CPU_CFLAGS all
50269408Sache	mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
50369408Sache.endfor
50469408Sache	touch release.5
50569408Sache
50669408Sache#
50769408Sache# --==## Fix up the distributions. ##==--
50869408Sache#
50969408Sacherelease.6:
51069408Sache	# Create any "synthetic dists" now.
51169408Sache	@for i in ${DISTRIBUTIONS}; do \
51269408Sache		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
51369408Sache			echo -n "Running $$i dist creation script... "; \
51469408Sache			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
51569408Sache			echo "Done."; \
51669408Sache		fi \
51769408Sache	done \
51869408Sache
51969408Sache	# Remove all the directories we don't need.
52069408Sache	-cd ${RD}/trees && \
52169408Sache		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
52269408Sache	touch release.6
52369408Sache
52469408Sache#
52569408Sache# --==## Package up the tarballs from assembled trees ##==--
52669408Sache#
52769408Sacherelease.7:
52869408Sache	rm -rf ${RD}/dists
52969408Sache	mkdir -p ${RD}/dists
53069408Sache	@for i in ${DISTRIBUTIONS} ; \
53169408Sache	do \
53269408Sache		if [ -d ${RD}/trees/$${i} ] ; then \
53369408Sache			cd ${.CURDIR} && $(MAKE) doTARBALL \
53469408Sache				SD=${RD}/trees/$${i} \
53569408Sache				TN=$$i TD=$$i ARG="." && \
53669408Sache			echo "$${i} distribution is finished."; \
53769408Sache		fi ; \
53869408Sache	done
53969408Sache	# More munition braindeadness.
54069408Sache	( cd ${RD}/dists && \
54169408Sache		if [ -f krb4/krb4.aa ] ; then \
54269408Sache			mv krb4/krb4.* crypto && \
54369408Sache			cat krb4/CHECKSUM.MD5 >> crypto/CHECKSUM.MD5 && \
54469408Sache			rm -r krb4; \
54569408Sache		fi )
54669408Sache	( cd ${RD}/dists && \
54769408Sache		if [ -f krb5/krb5.aa ] ; then \
54869408Sache			mv krb5/krb5.* crypto && \
54969408Sache			cat krb5/CHECKSUM.MD5 >> crypto/CHECKSUM.MD5 && \
55069408Sache			rm -r krb5; \
55169408Sache		fi )
55269408Sache	touch release.7
55369408Sache
55469408Sache
55569408Sache#
55669408Sache# --==## Make source dists ##==--
55769408Sache#
55869408Sacherelease.8:
55969408Sache.if !defined(NOSRC)
56069408Sache	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
56169408Sache		TD=src TN=sbase ARG="[A-Z]*"
56269408Sache	@for i in `cd /usr/src && echo [a-z]*` ; do \
56369408Sache		if [ -d /usr/src/$$i ] ; then \
56469408Sache			cd ${.CURDIR} && $(MAKE) doTARBALL \
56569408Sache				TN=`echo s$$i | tr -d '.' | \
56669408Sache				    sed -e 's/usr/u/' \
56769408Sache					-e 's/kerberosIV/krb4/' \
56869408Sache					-e 's/kerberos5/krb5/'` \
56969408Sache				SD=/usr/src TD=src ARG="$$i" ; \
57069408Sache		fi ; \
57169408Sache	done
57269408Sache.if defined(EXTRA_SRC)
57369408Sache	@set ${EXTRA_SRC} && \
57469408Sache	while [ $$# -ge 2 ] ; do \
57569408Sache		if [ -d /usr/src/$$1 ] ; then \
57669408Sache			cd ${.CURDIR} && $(MAKE) doTARBALL \
57769408Sache				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
57869408Sache		fi && shift && shift ; \
57969408Sache	done
58069408Sache.endif
58169408Sache	if [ -d ${RD}/dists/crypto ] ; then ( cd ${RD}/dists/src && \
58269408Sache		if [ -f ssecure.aa ] ; then mv ssecure.* ../crypto ; fi && \
58369408Sache		if [ -f scrypto.aa ] ; then mv scrypto.* ../crypto ; fi && \
58469408Sache		if [ -f skrb4.aa ] ; then mv skrb4.* ../crypto ; fi && \
58569408Sache		if [ -f skrb5.aa ] ; then mv skrb5.* ../crypto ; fi ; \
58669408Sache		cd ${RD}/dists/crypto; rm -f CHECKSUM.MD5; \
58769408Sache		md5 * > CHECKSUM.MD5 ) ; fi
58869408Sache	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
58969408Sache	@echo "src distribution is finished."
59069408Sache.endif
59169408Sache	touch release.8
59269408Sache
59369408Sache# Complete the bootfd
59469408Sache#
59569408Sache# Now, just to get this picture down once and for all:
59669408Sache#
59769408Sache# +------------------------------------------------------------------------+
59869408Sache# |boot.flp                                                                |
59969408Sache# +-----+-----+------------------------------------------------------------+
60069408Sache# |boot1|boot2|floppy filesystem "bootfd"                                  |
60169408Sache# +-----+-----+-+----------------------+---------------------------------+-+
60269408Sache#               |kernel.gz             |mfsroot.gz                       |
60369408Sache#               +----------------------+---------------------------------+
60469408Sache#
60569408Sache
60669408Sacherelease.9:
60769408Sache	rm -rf ${RD}/mfsfd
60869408Sache	mkdir ${RD}/mfsfd
60969408Sache	cd ${RD}/mfsfd && \
61069408Sache		mkdir -p etc/defaults dev mnt stand/help
61169408Sache	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
61269408Sache		DIR=${RD}/mfsfd/stand ZIP=false
61369408Sache	( cd ${RD}/trees/base/dev && \
61469408Sache		ls console tty bpf0 ttyd0 ttyv0 ttyv1 ttyv2 ttyv3 null zero card0 card1 card2 card3 usb usb0 uhid0 ums0 ulpt0 ugen0 kbd0 kmem mem xpt0 | \
61569408Sache	cpio -dump ${RD}/mfsfd/dev )
61669408Sache	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
61769408Sache	( cd ${RD}/mfsfd && \
61869408Sache	  for dir in bin sbin ; do \
61969408Sache		ln -sf /stand $$dir; \
62069408Sache	  done )
62169408Sache	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
62269408Sache.if ${TARGET} == "pc98"
62369408Sache	cp ${.CURDIR}/../etc/defaults/pccard.conf ${RD}/mfsfd/etc/defaults/pccard.conf
62469408Sache.endif
62569408Sache	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
62669408Sache	cd ${RD}/trees/base && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
62769408Sache	( for F in netconfig protocols ; do \
62869408Sache		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
62969408Sache		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
63069408Sache	  done )
63169408Sache	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
63269408Sache	    ${RD}/trees/base/etc/services | \
63369408Sache	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
63469408Sache	    > ${RD}/mfsfd/stand/etc/services
63569408Sache	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
63669408Sache	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
63769408Sache	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
63869408Sache.if !defined(NODOC)
63969408Sache	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
64069408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
64169408Sache	done
64269408Sache	@for i in ${DIST_DOCS_ARCH_DEP}; do \
64369408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
64469408Sache	done
64569408Sache	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT ${RD}/mfsfd/stand/help/INSTALL.TXT
64669408Sache.endif
64769408Sache	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
64869408Sache	@mkdir -p ${RD}/mfsfd/boot
64969408Sache	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
65069408Sache.if ${TARGET} == "i386"
65169408Sache	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
65269408Sache.endif
65369408Sache	@cp ${RD}/trees/base/boot/loader.help ${RD}/mfsfd/boot
65469408Sache	@echo "Making the regular boot floppy."
65569408Sache	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
65669408Sache		tar xf - -C ${RD}/mfsfd/stand
65769408Sache.if ${TARGET_ARCH} == "alpha"
65869408Sache	rm -rf ${RD}/mfsfd/stand/help/*
65969408Sache.endif
66069408Sache.if ${TARGET} == "pc98"
66169408Sache.if exists(${.CURDIR}/${TARGET}/drivers-small.conf)
66269408Sache	@rm -rf ${RD}/mfsfd/stand/modules
66369408Sache	@mkdir -p ${RD}/mfsfd/stand/modules
66469408Sache	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
66569408Sache	    ${.CURDIR}/${TARGET}/drivers-small.conf \
66669408Sache	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/stand/modules
66769408Sache.endif
66869408Sache	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot-small ${RD} ${MNT} \
66969408Sache		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
67069408Sache	@gzip -9vc mfsroot-small > mfsroot-small.gz
67169408Sache	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot-small.flp \
67269408Sache		${RD} ${MNT} ${SMALLBOOTSIZE} mfsroot-small.gz \
67369408Sache		${BOOTINODE} ${SMALLBOOTLABEL}
67469408Sache.if exists(${.CURDIR}/${TARGET}/drivers.conf)
67569408Sache	@rm -rf ${RD}/mfsfd/stand/modules
67669408Sache	@mkdir -p ${RD}/mfsfd/stand/modules
67769408Sache	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
67869408Sache	    ${.CURDIR}/${TARGET}/drivers.conf \
67969408Sache	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/stand/modules
68069408Sache.endif
68169408Sache	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
68269408Sache		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
68369408Sache	@gzip -9vc mfsroot > mfsroot.gz
68469408Sache	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
68569408Sache		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
68669408Sache	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
68769408Sache	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
68869408Sache.else
68969408Sache.if exists(${.CURDIR}/${TARGET}/drivers.conf)
69069408Sache	@mkdir -p ${RD}/mfsfd/stand/modules
69169408Sache	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
69269408Sache	    ${.CURDIR}/${TARGET}/drivers.conf \
69369408Sache	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/stand/modules
69469408Sache	@rm -rf ${RD}/driversfd
69569408Sache	@mkdir ${RD}/driversfd
69669408Sache	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 3 \
69769408Sache	    ${.CURDIR}/${TARGET}/drivers.conf \
69869408Sache	    ${RD}/trees/base/boot/kernel ${RD}/driversfd
69969408Sache	-@rmdir ${RD}/driversfd
70069408Sache	if [ -d ${RD}/driversfd ]; then \
70169408Sache	    sh -e ${.CURDIR}/scripts/doFS.sh \
70269408Sache		${RD}/floppies/drivers.flp ${RD} ${MNT} ${DRIVERSIZE} \
70369408Sache		${RD}/driversfd ${DRIVERINODE} ${DRIVERLABEL}; \
70469408Sache	fi
70569408Sache.endif
70669408Sache	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
70769408Sache		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
70869408Sache	@gzip -9vc mfsroot > mfsroot.gz
70969408Sache.if ${TARGET_ARCH} != "sparc64"
71069408Sache	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
71169408Sache		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
71269408Sache	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
71369408Sache.endif
71469408Sache	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
71569408Sache.endif
71669408Sache	@rm mfsroot mfsroot.gz
71769408Sache	@echo "Regular and MFS boot floppies made."
71869408Sache	touch release.9
71969408Sache
72069408Sache#
72169408Sache# --==## Create a fixit floppy ##==--
72269408Sache#
72369408Sacherelease.10:
72469408Sache	@echo "Making fixit floppy."
72569408Sache	@rm -rf ${RD}/fixitfd
72669408Sache	@mkdir ${RD}/fixitfd
72769408Sache	@cd ${RD}/fixitfd && \
72869408Sache		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
72969408Sache		usr/share/misc
73069408Sache	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
73169408Sache		DIR=${RD}/fixitfd/stand ZIP=false
73269408Sache	@cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
73369408Sache		${RD}/trees/base/etc/protocols ${RD}/fixitfd/etc
73469408Sache	@cp ${RD}/trees/base/usr/share/misc/scsi_modes \
73569408Sache		${RD}/fixitfd/usr/share/misc
73669408Sache	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
73769408Sache	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
73869408Sache	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
73969408Sache	@chmod 555 ${RD}/fixitfd/stand/tar
74069408Sache	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
74169408Sache		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
74269408Sache# Do our last minute floppies directory setup in a convenient place.
74369408Sache.if !defined(NODOC)
74469408Sache	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
74569408Sache		${RD}/floppies/README.TXT
74669408Sache	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
74769408Sache.else
74869408Sache	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
74969408Sache.endif
75069408Sache	touch release.10
75169408Sache
75269408Sache#
75369408Sache# --==## Setup a suitable ftp-area ##==--
75469408Sache#
75569408Sacheftp.1:
75669408Sache	@echo "Setting up FTP distribution area"
75769408Sache	@mkdir -p ${FD}
75869408Sache	-@ln -s . ${FD}/${BUILDNAME}
75969408Sache	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
76069408Sache	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
76169408Sache.if !defined(NODOC)
76269408Sache	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
76369408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
76469408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
76569408Sache	done
76669408Sache	@for i in ${DIST_DOCS_ARCH_DEP}; do \
76769408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
76869408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
76969408Sache	done
77069408Sache	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
77169408Sache	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
77269408Sache	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
77369408Sache.endif
77469408Sache	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
77569408Sache.if !defined(NOPORTS)
77669408Sache	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
77769408Sache.endif
77869408Sache	touch ftp.1
77969408Sache
78069408Sache#
78169408Sache# --==## Setup a suitable cdrom-area ##==--
78269408Sache#
78369408Sachecdrom.1:
78469408Sache	@echo "Setting up CDROM distribution area"
78569408Sache	@mkdir -p ${CD_DISC1} ${CD_DISC2}
78669408Sache	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
78769408Sache	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
78869408Sache	@for i in ${DISTRIBUTIONS} ; \
78969408Sache	do \
79069408Sache		if [ -d ${RD}/trees/$${i} ] ; then \
79169408Sache			chflags -R noschg ${RD}/trees/$${i} || true ; \
79269408Sache			( cd ${RD}/trees/$${i} && \
79369408Sache			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
79469408Sache		fi \
79569408Sache	done
79669408Sache	@rm -f ${CD_DISC2}/.profile
79769408Sache	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
79869408Sache	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
79969408Sache	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
80069408Sache.if !defined(NODOC)
80169408Sache	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
80269408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
80369408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
80469408Sache	done
80569408Sache	@for i in ${DIST_DOCS_ARCH_DEP}; do \
80669408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
80769408Sache	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
80869408Sache	done
80969408Sache	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
81069408Sache	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
81169408Sache	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
81269408Sache.endif
81369408Sache.if ${TARGET} != "pc98"
81469408Sache	@echo "Setting up /boot"
81569408Sache	@rm -f ${CD_DISC1}/boot/mfsroot.gz
81669408Sache	@rm -f ${CD_DISC2}/boot/mfsroot.gz
81769408Sache	@rm -f ${CD_DISC2}/boot/loader.conf
81869408Sache	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
81969408Sache	@ln -f ${RD}/image.boot/mfsroot.gz ${CD_DISC1}/boot/mfsroot.gz
82069408Sache	@ln -f ${CD_DISC1}/boot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
82169408Sache	@echo 'mfsroot_load="YES"' > ${CD_DISC1}/boot/loader.conf
82269408Sache	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC1}/boot/loader.conf
82369408Sache	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC1}/boot/loader.conf
82469408Sache	@ln -f ${CD_DISC1}/boot/loader.conf ${CD_DISC2}/boot/loader.conf
82569408Sache.endif
82669408Sache.if ${TARGET} == "i386"
82769408Sache	@mkdir -p ${CD_DISC2}/floppies
82869408Sache	@cp ${CD_DISC1}/floppies/boot.flp ${CD_DISC2}/floppies
82969408Sache.endif
83069408Sache.if !defined(NOPORTS)
83169408Sache	@mkdir -p ${CD_DISC1}/ports && \
83269408Sache	  tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
83369408Sache	  ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
83469408Sache	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
83569408Sache	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
83669408Sache.endif
83769408Sache	touch cdrom.1
83869408Sache
83969408Sacheiso.1:
84069408Sache	@if [ -r ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ]; then \
84169408Sache		echo "Creating ISO images..."; \
84269408Sache		sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
84369408Sache		  fbsd_miniinst ${CD}/miniinst.iso ${CD_DISC1}; \
84469408Sache		sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
84569408Sache		  fbsd_livefs ${CD}/disc2.iso ${CD_DISC2}; \
84669408Sache		if [ "x${CD_EXTRA_BITS}" != "x" ]; then \
84769408Sache			sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
84869408Sache			  fbsd_boot ${CD}/disc1.iso ${CD_DISC1} ${CD_EXTRA_BITS} \
84969408Sache			    && false; \
85069408Sache		fi \
85169408Sache	else \
85269408Sache		echo "Do not know how to create an ISO for ${TARGET_ARCH}."; \
85369408Sache	fi
85469408Sache	touch iso.1
85569408Sache
85669408Sache#
85769408Sache# --==## Documentation Project files such as the Handbook and FAQ ##==--
85869408Sache#
85969408Sachedoc.1:
86069408Sache	@echo "Making docs..."
86169408Sache	@for i in ${DOCPORTS}; do \
86269408Sache	    cd /usr/ports/$$i && \
86369408Sache	    env -i PATH=$${PATH} make all install clean \
86469408Sache		BATCH=yes WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
86569408Sache		FORCE_PKG_REGISTER=yes; \
86669408Sache	done
86769408Sache	@cd /usr/doc && make all install 'FORMATS=html html-split txt' INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc
86869408Sache	touch doc.1
86969408Sache
87069408Sache#
87169408Sache# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
87269408Sache#
87369408Sachedoc.2:
87469408Sache	@echo "Making release documentation..."
87569408Sache	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' INSTALL_COMPRESSED='' DOCDIR=${RND}
87669408Sache	touch doc.2
87769408Sache
87869408Sache# Various "subroutine" and other supporting targets.
87969408Sache
88069408Sache# RD=
88169408Sache# SD=
88269408Sache# TD=
88369408Sache# ARG=
88469408SachedoTARBALL:
88569408Sache.if !defined(SD)
88669408Sache	@echo "SD undefined in doTARBALL" && exit 1
88769408Sache.endif
88869408Sache.if !defined(TD)
88969408Sache	@echo "TD undefined in doTARBALL" && exit 1
89069408Sache.endif
89169408Sache.if !defined(ARG)
89269408Sache	@echo "ARG undefined in doTARBALL" && exit 1
89369408Sache.endif
89469408Sache	@rm -rf ${RD}/dists/${TD}/${TN}*
89569408Sache	@mkdir -p ${RD}/dists/${TD}
89669408Sache	@( cd ${SD} && \
89769408Sache		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
89869408Sache		echo rolling ${TD}/$$tn tarball &&\
89969408Sache		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
90069408Sache		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
90169408Sache		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
90269408Sache		   ${RD}/dists/${TD}/$$tn.inf && \
90369408Sache		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
90469408Sache		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
90569408Sache		fi && \
90669408Sache		if [ "${SD}" != "/usr/src" ]; then \
90769408Sache			mtree -c -i -p ${SD}/${ARG} \
90869408Sache			  -k gname,md5digest,mode,nlink,uname,size,link,type \
90969408Sache			  > ${RD}/dists/${TD}/$$tn.mtree ; \
91069408Sache		else \
91169408Sache			true; \
91269408Sache		fi; \
91369408Sache		(cd ${RD}/dists/${TD}; \
91469408Sache		   rm -f CHECKSUM.MD5; \
91569408Sache		   md5 * > CHECKSUM.MD5) \
91669408Sache	)
91769408Sache
91869408SachedoRELEASE:  release.1 release.2 release.3 ${DOCREL} release.4 release.5 \
91969408Sache		release.6 release.7 release.8 release.9 ${FIXIT_TARGET}
92069408Sache	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
92169408Sache	@echo "Release done"
92269408Sache
92369408Sachefloppies:
92469408Sache	@cd ${.CURDIR} && ${MAKE} boot.flp
92569408Sache	@cd ${.CURDIR} && ${MAKE} fixit.flp
92669408Sache	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
92769408Sache
92869408Sacheboot.flp:
92969408Sache	@rm -f release.5 release.9
93069408Sache	@cd ${.CURDIR} && ${MAKE} release.5 release.9 CRUNCH_TARGETS=boot
93169408Sache
93269408Sachefixit.flp:
93369408Sache	@rm -f release.5 release.10
93469408Sache	@cd ${.CURDIR} && ${MAKE} release.5 release.10 CRUNCH_TARGETS=fixit
93569408Sache
93669408SacheinstallCRUNCH:
93769408Sache.if !defined(CRUNCH)
93869408Sache	@echo "CRUNCH undefined in installCRUNCH" && exit 1
93969408Sache.endif
94069408Sache.if !defined(DIR)
94169408Sache	@echo "DIR undefined in installCRUNCH" && exit 1
94269408Sache.endif
94369408Sache.if !defined(ZIP)
94469408Sache	@echo "ZIP undefined in installCRUNCH" && exit 1
94569408Sache.endif
94669408Sache	@if ${ZIP} ; then \
94769408Sache		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
94869408Sache	else \
94969408Sache		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
95069408Sache	fi
95169408Sache	@chmod 555 ${DIR}/${CRUNCH}_crunch
95269408Sache	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
95369408Sache		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
95469408Sache			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
95569408Sache		done \
95669408Sache	else \
95769408Sache		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
95869408Sache			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
95969408Sache		done \
96069408Sache	fi
96169408Sache
96269408Sache#
96369408Sache# --==## Put a filesystem into a BOOTMFS kernel ##==--
96469408Sache#
96569408SachedoMFSKERN:
96669408Sache	@echo "Running ${.TARGET} for ${FSIMAGE}"
96769408Sache	@rm -f ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
96869408Sache	@cd ${.CURDIR}/../sys/${TARGET}/conf && \
96969408Sache	    sh ${.CURDIR}/${TARGET}/dokern.sh ${FDSIZE} < GENERIC > BOOTMFS && \
970	    [ -r GENERIC.hints ] && cp GENERIC.hints BOOTMFS.hints
971.if defined(FDSIZE) && ${FDSIZE} == "SMALL" && \
972    exists(${.CURDIR}/${TARGET}/drivers-small.conf)
973	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
974		${.CURDIR}/${TARGET}/drivers-small.conf \
975		${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
976.elif exists(${.CURDIR}/${TARGET}/drivers.conf)
977	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
978		${.CURDIR}/${TARGET}/drivers.conf \
979		${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
980.endif
981	cd ${.CURDIR}/..; \
982	KERNEL_KO=BOOTMFS KODIR= \
983	    ${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES -DNO_KERNELCLEAN \
984	    KERNCONF=BOOTMFS COPTFLAGS="-Os -pipe" -DNO_CPU_COPTFLAGS \
985	    buildkernel reinstallkernel \
986	    DESTDIR=${RD}/kernels
987	[ -r ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ] && \
988	cp ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ${RD}/kernels
989	@rm -rf ${RD}/image.${FSIMAGE}
990	@mkdir ${RD}/image.${FSIMAGE}
991	@cd ${RD}/kernels && \
992	  (chflags noschg BOOTMFS || true) && \
993	  ${WMAKEENV} strip BOOTMFS && \
994	  cp BOOTMFS BOOTMFS.${FSIMAGE} && \
995	  [ -r BOOTMFS.hints ] && mv BOOTMFS.hints BOOTMFS.${FSIMAGE}.hints
996	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
997	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
998	@mkdir -p ${RD}/image.${FSIMAGE}/boot
999.if ${TARGET} == "i386"
1000	@kgzip -vo ${RD}/image.${FSIMAGE}/boot/loader /boot/loader
1001.else
1002	@cp /boot/loader ${RD}/image.${FSIMAGE}/boot
1003.endif
1004	@[ -r ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints ] && \
1005	  sed -e '/^hint/s/^/set /' -e '/^#/d' \
1006	    ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints > \
1007	    ${RD}/image.${FSIMAGE}/boot/device.hints && \
1008	  echo "include /boot/device.hints" > ${RD}/image.${FSIMAGE}/boot/loader.rc
1009	@echo "load /kernel" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1010.if !defined(FDSIZE) || ${FDSIZE} != "BIG"
1011	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1012	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1013	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1014.endif
1015	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1016	@echo "set hint.acpi.0.disabled=1" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1017	@echo "set module_path=\"/stand/modules;/dist\"" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1018	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1019	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1020.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
1021	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
1022.endif
1023	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
1024	@rm -f ${RD}/floppies/${FSIMAGE}.flp
1025.if defined(FDSIZE) && ${FDSIZE} == "BIG"
1026	@cp mfsroot.gz ${RD}/image.${FSIMAGE}
1027	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1028		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
1029		${BOOTINODE} ${BIGBOOTLABEL}
1030.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
1031	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1032		${RD} ${MNT} ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} \
1033		${BOOTINODE} ${SMALLBOOTLABEL}
1034.else
1035	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1036		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
1037		${BOOTINODE} ${BOOTLABEL}
1038.endif
1039	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1040
1041.include <bsd.prog.mk>
1042