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