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