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