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