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