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