Makefile revision 107732
1# $FreeBSD: head/release/Makefile 107732 2002-12-10 16:35:44Z bmah $
2#
3# make release CHROOTDIR=/some/dir BUILDNAME=somename CVSROOT=/cvs/dir \
4#	[ RELEASETAG=tag ]
5#
6# Where "/some/dir" is the pathname of a directory on a some filesystem with
7# at least 1000MB of free space, "somename" is what you want the release to
8# call itself, "/cvs/dir" is where our source repo resides and, optionally,
9# which CVS "tag" name should be used when checking out the sources to build
10# the release (default is HEAD).
11#
12# Please note: the md(4) driver must be compiled into your kernel
13# or available as a kld(4)-style kernel module,
14# otherwise the target 'release.9' and possibly others will fail.
15#
16# Note:  "/some/dir" cannot reside on a filesystem mounted with
17# the "nodev" option, otherwise the chrooted "buildworld" will likely
18# fail.
19#
20# Note: If you add options to this file, please keep release(7) updated!
21#
22# Set these, release builder!
23#
24# Fixed version:
25#BUILDNAME=5.0-RELEASE
26#
27# Automatic SNAP versioning:
28DATE != date +%Y%m%d
29BASE = 5.0
30BUILDNAME?=${BASE}-${DATE}-SNAP
31#
32#CHROOTDIR=/junk/release
33# If this is a -stable snapshot, then set
34#RELEASETAG=RELENG_4
35#
36# To add other options to the CVS subcommands (co,up), set
37#CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
38#
39# To add other options to the CVS command, set
40#CVSARGS="-lfq"
41#
42# To prefix the cvs command
43#CVSPREFIX="/usr/bin/time"
44#
45# Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
46# are building an official release.  Otherwise, we are building for
47# a branch.
48.if defined(RELEASETAG)
49ISRELEASE!=	expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
50.if ${ISRELEASE} != 0
51# Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
52AUXRELEASETAG!=	echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
53DOCRELEASETAG?=		${AUXRELEASETAG}
54PORTSRELEASETAG?=	${AUXRELEASETAG}
55.endif
56.endif
57
58# If you want to pass flags to the world build such as -j X, use
59# WORLD_FLAGS.  Similarly, you can specify make flags for kernel
60# builds via KERNEL_FLAGS.
61#WORLD_FLAGS=-j4
62#KERNEL_FLAGS=-j4
63
64TARGET_ARCH?=	${MACHINE_ARCH}
65.if ${TARGET_ARCH} == ${MACHINE_ARCH}
66TARGET?=	${MACHINE}
67.else
68TARGET?=	${TARGET_ARCH}
69.endif
70CROSSMAKE=	${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
71NATIVEMAKE=	${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
72
73# If you are using a local CVS repository with components stored in 
74# non-standard modules, override these on the make commandline or
75# in the environment.
76RELEASESRCMODULE?=	src
77RELEASEDOCMODULE?=	doc
78RELEASEPORTSMODULE?=	ports
79
80# Uncomment this to disable the doc.1 target.  Docs normally require
81# the ports tree, so NOPORTS can be set together with NODOC in order
82# to have neither ports or docs.  If only NOPORTS is set to YES, but
83# docs are still desired, the DOMINIMALDOCPORTS logic below will only
84# install the ports that are minimally required for the docs.  This is
85# intended as a compromise, less disk space is required than for using
86# the entire ports collection (and much less time due to the huge number
87# of directories it would create), but still quite a bit as well as some
88# CPU cycles (some of the programs are C++, and things like ghostscript
89# belong to the required ports nevertheless).
90#
91# Setting this also disables building of release note documentation
92# (RELNOTESng).
93#NODOC=  YES
94#NOPORTS=  YES
95
96# Modify this definition if you want the release notes 
97# and other release documentation in a language other than English.
98RELNOTES_LANG?=	en_US.ISO8859-1
99
100# As an alternative to installing the entire ports collection (which
101# can take a huge amount of time, in particular on slower disks),
102# setting ${MINIMALDOCPORTS} allows to install and build just those
103# ports that are really required for getting the docs up & running.
104.if defined(NOPORTS) && !defined(NODOC)
105DOMINIMALDOCPORTS=	YES
106.include "Makefile.inc.docports"
107RELEASEPORTSMODULE=	${MINIMALDOCPORTS}
108.endif
109
110# Helper variable
111.if defined(NOPORTS)
112.if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
113NOPORTSATALL=	YES
114.endif
115.endif
116
117# By default, documentation (Handbook, FAQ, etc.) is built for all
118# the languages.  To speed up building, set the DOC_LANG to just
119# the languages you need.  (The language for the release notes is
120# controlled by the RELNOTES_LANG variable above.)
121#DOC_LANG=	en_US.ISO8859-1
122DOCPORTS=	textproc/docproj
123# Set this to wherever the distfiles required by release procedures.
124.if defined(DOCDISTFILES)
125# Respect DOCDISTFILES which is used before.
126RELEASEDISTFILES?=	${DOCDISTFILES}
127.else
128RELEASEDISTFILES?=	${.CURDIR}/../../ports/distfiles
129.endif
130# Set this to 1 if you want -P to be used for automatic keyboard detection
131# on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
132AUTO_KEYBOARD_DETECT?= 0
133
134.if !defined(NODOC)
135DIST_DOCS_ARCH_INDEP=	readme errata early-adopter
136DIST_DOCS_ARCH_DEP=	installation relnotes hardware
137.endif
138
139# Things which without too much trouble can be considered variables
140# BASE_DISTS are special in that they get full /etc installation sets.
141#
142.if ${TARGET_ARCH} == "i386"
143COMPAT_DISTS?=	compat1x compat20 compat21 compat22 compat3x compat4x
144.elif ${TARGET_ARCH} != "ia64"
145COMPAT_DISTS?=	compat4x
146.endif
147OTHER_DISTS?=	catpages manpages games proflibs dict info doc
148CRYPTO_DISTS?=	crypto krb4 krb5
149BASE_DISTS?=	base
150DISTRIBUTIONS?=	${BASE_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS}
151
152# mountpoint for filesystems.
153MNT=			/mnt
154
155# Various floppy image parameters.
156#
157
158.if ${TARGET_ARCH} == "i386"
159.if ${TARGET} == "pc98"
160SMALLBOOTSIZE=		1200
161BOOTSIZE=		1440
162SMALLFIXITSIZE=		1200
163FIXITSIZE=		1440
164MFSSIZE=		4320
165BOOTINODE=		80000
166FIXITINODE=		40000
167MFSINODE=		8000
168SMALLBOOTLABEL=		fd1200
169BOOTLABEL=		fd1440
170SMALLFIXITLABEL=	fd1200
171FIXITLABEL=		fd1440
172MFSLABEL=		minimum3
173.else
174DRIVERSIZE=		1440
175BOOTSIZE=		1440
176FIXITSIZE=		1440
177MFSSIZE=		4320
178BIGBOOTSIZE=		2880
179DRIVERINODE=		40000
180BOOTINODE=		80000
181FIXITINODE=		40000
182MFSINODE=		8000
183DRIVERLABEL=		fd1440
184BOOTLABEL=		fd1440
185FIXITLABEL=		fd1440
186MFSLABEL=		minimum3
187BIGBOOTLABEL=		minimum2
188.endif
189.elif ${TARGET_ARCH} == "alpha"
190DRIVERSIZE=		1440
191BOOTSIZE=		1440
192FIXITSIZE=		2880
193MFSSIZE=		4320
194BIGBOOTSIZE=		2880
195DRIVERINODE=		80000
196BOOTINODE=		80000
197FIXITINODE=		40000
198MFSINODE=		8000
199DRIVERLABEL=		fd1440
200BOOTLABEL=		fd1440
201FIXITLABEL=		minimum2
202MFSLABEL=		auto
203BIGBOOTLABEL=		minimum2
204.elif ${TARGET_ARCH} == "sparc64"
205BIGBOOTSIZE=		4096
206MFSSIZE=		4096
207BOOTINODE=		8192
208MFSINODE=		8192
209BIGBOOTLABEL=		auto
210MFSLABEL=		auto
211.elif ${TARGET_ARCH} == "ia64"
212BIGBOOTLABEL=		efi
213BIGBOOTSIZE=		5154
214BOOTINODE=		15872
215MFSINODE=		8192
216MFSLABEL=		auto
217MFSSIZE=		8192
218.endif
219
220ZIPNSPLIT=		gzip --no-name -9 -c | split -b 240640 -
221
222# Things that need to be recompiled with Kerberos support.
223.if exists(${.CURDIR}/../kerberosIV) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
224K4PROGS!=	cd ${.CURDIR}/../kerberosIV; ${MAKE} -V KPROGS
225.endif
226.if exists(${.CURDIR}/../kerberos5) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
227K5PROGS!=	cd ${.CURDIR}/../kerberos5; ${MAKE} -V KPROGS
228.endif
229
230# Things that need to be compiled without crypto support in releases
231.if !defined(FIXCRYPTO)
232FIXCRYPTO=	bin/ed usr.sbin/ppp usr.sbin/pppd usr.sbin/tcpdump/tcpdump \
233		lib/libfetch usr.bin/fetch
234.if !defined(NO_SENDMAIL)
235FIXCRYPTO+=	usr.sbin/sendmail
236.endif
237.endif
238
239
240# Things which may get you into trouble if you change them
241MTREEFILES=		${.CURDIR}/../etc/mtree
242_R?=			/R
243RD=			${_R}/stage
244RND=			${RD}/release.doc
245FD=			${_R}/ftp
246CD=			${_R}/cdrom
247CD_DISC1=		${CD}/disc1
248CD_DISC2=		${CD}/disc2
249
250# Where the bootstrap ports (see DOCPORTS) get installed.
251LOCALDIR=		/usr/local/bin
252
253# ia64 is different enough that we want our own doFS.sh.
254.if ${TARGET_ARCH} == "ia64"
255DOFS_SH=	${.CURDIR}/ia64/doFS.sh
256.else
257DOFS_SH=	${.CURDIR}/scripts/doFS.sh
258.endif
259
260.if ${TARGET_ARCH} == "sparc64"
261CRUNCH_TARGETS= boot
262FIXIT_TARGET=
263.elif ${TARGET_ARCH} == "ia64"
264CRUNCH_TARGETS= boot
265FIXIT_TARGET=
266.elif ${TARGET} == "pc98"
267CRUNCH_TARGETS=	boot fixit fixit-small
268.endif
269
270.if !defined(CRUNCH_TARGETS)
271CRUNCH_TARGETS=	boot fixit
272.endif
273
274.if !defined(FIXIT_TARGET)
275FIXIT_TARGET= release.10
276.endif
277
278EXTRAS= ftp.1
279.if !defined(NOCDROM)
280EXTRAS+= cdrom.1
281.if defined(MAKE_ISOS)
282EXTRAS+= iso.1
283.if ${TARGET} != "pc98"
284BOOTABLE="-b"
285.endif
286.endif
287.endif
288
289.if !defined(NODOC)
290DOCREL= doc.1 doc.2
291.endif
292
293.if !defined(NOPORTREADMES)
294MAKEREADMES=	make readmes PORTSDIR=${CHROOTDIR}/usr/ports
295.else
296MAKEREADMES=	true
297.endif
298
299TMAKE!=		echo MAKEFLAGS=\"-m ${.CURDIR}/../share/mk\"; \
300		cd ${.CURDIR}/..; ${MAKE} -f Makefile.inc1 -V TMAKE
301WMAKEENV!=	echo MAKEFLAGS=\"-m ${.CURDIR}/../share/mk\"; \
302		cd ${.CURDIR}/..; ${CROSSMAKE} -f Makefile.inc1 -V WMAKEENV
303WMAKE=		${WMAKEENV} ${MAKE}
304
305CVS_SRCARGS=	-P
306.if defined(RELEASETAG)
307CVS_SRCARGS+=	-r ${RELEASETAG}
308.endif
309
310CVS_DOCARGS=	-P
311.if defined(DOCRELEASETAG)
312CVS_DOCARGS+=	-r ${DOCRELEASETAG}
313.endif
314
315CVS_PORTSARGS=	-P
316.if defined(PORTSRELEASETAG)
317CVS_PORTSARGS+=	-r ${PORTSRELEASETAG}
318.endif
319
320rerelease release:
321.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
322	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
323.endif
324.if defined(NOPORTSATALL) && !defined(NODOC)
325	@echo "Ports are required for building the docs.  Either set NODOC or"
326	@echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
327	@exit 1
328.endif
329.if make(release)
330.if exists(${CHROOTDIR})
331# The first command will fail on a handful of files that have their schg
332# flags set.  But it greatly speeds up the next two commands.
333	# NB: clear any vestigal devfs mount, just in case
334	-umount ${CHROOTDIR}/dev > /dev/null 2>&1
335	-rm -rf ${CHROOTDIR} 2>/dev/null
336	-chflags -R noschg ${CHROOTDIR}/.
337	-rm -rf ${CHROOTDIR}
338.endif
339	mkdir -p ${CHROOTDIR}
340	@echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
341	cd ${.CURDIR}/.. && ${NATIVEMAKE} -DNOGAMES -DNOHTML -DNOINFO -DNOMAN \
342	    -DNOPROFILE installworld DESTDIR=${CHROOTDIR}
343	cd ${.CURDIR}/../etc && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
344	if [ -f /etc/resolv.conf ]; then \
345		cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
346	fi
347.if defined(EXTLOCALDIR)
348	rm -rf ${CHROOTDIR}/usr/local
349	cd ${CHROOTDIR}/usr && cp -R ${EXTLOCALDIR} local
350.endif
351	rm -rf ${CHROOTDIR}/usr/src
352.if defined(EXTSRCDIR)
353	cd ${CHROOTDIR}/usr && \
354		cp -R ${EXTSRCDIR} src
355.else
356	cd ${CHROOTDIR}/usr && \
357		${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
358.endif
359.if defined(LOCAL_PATCHES) && exists(${LOCAL_PATCHES})
360	cd ${CHROOTDIR}/usr/src && patch ${PATCH_FLAGS} < ${LOCAL_PATCHES}
361.endif
362.if defined(LOCAL_SCRIPT) && exists(${LOCAL_SCRIPT})
363	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
364.endif
365	rm -rf ${CHROOTDIR}/usr/ports
366.if !defined(NOPORTSATALL)
367	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
368.endif
369.if !defined(NOPORTS)
370	cd ${CHROOTDIR}/usr/ports && ${MAKEREADMES}
371.endif
372.if !defined(NODOC)
373	rm -rf ${CHROOTDIR}/usr/doc
374.if defined(EXTDOCDIR)
375	cd ${CHROOTDIR}/usr && cp -R ${EXTDOCDIR} doc
376.else
377	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
378.endif
379	if [ -d ${RELEASEDISTFILES}/ ]; then \
380		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
381	else \
382		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
383	fi
384.if defined(PREFETCHDISTFILES)
385	@for i in ${DOCPORTS}; do \
386		cd ${CHROOTDIR}/usr/ports/$$i && \
387			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
388			WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
389			fetch-recursive ; \
390	done
391.endif
392.endif
393.endif
394.if make(rerelease)
395.if !defined(RELEASENOUPDATE)
396.if !defined(RELEASETAG)
397	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d -A
398.else
399	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
400.endif
401.if !defined(NOPORTS)
402	cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d
403.endif
404.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
405	for i in ${MINIMALDOCPORTS}; do \
406		( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d ) ; \
407	done
408.endif
409.if !defined(NODOC)
410	cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d
411.endif
412.endif
413.endif
414	# Add version information to those things that need it.
415	( cd ${CHROOTDIR}/usr/src/sys/conf && \
416	  mv newvers.sh foo && \
417	  sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && rm foo )
418	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
419	echo "#!/bin/sh"			> ${CHROOTDIR}/mk
420	echo "set -ex"				>> ${CHROOTDIR}/mk
421	echo "trap 'umount /dev || true' 0"	>> ${CHROOTDIR}/mk
422	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${CHROOTDIR}/mk
423.for var in \
424	AUTO_KEYBOARD_DETECT BOOT_CONFIG BUILDNAME \
425	CD_EXTRA_BITS DISTRIBUTIONS DOC_LANG DOMINIMALDOCPORTS \
426	EXTRA_SRC FIXCRYPTO KERNELS KERNEL_FLAGS \
427	MAKE_ISOS NOCDROM NODOC NO_FLOPPIES NOKERBEROS NOPORTS NOSHARED \
428	NOSRC NO_CPU_CFLAGS NO_CPU_COPTFLAGS NO_SENDMAIL RELEASETAG \
429	RELNOTES_LANG TARGET TARGET_ARCH WORLD_FLAGS
430.if defined(${var})
431	echo "export ${var}=\"${${var}}\""	>> ${CHROOTDIR}/mk
432.endif
433.endfor
434	# Don't remove this, or the build will fall over!
435	echo "export RELEASEDIR=${_R}"		>> ${CHROOTDIR}/mk
436	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${CHROOTDIR}/mk
437	echo "export MANBUILDCAT=YES"		>> ${CHROOTDIR}/mk
438	# NB: these may fail if the host is running w/o devfs
439	echo "umount /dev >/dev/null 2>&1 || true" >> ${CHROOTDIR}/mk
440	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true" \
441						>> ${CHROOTDIR}/mk
442	echo "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
443	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
444	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNOCLEAN buildworld && \\" >> ${CHROOTDIR}/mk
445	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
446	echo "fi"				>> ${CHROOTDIR}/mk
447	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
448	echo "make obj"				>> ${CHROOTDIR}/mk
449	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
450	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${CHROOTDIR}/mk
451	chmod 755 ${CHROOTDIR}/mk
452	env -i /usr/sbin/chroot ${CHROOTDIR} /mk
453
454clean:
455	rm -rf boot_crunch release.[0-9]
456
457# Clean out ${_R} and make the directory structure.
458release.1:
459	mkdir -p ${_R}
460	-rm -rf ${_R}/* 2> /dev/null
461	-chflags -R noschg ${_R}/.
462	rm -rf ${_R}/*
463	mkdir ${RD}
464	mkdir ${RD}/floppies
465	mkdir ${RD}/trees
466	mkdir ${RD}/kernels
467	for i in ${DISTRIBUTIONS} ; do \
468		mkdir ${RD}/trees/$$i && \
469		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
470		    -p ${RD}/trees/$$i > /dev/null && \
471		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
472		    -p ${RD}/trees/$$i/usr > /dev/null && \
473		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
474		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
475		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
476		    -p ${RD}/trees/$$i/var > /dev/null ; \
477	done
478	touch release.1
479
480# Install the system into the various distributions.
481release.2:
482	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
483	cd ${.CURDIR}/.. && ${CROSSMAKE} distributeworld DISTDIR=${RD}/trees
484	touch release.2
485
486# Build and install crypto, krb4 and krb5 distributions.
487release.3:
488	# Handle some grief caused by the munition braindeadness.
489	cd ${.CURDIR}/..; \
490	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DNOCRYPT \
491	    SUBDIR_OVERRIDE="${FIXCRYPTO}" \
492	    buildworld distributeworld DISTDIR=${RD}/trees
493.if exists(${.CURDIR}/../kerberosIV) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
494	cd ${.CURDIR}/..; \
495	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DMAKE_KERBEROS4 \
496	    SUBDIR_OVERRIDE="kerberosIV ${K4PROGS}" \
497	    buildworld distributeworld DISTDIR=${RD}/trees
498.endif
499.if exists(${.CURDIR}/../kerberos5) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
500	cd ${.CURDIR}/..; \
501	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DMAKE_KERBEROS5 \
502	    SUBDIR_OVERRIDE="kerberos5 ${K5PROGS}" \
503	    buildworld distributeworld DISTDIR=${RD}/trees
504	rm -f ${RD}/trees/krb5/usr/share/info/dir
505.endif
506	-chflags -R noschg ${RD}/trees
507	touch release.3
508
509# Make and install the generic kernel(s).
510release.4:
511.for kernel in ${KERNELS}
512	cd ${.CURDIR}/..; \
513	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
514	    KERNCONF=${kernel} INSTKERNNAME=${kernel} kernel \
515	    DESTDIR=${RD}/trees/base
516.endfor
517	# Install a standard boot kernel+modules.
518	cd ${.CURDIR}/..; \
519	${CROSSMAKE} ${KERNEL_FLAGS} \
520	    kernel \
521	    DESTDIR=${RD}/trees/base; \
522	cd ${.CURDIR}/..; \
523	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
524	    reinstallkernel -DINSTALL_DEBUG \
525	    DESTDIR=${RD}/trees/base
526	touch release.4
527
528# Make and install the three crunched binaries which live on the floppies.
529# You are not supposed to like this :-)
530release.5:
531	rm -rf ${RD}/crunch
532	mkdir -p ${RD}/crunch
533.for j in ${CRUNCH_TARGETS}
534	rm -rf ${j}_crunch
535	mkdir ${j}_crunch
536.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
537	cd ${j}_crunch; ${WMAKEENV} crunchgen -o ${.CURDIR}/${TARGET}/${j}_crunch.conf
538.else
539	cd ${j}_crunch; ${WMAKEENV} crunchgen -o ${.CURDIR}/${j}_crunch.conf
540.endif
541	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
542	cd ${.CURDIR}/..; ${TMAKE} build-tools
543	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk \
544	    CFLAGS="-Os -pipe" -DNO_CPU_CFLAGS all
545	mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
546.endfor
547	touch release.5
548
549#
550# --==## Fix up the distributions. ##==--
551#
552release.6:
553	# Create any "synthetic dists" now.
554	@for i in ${DISTRIBUTIONS}; do \
555		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
556			echo -n "Running $$i dist creation script... "; \
557			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
558			echo "Done."; \
559		fi \
560	done \
561
562	# Remove all the directories we don't need.
563	-cd ${RD}/trees && \
564		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
565	touch release.6
566
567#
568# --==## Package up the tarballs from assembled trees ##==--
569#
570release.7:
571	rm -rf ${RD}/dists
572	mkdir -p ${RD}/dists
573	@for i in ${DISTRIBUTIONS} ; \
574	do \
575		if [ -d ${RD}/trees/$${i} ] ; then \
576			cd ${.CURDIR} && $(MAKE) doTARBALL \
577				SD=${RD}/trees/$${i} \
578				TN=$$i TD=$$i ARG="." && \
579			echo "$${i} distribution is finished."; \
580		fi ; \
581	done
582	# More munition braindeadness.
583	( cd ${RD}/dists && \
584		if [ -f krb4/krb4.aa ] ; then \
585			mv krb4/krb4.* crypto && \
586			cat krb4/CHECKSUM.MD5 >> crypto/CHECKSUM.MD5 && \
587			rm -r krb4; \
588		fi )
589	( cd ${RD}/dists && \
590		if [ -f krb5/krb5.aa ] ; then \
591			mv krb5/krb5.* crypto && \
592			cat krb5/CHECKSUM.MD5 >> crypto/CHECKSUM.MD5 && \
593			rm -r krb5; \
594		fi )
595	touch release.7
596
597
598#
599# --==## Make source dists ##==--
600#
601release.8:
602.if !defined(NOSRC)
603	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
604		TD=src TN=sbase ARG="[A-Z]*"
605	@for i in `cd /usr/src && echo [a-z]*` ; do \
606		if [ -d /usr/src/$$i ] ; then \
607			cd ${.CURDIR} && $(MAKE) doTARBALL \
608				TN=`echo s$$i | tr -d '.' | \
609				    sed -e 's/usr/u/' \
610					-e 's/kerberosIV/krb4/' \
611					-e 's/kerberos5/krb5/'` \
612				SD=/usr/src TD=src ARG="$$i" ; \
613		fi ; \
614	done
615.if defined(EXTRA_SRC)
616	@set ${EXTRA_SRC} && \
617	while [ $$# -ge 2 ] ; do \
618		if [ -d /usr/src/$$1 ] ; then \
619			cd ${.CURDIR} && $(MAKE) doTARBALL \
620				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
621		fi && shift && shift ; \
622	done
623.endif
624	if [ -d ${RD}/dists/crypto ] ; then ( cd ${RD}/dists/src && \
625		if [ -f ssecure.aa ] ; then mv ssecure.* ../crypto ; fi && \
626		if [ -f scrypto.aa ] ; then mv scrypto.* ../crypto ; fi && \
627		if [ -f skrb4.aa ] ; then mv skrb4.* ../crypto ; fi && \
628		if [ -f skrb5.aa ] ; then mv skrb5.* ../crypto ; fi ; \
629		cd ${RD}/dists/crypto; rm -f CHECKSUM.MD5; \
630		md5 * > CHECKSUM.MD5 ) ; fi
631	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
632	@echo "src distribution is finished."
633.endif
634	touch release.8
635
636# Complete the bootfd
637#
638# Now, just to get this picture down once and for all:
639#
640# +------------------------------------------------------------------------+
641# |boot.flp                                                                |
642# +-----+-----+------------------------------------------------------------+
643# |boot1|boot2|floppy filesystem "bootfd"                                  |
644# +-----+-----+-+----------------------+---------------------------------+-+
645#               |kernel.gz             |mfsroot.gz                       |
646#               +----------------------+---------------------------------+
647#
648
649release.9:
650.if ${TARGET_ARCH} != "ia64" || ${TARGET_ARCH} == ${MACHINE_ARCH}
651	rm -rf ${RD}/mfsfd
652	mkdir ${RD}/mfsfd
653	cd ${RD}/mfsfd && \
654		mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help
655	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
656		DIR=${RD}/mfsfd/stand ZIP=false
657	( cd ${RD}/mfsfd && \
658	  for dir in bin sbin ; do \
659		ln -sf /stand $$dir; \
660	  done )
661	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
662.if ${TARGET} == "pc98"
663	cp ${.CURDIR}/../etc/defaults/pccard.conf ${RD}/mfsfd/etc/defaults/pccard.conf
664.endif
665	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
666	( for F in defaults/rc.conf netconfig protocols ; do \
667		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
668		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
669	  done )
670	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
671	    ${RD}/trees/base/etc/services | \
672	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
673	    > ${RD}/mfsfd/stand/etc/services
674	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
675	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
676	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
677.if !defined(NODOC)
678	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
679	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
680	done
681	@for i in ${DIST_DOCS_ARCH_DEP}; do \
682	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
683	done
684	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT ${RD}/mfsfd/stand/help/INSTALL.TXT
685	@mv ${RD}/mfsfd/stand/help/EARLY-ADOPTER.TXT ${RD}/mfsfd/stand/help/EARLY.TXT
686.endif
687	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
688	@mkdir -p ${RD}/mfsfd/boot
689.if ${TARGET_ARCH} != "ia64"
690	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
691.endif
692.if ${TARGET} == "i386"
693	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
694.endif
695	@echo "Making the regular boot floppy."
696	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
697		tar xf - -C ${RD}/mfsfd/stand
698.if ${TARGET_ARCH} == "alpha" && !defined(NO_FLOPPIES)
699	rm -rf ${RD}/mfsfd/stand/help/*
700.endif
701.if defined(SMALLBOOTSIZE)
702.if exists(${.CURDIR}/${TARGET}/drivers-small.conf)
703	@rm -rf ${RD}/mfsfd/modules
704	@mkdir -p ${RD}/mfsfd/modules
705	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
706	    ${.CURDIR}/${TARGET}/drivers-small.conf \
707	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/modules
708.endif
709	sh -e ${DOFS_SH} -s mfsroot-small ${RD} ${MNT} \
710		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
711	@gzip -9vc mfsroot-small > mfsroot-small.gz
712	@sh -e ${DOFS_SH} ${RD}/floppies/mfsroot-small.flp \
713		${RD} ${MNT} ${SMALLBOOTSIZE} mfsroot-small.gz \
714		${BOOTINODE} ${SMALLBOOTLABEL}
715.endif
716.if exists(${.CURDIR}/${TARGET}/drivers.conf)
717	@rm -rf ${RD}/mfsfd/modules
718	@mkdir -p ${RD}/mfsfd/modules
719	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
720	    ${.CURDIR}/${TARGET}/drivers.conf \
721	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/modules
722	@rm -rf ${RD}/driversfd
723	@mkdir ${RD}/driversfd
724	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 3 \
725	    ${.CURDIR}/${TARGET}/drivers.conf \
726	    ${RD}/trees/base/boot/kernel ${RD}/driversfd
727	-@rmdir ${RD}/driversfd
728	if [ -d ${RD}/driversfd ]; then \
729	    sh -e ${DOFS_SH} \
730		${RD}/floppies/drivers.flp ${RD} ${MNT} ${DRIVERSIZE} \
731		${RD}/driversfd ${DRIVERINODE} ${DRIVERLABEL}; \
732	fi
733.endif
734	sh -e ${DOFS_SH} -s mfsroot ${RD} ${MNT} \
735		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
736	@gzip -9vc mfsroot > mfsroot.gz
737	@mkdir -p ${RD}/mfsroot
738	@cp mfsroot.gz ${RD}/mfsroot
739.if !defined(NO_FLOPPIES)
740.if defined(BOOTSIZE)
741	@sh -e ${DOFS_SH} ${RD}/floppies/mfsroot.flp \
742		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
743	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
744.endif
745.if defined(SMALLBOOTSIZE)
746	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
747.endif
748.if defined(BIGBOOTSIZE)
749	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
750.endif
751.endif
752	@rm mfsroot mfsroot.gz
753	@echo "Regular and MFS boot floppies made."
754.endif
755	touch release.9
756
757#
758# --==## Create a fixit floppy ##==--
759#
760release.10:
761.if !defined(NO_FLOPPIES)
762	@echo "Making fixit floppy."
763	@rm -rf ${RD}/fixitfd
764	@mkdir ${RD}/fixitfd
765	@cd ${RD}/fixitfd && \
766		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
767		usr/share/misc
768	@cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
769		${RD}/trees/base/etc/protocols ${RD}/fixitfd/etc
770	@cp ${RD}/trees/base/usr/share/misc/scsi_modes \
771		${RD}/fixitfd/usr/share/misc
772	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
773	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
774	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
775	@chmod 555 ${RD}/fixitfd/stand/tar
776.if defined(SMALLFIXITSIZE)
777	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit-small \
778		DIR=${RD}/fixitfd/stand ZIP=false
779	@sh -e ${DOFS_SH} ${RD}/floppies/fixit-small.flp \
780		${RD} ${MNT} ${SMALLFIXITSIZE} ${RD}/fixitfd ${FIXITINODE} \
781		${SMALLFIXITLABEL}
782	@rm -rf ${RD}/fixitfd/stand
783	@mkdir ${RD}/fixitfd/stand
784.endif
785	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
786		DIR=${RD}/fixitfd/stand ZIP=false
787	@sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} \
788		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
789# Do our last minute floppies directory setup in a convenient place.
790.if !defined(NODOC)
791.if ${TARGET} == "i386"
792	@(cd ${RD}/driversfd; awk -f  ${.CURDIR}/scripts/driver-desc.awk \
793		*.dsc >> ${RD}/floppies/DRIVERS.TXT)
794.endif
795	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
796		${RD}/floppies/README.TXT
797	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
798.else
799	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
800.endif
801.endif
802	touch release.10
803
804#
805# --==## Setup a suitable ftp-area ##==--
806#
807ftp.1:
808	@echo "Setting up FTP distribution area"
809	@mkdir -p ${FD}
810	-@ln -s . ${FD}/${BUILDNAME}
811	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
812	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
813.if !defined(NODOC)
814	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
815	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
816	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
817	done
818	@for i in ${DIST_DOCS_ARCH_DEP}; do \
819	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
820	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
821	done
822	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
823	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
824	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
825	@mv ${FD}/EARLY-ADOPTER.TXT ${FD}/EARLY.TXT
826	@mv ${FD}/EARLY-ADOPTER.HTM ${FD}/EARLY.HTM
827.endif
828	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
829.if !defined(NOPORTS)
830	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
831.endif
832	touch ftp.1
833
834#
835# --==## Setup a suitable cdrom-area ##==--
836#
837cdrom.1:
838	@echo "Setting up CDROM distribution area"
839	@mkdir -p ${CD_DISC1} ${CD_DISC2}
840	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
841	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
842	@for i in ${DISTRIBUTIONS} ; \
843	do \
844		if [ -d ${RD}/trees/$${i} ] ; then \
845			chflags -R noschg ${RD}/trees/$${i} || true ; \
846			( cd ${RD}/trees/$${i} && \
847			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
848		fi \
849	done
850	@rm -f ${CD_DISC2}/.profile
851	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
852	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
853	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
854.if !defined(NODOC)
855	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
856	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
857	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
858	done
859	@for i in ${DIST_DOCS_ARCH_DEP}; do \
860	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
861	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
862	done
863	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
864	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
865	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
866	@mv ${CD_DISC1}/EARLY-ADOPTER.TXT ${CD_DISC1}/EARLY.TXT
867	@mv ${CD_DISC1}/EARLY-ADOPTER.HTM ${CD_DISC1}/EARLY.HTM
868.endif
869.if ${TARGET} != "pc98"
870	@echo "Setting up /boot"
871	@rm -f ${CD_DISC2}/boot/loader.conf
872	@cp ${RD}/mfsroot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
873	@echo 'mfsroot_load="YES"' > ${CD_DISC2}/boot/loader.conf
874	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC2}/boot/loader.conf
875	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC2}/boot/loader.conf
876	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
877.endif
878.if ${TARGET} == "i386"
879	@mkdir -p ${CD_DISC2}/floppies
880	@cp ${CD_DISC1}/floppies/boot.flp ${CD_DISC2}/floppies
881.endif
882.if !defined(NOPORTS)
883	@mkdir -p ${CD_DISC1}/ports && \
884	  tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
885	  ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
886	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
887	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
888.endif
889	touch cdrom.1
890
891iso.1:
892	@if [ -r ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ]; then \
893		echo "Creating ISO images..."; \
894		sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
895		  fbsd_miniinst ${CD}/${BUILDNAME}-${TARGET}-miniinst.iso ${CD_DISC1}; \
896		sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
897		  fbsd_livefs ${CD}/${BUILDNAME}-${TARGET}-disc2.iso ${CD_DISC2}; \
898		if [ "x${CD_EXTRA_BITS}" != "x" ]; then \
899			sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
900			  fbsd_boot ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} ${CD_EXTRA_BITS} \
901			    && false; \
902		fi \
903	else \
904		echo "Do not know how to create an ISO for ${TARGET_ARCH}."; \
905	fi
906	touch iso.1
907
908#
909# --==## Documentation Project files such as the Handbook and FAQ ##==--
910#
911doc.1:
912	@echo "Making docs..."
913	@for i in ${DOCPORTS}; do \
914	    cd /usr/ports/$$i && \
915	    env -i PATH=$${PATH} make all install clean \
916		BATCH=yes WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
917		FORCE_PKG_REGISTER=yes; \
918	done
919	@cd /usr/doc && make all install 'FORMATS=html html-split txt' INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc
920	touch doc.1
921
922#
923# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
924#
925doc.2:
926	@echo "Making release documentation..."
927	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' INSTALL_COMPRESSED='' DOCDIR=${RND}
928	touch doc.2
929
930# Various "subroutine" and other supporting targets.
931
932# RD=
933# SD=
934# TD=
935# ARG=
936doTARBALL:
937.if !defined(SD)
938	@echo "SD undefined in doTARBALL" && exit 1
939.endif
940.if !defined(TD)
941	@echo "TD undefined in doTARBALL" && exit 1
942.endif
943.if !defined(ARG)
944	@echo "ARG undefined in doTARBALL" && exit 1
945.endif
946	@rm -rf ${RD}/dists/${TD}/${TN}*
947	@mkdir -p ${RD}/dists/${TD}
948	@( cd ${SD} && \
949		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
950		echo rolling ${TD}/$$tn tarball &&\
951		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
952		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
953		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
954		   ${RD}/dists/${TD}/$$tn.inf && \
955		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
956		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
957		fi && \
958		if [ "${SD}" != "/usr/src" ]; then \
959			mtree -c -i -p ${SD}/${ARG} \
960			  -k gname,md5digest,mode,nlink,uname,size,link,type \
961			  > ${RD}/dists/${TD}/$$tn.mtree ; \
962		else \
963			true; \
964		fi; \
965		(cd ${RD}/dists/${TD}; \
966		   rm -f CHECKSUM.MD5; \
967		   md5 * > CHECKSUM.MD5) \
968	)
969
970doRELEASE:  release.1 release.2 release.3 ${DOCREL} release.4 release.5 \
971		release.6 release.7 release.8 release.9 ${FIXIT_TARGET}
972	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
973	@echo "Release done"
974
975floppies:
976	@cd ${.CURDIR} && ${MAKE} boot.flp
977	@cd ${.CURDIR} && ${MAKE} fixit.flp
978	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
979
980boot.flp:
981	@rm -f release.5 release.9
982	@cd ${.CURDIR} && ${MAKE} release.5 release.9 CRUNCH_TARGETS=boot
983
984fixit.flp:
985	@rm -f release.5 release.10
986	@cd ${.CURDIR} && ${MAKE} release.5 release.10 CRUNCH_TARGETS=fixit
987
988installCRUNCH:
989.if !defined(CRUNCH)
990	@echo "CRUNCH undefined in installCRUNCH" && exit 1
991.endif
992.if !defined(DIR)
993	@echo "DIR undefined in installCRUNCH" && exit 1
994.endif
995.if !defined(ZIP)
996	@echo "ZIP undefined in installCRUNCH" && exit 1
997.endif
998	@if ${ZIP} ; then \
999		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
1000	else \
1001		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
1002	fi
1003	@chmod 555 ${DIR}/${CRUNCH}_crunch
1004	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
1005		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
1006			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1007		done \
1008	else \
1009		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
1010			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1011		done \
1012	fi
1013
1014#
1015# --==## Put a filesystem into a BOOTMFS kernel ##==--
1016#
1017doMFSKERN:
1018	@echo "Running ${.TARGET} for ${FSIMAGE}"
1019	@rm -f ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
1020	@cd ${.CURDIR}/../sys/${TARGET}/conf && \
1021	    sh ${.CURDIR}/${TARGET}/dokern.sh ${FDSIZE} < GENERIC > BOOTMFS && \
1022	    [ -r GENERIC.hints ] && cp GENERIC.hints BOOTMFS.hints
1023.if defined(FDSIZE) && ${FDSIZE} == "SMALL" && \
1024    exists(${.CURDIR}/${TARGET}/drivers-small.conf)
1025	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
1026		${.CURDIR}/${TARGET}/drivers-small.conf \
1027		${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
1028.elif exists(${.CURDIR}/${TARGET}/drivers.conf)
1029	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
1030		${.CURDIR}/${TARGET}/drivers.conf \
1031		${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
1032.endif
1033	cd ${.CURDIR}/..; \
1034	KERNEL_KO=BOOTMFS KODIR= \
1035	    ${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES -DNO_KERNELCLEAN \
1036	    KERNCONF=BOOTMFS COPTFLAGS="-Os -pipe" -DNO_CPU_COPTFLAGS \
1037	    buildkernel reinstallkernel \
1038	    DESTDIR=${RD}/kernels
1039	[ -r ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ] && \
1040	cp ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ${RD}/kernels
1041	@rm -rf ${RD}/image.${FSIMAGE}
1042	@mkdir ${RD}/image.${FSIMAGE}
1043	@cd ${RD}/kernels && \
1044	  (chflags noschg BOOTMFS || true) && \
1045	  ${WMAKEENV} strip BOOTMFS && \
1046	  cp BOOTMFS BOOTMFS.${FSIMAGE} && \
1047	  [ -r BOOTMFS.hints ] && mv BOOTMFS.hints BOOTMFS.${FSIMAGE}.hints
1048	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
1049	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
1050	@mkdir -p ${RD}/image.${FSIMAGE}/boot
1051.if ${TARGET} == "i386"
1052	@kgzip -vo ${RD}/image.${FSIMAGE}/boot/loader ${RD}/trees/base/boot/loader
1053.elif ${TARGET_ARCH} == "ia64"
1054	@cp ${RD}/trees/base/boot/loader.efi ${RD}/image.${FSIMAGE}/boot
1055.else
1056	@cp ${RD}/trees/base/boot/loader ${RD}/image.${FSIMAGE}/boot
1057.endif
1058	@[ -r ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints ] && \
1059	  sed -e '/^hint/s/^/set /' -e '/^#/d' \
1060	    ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints > \
1061	    ${RD}/image.${FSIMAGE}/boot/device.hints && \
1062	  echo "include /boot/device.hints" > ${RD}/image.${FSIMAGE}/boot/loader.rc
1063	@echo "load /kernel" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1064.if !defined(FDSIZE) || ${FDSIZE} != "BIG"
1065	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1066	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1067	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1068.endif
1069	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1070.if ${TARGET_ARCH} != "ia64"
1071	@echo "set hint.acpi.0.disabled=1" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1072.endif
1073	@echo "set module_path=\"/modules;/dist\"" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1074	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1075	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1076.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
1077	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
1078.endif
1079	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
1080	@rm -f ${RD}/floppies/${FSIMAGE}.flp
1081.if defined(FDSIZE) && ${FDSIZE} == "BIG"
1082	@cp mfsroot.gz ${RD}/image.${FSIMAGE}
1083	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp \
1084		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
1085		${BOOTINODE} ${BIGBOOTLABEL}
1086.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
1087	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp \
1088		${RD} ${MNT} ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} \
1089		${BOOTINODE} ${SMALLBOOTLABEL}
1090.else
1091	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp \
1092		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
1093		${BOOTINODE} ${BOOTLABEL}
1094.endif
1095	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1096
1097.include <bsd.prog.mk>
1098