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