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