xref: /freebsd/release/Makefile (revision 8fa113e5fc65fe6abc757f0089f477a87ee4d185)
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# 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 "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
380	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
381.if make(release)
382	echo "	(cd etc; make distrib-dirs distribution)" >> ${CHROOTDIR}/mk
383	echo "	make ${WORLD_FLAGS} world && \\"	>> ${CHROOTDIR}/mk
384.endif
385.if make(rerelease)
386	echo "	make ${WORLD_FLAGS} all install && \\" >> ${CHROOTDIR}/mk
387.endif
388	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
389	echo "fi"				>> ${CHROOTDIR}/mk
390	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
391	echo "make obj"				>> ${CHROOTDIR}/mk
392	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
393	echo "echo \">>> make ${.TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${CHROOTDIR}/mk
394	chmod 755 ${CHROOTDIR}/mk
395	chroot ${CHROOTDIR} /mk
396
397clean:
398	rm -rf boot_crunch release.[0-9]
399
400# Clean out ${_R} and make the directory structure.
401release.1:
402	mkdir -p ${_R}
403	-rm -rf ${_R}/* 2> /dev/null
404	-chflags -R noschg ${_R}/.
405	rm -rf ${_R}/*
406	mkdir ${RD}
407	mkdir ${RD}/floppies
408	mkdir ${RD}/trees
409	mkdir ${RD}/dists
410	mkdir ${RD}/kernels
411	for i in ${DISTRIBUTIONS} ; do \
412		mkdir ${RD}/trees/$$i && \
413		mkdir ${RD}/dists/$$i && \
414		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
415		    -p ${RD}/trees/$$i > /dev/null && \
416		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
417		    -p ${RD}/trees/$$i/usr > /dev/null && \
418		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
419		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
420		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
421		    -p ${RD}/trees/$$i/var > /dev/null ; \
422	done
423	touch release.1
424
425# Install the system into the various distributions.
426release.2:
427	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/bin
428	cd ${.CURDIR}/.. && make distribworld DISTDIR=${RD}/trees
429.if exists(${.CURDIR}/../kerberosIV) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
430	cd ${.CURDIR}/../kerberosIV && ( \
431		make bootstrap &&\
432		make obj all help-distribute DISTDIR=${RD}/trees &&\
433		make kprog \
434	)
435.endif
436.if exists(${.CURDIR}/../kerberos5) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
437	cd ${.CURDIR}/../kerberos5 && ( \
438		make bootstrap &&\
439		make obj all help-distribute DISTDIR=${RD}/trees &&\
440		make kprog \
441	)
442.endif
443	-chflags -R noschg ${RD}/trees
444	touch release.2
445
446# Make and install the generic kernel(s).
447release.3:
448.for kernel in ${KERNELS}
449	-chflags -R noschg ${RD}/kernels/${kernel}
450	rm -rf ${RD}/kernels/${kernel}
451	rm -rf ${.CURDIR}/../sys/${MACHINE}/compile/${kernel}
452	cd ${.CURDIR} && ${MAKE} doSTDKERNEL KERNEL=${kernel} KODIR=/${kernel}
453	rm -rf ${.CURDIR}/../sys/${MACHINE}/compile/${kernel}
454	-mkdir ${RD}/trees/bin/boot/${kernel}
455	cp -p ${RD}/kernels/${kernel}/kernel ${RD}/trees/bin/boot/${kernel}
456.endfor
457	# Install a standard boot kernel+modules
458	mkdir -p ${RD}/trees/bin/boot/kernel
459	cp -Rp ${RD}/kernels/GENERIC/* ${RD}/trees/bin/boot/kernel
460	touch release.3
461
462# Make and install the three crunched binaries which live on the floppies.
463# You are not supposed to like this :-)
464release.4:
465	@mkdir -p /stand
466	rm -rf ${RD}/crunch
467	mkdir -p ${RD}/crunch
468	for j in ${CRUNCH_TARGETS} ; do \
469		rm -rf $${j}_crunch && \
470		mkdir $${j}_crunch && \
471		( cd $${j}_crunch && \
472		  ( ( [ -f ${.CURDIR}/${MACHINE}/$${j}_crunch.conf ] && \
473		    crunchgen ${.CURDIR}/${MACHINE}/$${j}_crunch.conf ) || \
474		    ( crunchgen ${.CURDIR}/$${j}_crunch.conf ) ) && \
475		  ${MAKE} -f $${j}_crunch.mk subclean all ) && \
476		mv $${j}_crunch/$${j}_crunch ${RD}/crunch/$${j} && \
477		true || { rm -rf $${j}_crunch ; false ; } ; \
478	done
479	touch release.4
480
481#
482# --==## Fix up the distributions. ##==--
483#
484release.5:
485	# Handle some grief caused by the munition braindeadness.
486	for i in ${FIXCRYPTO}; do \
487		( cd ${.CURDIR}/../$$i; \
488		  make -DNOCRYPT clean all distribute DISTDIR=${RD}/trees ) ; \
489	done
490
491	# Create any "synthetic dists" now.
492	@for i in ${DISTRIBUTIONS}; do \
493		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
494			echo -n "Running $$i dist creation script... "; \
495			env OBJFORMAT=${OBJFORMAT} RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
496			echo "Done."; \
497		fi \
498	done \
499
500	# Remove all the directories we don't need.
501	-cd ${RD}/trees && \
502		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
503	touch release.5
504
505#
506# --==## Package up the tarballs from assembled trees ##==--
507#
508release.6:
509	rm -rf ${RD}/dists
510	mkdir -p ${RD}/dists
511	@for i in ${DISTRIBUTIONS} ; \
512	do \
513		if [ -d ${RD}/trees/$${i} ] ; then \
514			cd ${.CURDIR} && $(MAKE) doTARBALL \
515				SD=${RD}/trees/$${i} \
516				TN=$$i TD=$$i ARG="." && \
517			echo "$${i} distribution is finished."; \
518		fi ; \
519	done
520	# More munition braindeadness.
521	( cd ${RD}/dists && \
522		if [ -f krb4/krb4.aa ] ; then \
523			mv krb4/krb4.* crypto && \
524			cat krb4/CHECKSUM.MD5 >> crypto/CHECKSUM.MD5 && \
525			rm -r krb4; \
526		fi )
527	( cd ${RD}/dists && \
528		if [ -f krb5/krb5.aa ] ; then \
529			mv krb5/krb5.* crypto && \
530			cat krb5/CHECKSUM.MD5 >> crypto/CHECKSUM.MD5 && \
531			rm -r krb5; \
532		fi )
533	touch release.6
534
535
536#
537# --==## Make source dists ##==--
538#
539release.7:
540.if !defined(NOSRC)
541	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
542		TD=src TN=sbase ARG="[A-Z]*"
543	@for i in `cd /usr/src && echo [a-z]*` ; do \
544		if [ -d /usr/src/$$i ] ; then \
545			cd ${.CURDIR} && $(MAKE) doTARBALL \
546				TN=`echo s$$i | tr -d '.' | \
547				    sed -e 's/usr/u/' \
548					-e 's/kerberosIV/krb4/' \
549					-e 's/kerberos5/krb5/'` \
550				SD=/usr/src TD=src ARG="$$i" ; \
551		fi ; \
552	done
553.if defined(EXTRA_SRC)
554	@set ${EXTRA_SRC} && \
555	while [ $$# -ge 2 ] ; do \
556		if [ -d /usr/src/$$1 ] ; then \
557			cd ${.CURDIR} && $(MAKE) doTARBALL \
558				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
559		fi && shift && shift ; \
560	done
561.endif
562	if [ -d ${RD}/dists/crypto ] ; then ( cd ${RD}/dists/src && \
563		if [ -f ssecure.aa ] ; then mv ssecure.* ../crypto ; fi && \
564		if [ -f scrypto.aa ] ; then mv scrypto.* ../crypto ; fi && \
565		if [ -f skrb4.aa ] ; then mv skrb4.* ../crypto ; fi && \
566		if [ -f skrb5.aa ] ; then mv skrb5.* ../crypto ; fi ; \
567		cd ${RD}/dists/crypto; rm -f CHECKSUM.MD5; \
568		md5 * > CHECKSUM.MD5 ) ; fi
569	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
570	@echo "src distribution is finished."
571.endif
572	touch release.7
573
574# Complete the bootfd
575#
576# Now, just to get this picture down once and for all:
577#
578# +------------------------------------------------------------------------+
579# |boot.flp                                                                |
580# +-----+-----+------------------------------------------------------------+
581# |boot1|boot2|floppy filesystem "bootfd"                                  |
582# +-----+-----+-+----------------------+---------------------------------+-+
583#               |kernel.gz             |mfsroot.gz                       |
584#               +----------------------+---------------------------------+
585#
586
587release.8:
588	rm -rf ${RD}/mfsfd
589	mkdir ${RD}/mfsfd
590	cd ${RD}/mfsfd && \
591		mkdir -p etc/defaults dev mnt stand/help
592	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
593		DIR=${RD}/mfsfd/stand ZIP=false
594	( cd ${RD}/trees/bin/dev && \
595		ls console tty bpf0 ttyd0 ttyv0 ttyv1 ttyv2 ttyv3 null zero card0 card1 card2 card3 usb usb0 uhid0 ums0 ulpt0 ugen0 kbd0 kmem mem | \
596	cpio -dump ${RD}/mfsfd/dev )
597	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
598	( cd ${RD}/mfsfd && \
599	  for dir in bin sbin ; do \
600		ln -sf /stand $$dir; \
601	  done )
602	cp /sbin/dhclient-script ${RD}/mfsfd/stand
603	cp ${.CURDIR}/../etc/defaults/pccard.conf ${RD}/mfsfd/etc/defaults/pccard.conf
604	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
605	cd ${RD}/trees/bin && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
606	( for F in netconfig protocols ; do \
607		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
608		${RD}/trees/bin/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
609	  done )
610	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
611	    ${.CURDIR}/../etc/services | \
612	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
613	    > ${RD}/mfsfd/stand/etc/services
614	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
615	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
616	gzip -9c ${.CURDIR}/../COPYRIGHT > ${RD}/mfsfd/stand/help/COPYRIGHT.hlp.gz
617.if !defined(NODOC)
618	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
619	  gzip -9c ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.txt > ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT.gz; \
620	done
621	@for i in ${DIST_DOCS_ARCH_DEP}; do \
622	  gzip -9c ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.txt > ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT.gz; \
623	done
624	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT.gz ${RD}/mfsfd/stand/help/INSTALL.TXT.gz
625.endif
626	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
627	@mkdir -p ${RD}/mfsfd/boot
628	@cp /boot/boot* ${RD}/mfsfd/boot
629	@cp /boot/loader.help ${RD}/mfsfd/boot
630	@cd ${.CURDIR} && ${MAKE} createBOOTMFS
631.if exists(${.CURDIR}/${MACHINE}/drivers.conf)
632	@cd ${.CURDIR} && ${MAKE} doMODULES KERNEL=BOOTMFS KERNEL_KO=BOOTMFS KODIR=""
633.endif
634	@echo "Making the regular boot floppy."
635	@tar --exclude CVS -cf - -C /usr/src/usr.sbin/sysinstall help | \
636		tar xf - -C ${RD}/mfsfd/stand
637	@echo "Compressing doc files..."
638	@gzip -9 ${RD}/mfsfd/stand/help/*.hlp
639.if ${MACHINE_ARCH} == "alpha"
640	rm -rf ${RD}/mfsfd/stand/help/*
641.endif
642.if exists(${.CURDIR}/${MACHINE}/drivers.conf)
643	@mkdir -p ${RD}/mfsfd/stand/modules
644	@perl ${.CURDIR}/scripts/driver-copy2.pl \
645		${.CURDIR}/${MACHINE}/drivers.conf \
646		${RD}/kernels ${RD}/mfsfd/stand/modules
647.endif
648	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
649		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
650	@gzip -9vc mfsroot > mfsroot.gz
651.if ${MACHINE} == "pc98"
652	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
653		${RD} ${MNT} ${SMALLBOOTSIZE} mfsroot.gz \
654		${BOOTINODE} ${SMALLBOOTLABEL}
655	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
656	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
657.else
658	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
659		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
660	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
661	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
662.endif
663	@rm mfsroot mfsroot.gz
664	@echo "Regular and MFS boot floppies made."
665	touch release.8
666
667#
668# --==## Create a fixit floppy ##==--
669#
670release.9:
671	@echo "Making fixit floppy."
672	@rm -rf ${RD}/fixitfd
673	@mkdir ${RD}/fixitfd
674	@cd ${RD}/fixitfd && \
675		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
676		usr/share/misc
677	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
678		DIR=${RD}/fixitfd/stand ZIP=false
679	@( cd ${RD}/fixitfd/dev && \
680		cp ${RD}/trees/bin/dev/MAKEDEV MAKEDEV && \
681		chmod 755 MAKEDEV && \
682		sh MAKEDEV fixit )
683	@cp ${RD}/trees/bin/etc/spwd.db ${RD}/trees/bin/etc/group \
684		${RD}/trees/bin/etc/protocols ${RD}/fixitfd/etc
685	@cp ${RD}/trees/bin/usr/share/misc/scsi_modes \
686		${RD}/fixitfd/usr/share/misc
687	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
688	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
689	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
690	@chmod 555 ${RD}/fixitfd/stand/tar
691	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
692		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
693# Do our last minute floppies directory setup in a convenient place.
694.if !defined(NODOC)
695	@cp ${.CURDIR}/doc/${RELNOTES_LANG}/installation/${MACHINE_ARCH}/article.txt \
696		${RD}/floppies/README.TXT
697	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
698.else
699	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
700.endif
701	touch release.9
702
703#
704# --==## Setup a suitable ftp-area ##==--
705#
706ftp.1:
707	@echo "Setting up FTP distribution area"
708	@mkdir -p ${FD}
709	-@ln -s . ${FD}/${BUILDNAME}
710	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
711	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
712.if !defined(NODOC)
713	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
714	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
715	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
716	done
717	@for i in ${DIST_DOCS_ARCH_DEP}; do \
718	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
719	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
720	done
721	@cp ${.CURDIR}/doc/${RELNOTES_LANG}/readme/docbook.css ${FD}
722	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
723	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
724.endif
725	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
726.if !defined(NOPORTS)
727	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
728.endif
729	touch ftp.1
730
731#
732# --==## Setup a suitable cdrom-area ##==--
733#
734cdrom.1:
735	@echo "Setting up CDROM distribution area"
736	@mkdir -p ${CD_DISC1} ${CD_DISC2}
737	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
738	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
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} != "pc98"
765	@echo "Setting up /boot"
766	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
767	@ln -f ${RD}/image.boot/mfsroot.gz ${CD_DISC1}/boot/mfsroot.gz
768	@ln -f ${CD_DISC1}/boot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
769	@echo 'mfsroot_load="YES"' > ${CD_DISC1}/boot/loader.conf
770	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC1}/boot/loader.conf
771	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC1}/boot/loader.conf
772	@ln -f ${CD_DISC1}/boot/loader.conf ${CD_DISC2}/boot/loader.conf
773.endif
774.if ${MACHINE} == "i386"
775	@mkdir -p ${CD_DISC2}/floppies
776	@cp ${CD_DISC1}/floppies/boot.flp ${CD_DISC2}/floppies
777.endif
778.if !defined(NOPORTS)
779	@-rm -rf /usr/ports/distfiles/*
780	@mkdir -p ${CD_DISC1}/ports && \
781	  tar --exclude CVS -czf ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
782	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
783	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
784.endif
785	touch cdrom.1
786
787iso.1:
788	@if [ -r ${.CURDIR}/${MACHINE_ARCH}/mkisoimages.sh ]; then \
789		echo "Creating ISO images..."; \
790		sh ${.CURDIR}/${MACHINE_ARCH}/mkisoimages.sh ${BOOTABLE} \
791		  fbsd_miniinst ${CD}/miniinst.iso ${CD_DISC1}; \
792		sh ${.CURDIR}/${MACHINE_ARCH}/mkisoimages.sh ${BOOTABLE} \
793		  fbsd_livefs ${CD}/disc2.iso ${CD_DISC2}; \
794		if [ "x${CD_EXTRA_BITS}" != "x" ]; then \
795			sh ${.CURDIR}/${MACHINE_ARCH}/mkisoimages.sh ${BOOTABLE} \
796			  fbsd_boot ${CD}/disc1.iso ${CD_DISC1} ${CD_EXTRA_BITS}; \
797			    && false; \
798		fi \
799	else \
800		echo "Do not know how to create an ISO for ${MACHINE_ARCH}."; \
801	fi
802	touch iso.1
803
804#
805# --==## Documentation Project files such as the Handbook and FAQ ##==--
806#
807doc.1:
808	@echo "Making docs..."
809	@for i in ${DOCPORTS}; do \
810	  cd /usr/ports/$$i && make all install clean BATCH=yes JADETEX=no FORCE_PKG_REGISTER=yes; \
811	done
812	@cd /usr/doc && make all install 'FORMATS=html html-split txt' INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/bin/usr/share/doc
813	touch doc.1
814
815#
816# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
817#
818doc.2:
819	@echo "Making release documentation..."
820	@cd ${.CURDIR}/doc && make all 'FORMATS=html txt'
821	touch doc.2
822
823# Various "subroutine" and other supporting targets.
824
825# RD=
826# SD=
827# TD=
828# ARG=
829doTARBALL:
830.if !defined(SD)
831	@echo "SD undefined in doTARBALL" && exit 1
832.endif
833.if !defined(TD)
834	@echo "TD undefined in doTARBALL" && exit 1
835.endif
836.if !defined(ARG)
837	@echo "ARG undefined in doTARBALL" && exit 1
838.endif
839	@rm -rf ${RD}/dists/${TD}/${TN}*
840	@mkdir -p ${RD}/dists/${TD}
841	@( cd ${SD} && \
842		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
843		echo rolling ${TD}/$$tn tarball &&\
844		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
845		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
846		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
847		   ${RD}/dists/${TD}/$$tn.inf && \
848		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
849		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
850		fi && \
851		if [ "${SD}" != "/usr/src" ]; then \
852			mtree -c -i -p ${SD}/${ARG} \
853			  -k gname,md5digest,mode,nlink,uname,size,link,type \
854			  > ${RD}/dists/${TD}/$$tn.mtree ; \
855		else \
856			true; \
857		fi; \
858		(cd ${RD}/dists/${TD}; \
859		   rm -f CHECKSUM.MD5; \
860		   md5 * > CHECKSUM.MD5) \
861	)
862
863doRELEASE:  release.1 release.2 ${DOCREL} release.3 release.4 release.5 \
864		release.6 release.7 release.8 release.9
865	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
866	@echo "Release done"
867
868floppies:
869	@cd ${.CURDIR} && ${MAKE} boot.flp
870	@cd ${.CURDIR} && ${MAKE} fixit.flp
871	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
872
873boot.flp:
874	@rm -f release.4 release.8
875	@cd ${.CURDIR} && ${MAKE} release.4 release.8 CRUNCH_TARGETS=boot
876
877fixit.flp:
878	@rm -f release.4 release.9
879	@cd ${.CURDIR} && ${MAKE} release.4 release.9 CRUNCH_TARGETS=fixit
880
881write_mfs_in_kernel:	${.CURDIR}/write_mfs_in_kernel.c
882	${CC} ${CFLAGS} -o write_mfs_in_kernel ${.CURDIR}/write_mfs_in_kernel.c
883
884installCRUNCH:
885.if !defined(CRUNCH)
886	@echo "CRUNCH undefined in installCRUNCH" && exit 1
887.endif
888.if !defined(DIR)
889	@echo "DIR undefined in installCRUNCH" && exit 1
890.endif
891.if !defined(ZIP)
892	@echo "ZIP undefined in installCRUNCH" && exit 1
893.endif
894	@if ${ZIP} ; then \
895		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
896	else \
897		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
898	fi
899	@chmod 555 ${DIR}/${CRUNCH}_crunch
900	@if [ -f ${.CURDIR}/${MACHINE}/${CRUNCH}_crunch.conf ] ; then \
901		for i in `crunchgen -l ${.CURDIR}/${MACHINE}/${CRUNCH}_crunch.conf` ; do \
902			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
903		done \
904	else \
905		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
906			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
907		done \
908	fi
909
910#
911# --==## BOOTMFS config file ##==--
912#
913
914createBOOTMFS:
915	@cd ${.CURDIR}/../sys/${MACHINE}/conf && \
916	  sh ${.CURDIR}/${MACHINE_ARCH}/dokern.sh ${FDSIZE} < ${KERNCONF} > BOOTMFS && \
917	  [ -r ${KERNCONF}.hints ] && cp ${KERNCONF}.hints BOOTMFS.hints
918.if 0 && ${MACHINE_ARCH} == "i386"
919	@echo "options  INTRO_USERCONFIG" >> \
920	  ${.CURDIR}/../sys/${MACHINE}/conf/BOOTMFS
921.endif
922.if exists(${.CURDIR}/${MACHINE}/drivers.conf)
923	@perl ${.CURDIR}/scripts/driver-remove.pl \
924		${.CURDIR}/${MACHINE}/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 modules-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.endif
995	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
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	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
1002	@rm -f ${RD}/floppies/${FSIMAGE}.flp
1003.if defined(FDSIZE) && ${FDSIZE} == "BIG"
1004	@cp mfsroot.gz ${RD}/image.${FSIMAGE}
1005	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1006		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
1007		${BOOTINODE} ${BIGBOOTLABEL}
1008.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
1009	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1010		${RD} ${MNT} ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} \
1011		${BOOTINODE} ${SMALLBOOTLABEL}
1012.else
1013	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1014		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
1015		${BOOTINODE} ${BOOTLABEL}
1016.endif
1017	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1018
1019.include <bsd.prog.mk>
1020