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