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