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