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