Makefile revision 104144
1# $FreeBSD: head/release/Makefile 104144 2002-09-29 13:47:01Z nyan $
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	if [ -d ${RD}/driversfd ]; then \
640	    sh -e ${.CURDIR}/scripts/doFS.sh \
641		${RD}/floppies/drivers.flp ${RD} ${MNT} ${BOOTSIZE} \
642		${RD}/driversfd ${BOOTINODE} ${BOOTLABEL}; \
643	fi
644.endif
645	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
646		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
647	@gzip -9vc mfsroot > mfsroot.gz
648.if ${TARGET} == "pc98"
649	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
650		${RD} ${MNT} ${SMALLBOOTSIZE} mfsroot.gz \
651		${BOOTINODE} ${SMALLBOOTLABEL}
652	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
653	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
654.else
655	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
656		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
657	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
658	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
659.endif
660	@rm mfsroot mfsroot.gz
661	@echo "Regular and MFS boot floppies made."
662	touch release.9
663
664#
665# --==## Create a fixit floppy ##==--
666#
667release.10:
668	@echo "Making fixit floppy."
669	@rm -rf ${RD}/fixitfd
670	@mkdir ${RD}/fixitfd
671	@cd ${RD}/fixitfd && \
672		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
673		usr/share/misc
674	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
675		DIR=${RD}/fixitfd/stand ZIP=false
676	@( cd ${RD}/fixitfd/dev && \
677		cp ${RD}/trees/base/dev/MAKEDEV MAKEDEV && \
678		chmod 755 MAKEDEV)
679	@cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
680		${RD}/trees/base/etc/protocols ${RD}/fixitfd/etc
681	@cp ${RD}/trees/base/usr/share/misc/scsi_modes \
682		${RD}/fixitfd/usr/share/misc
683	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
684	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
685	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
686	@chmod 555 ${RD}/fixitfd/stand/tar
687	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
688		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
689# Do our last minute floppies directory setup in a convenient place.
690.if !defined(NODOC)
691	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
692		${RD}/floppies/README.TXT
693	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
694.else
695	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
696.endif
697	touch release.10
698
699#
700# --==## Setup a suitable ftp-area ##==--
701#
702ftp.1:
703	@echo "Setting up FTP distribution area"
704	@mkdir -p ${FD}
705	-@ln -s . ${FD}/${BUILDNAME}
706	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
707	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
708.if !defined(NODOC)
709	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
710	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
711	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
712	done
713	@for i in ${DIST_DOCS_ARCH_DEP}; do \
714	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
715	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
716	done
717	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
718	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
719	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
720.endif
721	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
722.if !defined(NOPORTS)
723	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
724.endif
725	touch ftp.1
726
727#
728# --==## Setup a suitable cdrom-area ##==--
729#
730cdrom.1:
731	@echo "Setting up CDROM distribution area"
732	@mkdir -p ${CD_DISC1} ${CD_DISC2}
733	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
734	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
735	@for i in ${DISTRIBUTIONS} ; \
736	do \
737		if [ -d ${RD}/trees/$${i} ] ; then \
738			chflags -R noschg ${RD}/trees/$${i} || true ; \
739			( cd ${RD}/trees/$${i} && \
740			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
741		fi \
742	done
743	@rm -f ${CD_DISC2}/.profile
744	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
745	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
746	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
747.if !defined(NODOC)
748	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
749	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
750	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
751	done
752	@for i in ${DIST_DOCS_ARCH_DEP}; do \
753	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
754	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
755	done
756	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
757	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
758	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
759.endif
760.if ${TARGET} != "pc98"
761	@echo "Setting up /boot"
762	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
763	@ln -f ${RD}/image.boot/mfsroot.gz ${CD_DISC1}/boot/mfsroot.gz
764	@ln -f ${CD_DISC1}/boot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
765	@echo 'mfsroot_load="YES"' > ${CD_DISC1}/boot/loader.conf
766	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC1}/boot/loader.conf
767	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC1}/boot/loader.conf
768	@ln -f ${CD_DISC1}/boot/loader.conf ${CD_DISC2}/boot/loader.conf
769.endif
770.if ${TARGET} == "i386"
771	@mkdir -p ${CD_DISC2}/floppies
772	@cp ${CD_DISC1}/floppies/boot.flp ${CD_DISC2}/floppies
773.endif
774.if !defined(NOPORTS)
775	@mkdir -p ${CD_DISC1}/ports && \
776	  tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
777	  ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
778	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
779	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
780.endif
781	touch cdrom.1
782
783iso.1:
784	@if [ -r ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ]; then \
785		echo "Creating ISO images..."; \
786		sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
787		  fbsd_miniinst ${CD}/miniinst.iso ${CD_DISC1}; \
788		sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
789		  fbsd_livefs ${CD}/disc2.iso ${CD_DISC2}; \
790		if [ "x${CD_EXTRA_BITS}" != "x" ]; then \
791			sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
792			  fbsd_boot ${CD}/disc1.iso ${CD_DISC1} ${CD_EXTRA_BITS} \
793			    && false; \
794		fi \
795	else \
796		echo "Do not know how to create an ISO for ${TARGET_ARCH}."; \
797	fi
798	touch iso.1
799
800#
801# --==## Documentation Project files such as the Handbook and FAQ ##==--
802#
803doc.1:
804	@echo "Making docs..."
805	@for i in ${DOCPORTS}; do \
806	    cd /usr/ports/$$i && \
807	    env -i PATH=$${PATH} make all install clean \
808		BATCH=yes WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
809		FORCE_PKG_REGISTER=yes; \
810	done
811	@cd /usr/doc && make all install 'FORMATS=html html-split txt' INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc
812	touch doc.1
813
814#
815# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
816#
817doc.2:
818	@echo "Making release documentation..."
819	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' INSTALL_COMPRESSED='' DOCDIR=${RND}
820	touch doc.2
821
822# Various "subroutine" and other supporting targets.
823
824# RD=
825# SD=
826# TD=
827# ARG=
828doTARBALL:
829.if !defined(SD)
830	@echo "SD undefined in doTARBALL" && exit 1
831.endif
832.if !defined(TD)
833	@echo "TD undefined in doTARBALL" && exit 1
834.endif
835.if !defined(ARG)
836	@echo "ARG undefined in doTARBALL" && exit 1
837.endif
838	@rm -rf ${RD}/dists/${TD}/${TN}*
839	@mkdir -p ${RD}/dists/${TD}
840	@( cd ${SD} && \
841		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
842		echo rolling ${TD}/$$tn tarball &&\
843		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
844		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
845		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
846		   ${RD}/dists/${TD}/$$tn.inf && \
847		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
848		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
849		fi && \
850		if [ "${SD}" != "/usr/src" ]; then \
851			mtree -c -i -p ${SD}/${ARG} \
852			  -k gname,md5digest,mode,nlink,uname,size,link,type \
853			  > ${RD}/dists/${TD}/$$tn.mtree ; \
854		else \
855			true; \
856		fi; \
857		(cd ${RD}/dists/${TD}; \
858		   rm -f CHECKSUM.MD5; \
859		   md5 * > CHECKSUM.MD5) \
860	)
861
862doRELEASE:  release.1 release.2 release.3 ${DOCREL} release.4 release.5 \
863		release.6 release.7 release.8 release.9 release.10
864	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
865	@echo "Release done"
866
867floppies:
868	@cd ${.CURDIR} && ${MAKE} boot.flp
869	@cd ${.CURDIR} && ${MAKE} fixit.flp
870	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
871
872boot.flp:
873	@rm -f release.5 release.9
874	@cd ${.CURDIR} && ${MAKE} release.5 release.9 CRUNCH_TARGETS=boot
875
876fixit.flp:
877	@rm -f release.5 release.10
878	@cd ${.CURDIR} && ${MAKE} release.5 release.10 CRUNCH_TARGETS=fixit
879
880installCRUNCH:
881.if !defined(CRUNCH)
882	@echo "CRUNCH undefined in installCRUNCH" && exit 1
883.endif
884.if !defined(DIR)
885	@echo "DIR undefined in installCRUNCH" && exit 1
886.endif
887.if !defined(ZIP)
888	@echo "ZIP undefined in installCRUNCH" && exit 1
889.endif
890	@if ${ZIP} ; then \
891		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
892	else \
893		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
894	fi
895	@chmod 555 ${DIR}/${CRUNCH}_crunch
896	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
897		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
898			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
899		done \
900	else \
901		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
902			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
903		done \
904	fi
905
906#
907# --==## Put a filesystem into a BOOTMFS kernel ##==--
908#
909doMFSKERN:
910	@echo "Running ${.TARGET} for ${FSIMAGE}"
911	@rm -f ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
912	@cd ${.CURDIR}/../sys/${TARGET}/conf && \
913	    sh ${.CURDIR}/${TARGET}/dokern.sh ${FDSIZE} < GENERIC > BOOTMFS && \
914	    [ -r GENERIC.hints ] && cp GENERIC.hints BOOTMFS.hints
915.if exists(${.CURDIR}/${TARGET}/drivers.conf)
916	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
917		${.CURDIR}/${TARGET}/drivers.conf \
918		${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
919.endif
920	cd ${.CURDIR}/..; \
921	KERNEL_KO=BOOTMFS KODIR= \
922	    ${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES -DNO_KERNELCLEAN \
923	    KERNCONF=BOOTMFS COPTFLAGS="-Os -pipe" -DNO_CPU_COPTFLAGS \
924	    buildkernel reinstallkernel \
925	    DESTDIR=${RD}/kernels
926	[ -r ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ] && \
927	cp ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ${RD}/kernels
928	@rm -rf ${RD}/image.${FSIMAGE}
929	@mkdir ${RD}/image.${FSIMAGE}
930	@cd ${RD}/kernels && \
931	  (chflags noschg BOOTMFS || true) && \
932	  ${WMAKEENV} strip BOOTMFS && \
933	  cp BOOTMFS BOOTMFS.${FSIMAGE} && \
934	  [ -r BOOTMFS.hints ] && mv BOOTMFS.hints BOOTMFS.${FSIMAGE}.hints
935	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
936	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
937	@mkdir -p ${RD}/image.${FSIMAGE}/boot
938.if ${TARGET} == "i386"
939	@kgzip -vo ${RD}/image.${FSIMAGE}/boot/loader /boot/loader
940.else
941	@cp /boot/loader ${RD}/image.${FSIMAGE}/boot
942.endif
943	@[ -r ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints ] && \
944	  sed -e '/^hint/s/^/set /' -e '/^#/d' \
945	    ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints > \
946	    ${RD}/image.${FSIMAGE}/boot/device.hints && \
947	  echo "include /boot/device.hints" > ${RD}/image.${FSIMAGE}/boot/loader.rc
948	@echo "load /kernel" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
949.if !defined(FDSIZE) || ${FDSIZE} != "BIG"
950	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
951	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
952	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
953.endif
954	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
955	@echo "set hint.acpi.0.disabled=1" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
956	@echo "set module_path=\"/stand/modules;/dist\"" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
957	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
958	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
959.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
960	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
961.endif
962	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
963	@rm -f ${RD}/floppies/${FSIMAGE}.flp
964.if defined(FDSIZE) && ${FDSIZE} == "BIG"
965	@cp mfsroot.gz ${RD}/image.${FSIMAGE}
966	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
967		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
968		${BOOTINODE} ${BIGBOOTLABEL}
969.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
970	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
971		${RD} ${MNT} ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} \
972		${BOOTINODE} ${SMALLBOOTLABEL}
973.else
974	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
975		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
976		${BOOTINODE} ${BOOTLABEL}
977.endif
978	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
979
980.include <bsd.prog.mk>
981