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