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