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