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