Makefile revision 86626
1# $FreeBSD: head/release/Makefile 86626 2001-11-19 21:27:00Z jhb $
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=		2880
145BOOTINODE=		80000
146FIXITINODE=		4000
147MFSINODE=		8000
148SMALLBOOTLABEL=		fd1200
149BOOTLABEL=		fd1440
150FIXITLABEL=		fd1440
151MFSLABEL=		minimum2
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=		2880
169BIGBOOTSIZE=		2880
170BOOTINODE=		80000
171FIXITINODE=		4000
172MFSINODE=		8000
173BOOTLABEL=		fd1440
174FIXITLABEL=		minimum2
175MFSLABEL=		minimum2
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.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.gz             |mfsroot.gz                       |
581#               +----------------------+---------------------------------+
582#
583
584release.8:
585	rm -rf ${RD}/mfsfd
586	mkdir ${RD}/mfsfd
587	cd ${RD}/mfsfd && \
588		mkdir -p etc/defaults dev mnt stand/help
589	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
590		DIR=${RD}/mfsfd/stand ZIP=false
591	( cd ${RD}/trees/bin/dev && \
592		ls console tty bpf0 ttyd0 ttyv0 ttyv1 ttyv2 ttyv3 null zero card0 card1 card2 card3 usb usb0 uhid0 ums0 ulpt0 ugen0 kbd0 kmem mem | \
593	cpio -dump ${RD}/mfsfd/dev )
594	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
595	( cd ${RD}/mfsfd && \
596	  for dir in bin sbin ; do \
597		ln -sf /stand $$dir; \
598	  done )
599	cp /sbin/dhclient-script ${RD}/mfsfd/stand
600	cp ${.CURDIR}/../etc/defaults/pccard.conf ${RD}/mfsfd/etc/defaults/pccard.conf
601	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
602	cd ${RD}/trees/bin && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
603	( for F in netconfig protocols ; do \
604		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
605		${RD}/trees/bin/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
606	  done )
607	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
608	    ${.CURDIR}/../etc/services | \
609	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
610	    > ${RD}/mfsfd/stand/etc/services
611	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
612	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
613	gzip -9c ${.CURDIR}/../COPYRIGHT > ${RD}/mfsfd/stand/help/COPYRIGHT.hlp.gz
614.if !defined(NODOC)
615	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
616	  gzip -9c ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.txt > ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT.gz; \
617	done
618	@for i in ${DIST_DOCS_ARCH_DEP}; do \
619	  gzip -9c ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.txt > ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT.gz; \
620	done
621	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT.gz ${RD}/mfsfd/stand/help/INSTALL.TXT.gz
622.endif
623	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
624	@mkdir -p ${RD}/mfsfd/boot
625	@cp /boot/boot* ${RD}/mfsfd/boot
626	@cp /boot/loader.help ${RD}/mfsfd/boot
627	@cd ${.CURDIR} && ${MAKE} createBOOTMFS 
628.if exists(${.CURDIR}/${MACHINE_ARCH}/drivers.conf)
629	@cd ${.CURDIR} && ${MAKE} doMODULES KERNEL=BOOTMFS KERNEL_KO=BOOTMFS KODIR=""
630.endif
631	@echo "Making the regular boot floppy."
632	@tar --exclude CVS -cf - -C /usr/src/usr.sbin/sysinstall help | \
633		tar xf - -C ${RD}/mfsfd/stand
634	@echo "Compressing doc files..."
635	@gzip -9 ${RD}/mfsfd/stand/help/*.hlp
636.if ${MACHINE_ARCH} == "alpha"
637	rm -rf ${RD}/mfsfd/stand/help/*
638.endif
639.if exists(${.CURDIR}/${MACHINE_ARCH}/drivers.conf)
640	@mkdir -p ${RD}/mfsfd/stand/modules
641	@perl ${.CURDIR}/scripts/driver-copy2.pl \
642		${.CURDIR}/${MACHINE_ARCH}/drivers.conf \
643		${RD}/kernels ${RD}/mfsfd/stand/modules
644.endif
645	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
646		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
647	@gzip -9vc mfsroot > mfsroot.gz
648.if ${MACHINE} == "pc98"
649	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
650		${RD} ${MNT} ${SMALLBOOTSIZE} mfsroot.gz \
651		${BOOTINODE} ${SMALLBOOTLABEL}
652	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
653	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
654.else
655	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
656		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
657	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
658	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
659.endif
660	@rm mfsroot mfsroot.gz
661	@echo "Regular and MFS boot floppies made."
662	touch release.8
663
664#
665# --==## Create a fixit floppy ##==--
666#
667release.9:
668	@echo "Making fixit floppy."
669	@rm -rf ${RD}/fixitfd
670	@mkdir ${RD}/fixitfd
671	@cd ${RD}/fixitfd && \
672		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
673		usr/share/misc
674	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
675		DIR=${RD}/fixitfd/stand ZIP=false
676	@( cd ${RD}/fixitfd/dev && \
677		cp ${RD}/trees/bin/dev/MAKEDEV MAKEDEV && \
678		chmod 755 MAKEDEV && \
679		sh MAKEDEV fixit )
680	@cp ${RD}/trees/bin/etc/spwd.db ${RD}/trees/bin/etc/group \
681		${RD}/trees/bin/etc/protocols ${RD}/fixitfd/etc
682	@cp ${RD}/trees/bin/usr/share/misc/scsi_modes \
683		${RD}/fixitfd/usr/share/misc
684	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
685	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
686	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
687	@chmod 555 ${RD}/fixitfd/stand/tar
688	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
689		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
690# Do our last minute floppies directory setup in a convenient place.
691.if !defined(NODOC)
692	@cp ${.CURDIR}/doc/${RELNOTES_LANG}/installation/${MACHINE_ARCH}/article.txt \
693		${RD}/floppies/README.TXT
694	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
695.else
696	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
697.endif
698	touch release.9
699
700#
701# --==## Setup a suitable ftp-area ##==--
702#
703ftp.1:
704	@echo "Setting up FTP distribution area"
705	@mkdir -p ${FD}
706	-@ln -s . ${FD}/${BUILDNAME}
707	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
708	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
709.if !defined(NODOC)
710	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
711	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
712	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
713	done
714	@for i in ${DIST_DOCS_ARCH_DEP}; do \
715	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
716	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
717	done
718	@cp ${.CURDIR}/doc/${RELNOTES_LANG}/readme/docbook.css ${FD}
719	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
720	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
721.endif
722	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
723.if !defined(NOPORTS)
724	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
725.endif
726	touch ftp.1
727
728#
729# --==## Setup a suitable cdrom-area ##==--
730#
731cdrom.1:
732	@echo "Setting up CDROM distribution area"
733	@mkdir -p ${CD_DISC1} ${CD_DISC2}
734	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
735	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
736	@for i in ${DISTRIBUTIONS} ; \
737	do \
738		if [ -d ${RD}/trees/$${i} ] ; then \
739			chflags -R noschg ${RD}/trees/$${i} || true ; \
740			( cd ${RD}/trees/$${i} && \
741			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
742		fi \
743	done
744	@rm -f ${CD_DISC2}/.profile
745	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
746	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
747	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
748.if !defined(NODOC)
749	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
750	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
751	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
752	done
753	@for i in ${DIST_DOCS_ARCH_DEP}; do \
754	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
755	  cp ${.CURDIR}/doc/${RELNOTES_LANG}/$$i/${MACHINE_ARCH}/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
756	done
757	@cp ${.CURDIR}/doc/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
758	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
759	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
760.endif
761.if ${MACHINE_ARCH} == "alpha"
762	@echo "Setting up Alpha CD disc1 for booting"
763	@cp -Rp ${RD}/image.boot/boot ${CD_DISC1}
764	@ln -f ${RD}/image.boot/kernel.gz ${CD_DISC1}/kernel.gz
765	@ln -f ${RD}/image.boot/mfsroot.gz ${CD_DISC1}/mfsroot.gz
766	@ln -f ${CD_DISC2}/boot/cdboot ${CD_DISC1}/boot
767	@ln -f ${CD_DISC1}/boot/loader.rc ${CD_DISC2}/boot
768	@ln -f ${CD_DISC1}/kernel.gz ${CD_DISC2}/kernel.gz
769	@ln -f ${CD_DISC1}/mfsroot.gz ${CD_DISC2}/mfsroot.gz
770.elif ${MACHINE} == "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 exists(${.CURDIR}/${MACHINE_ARCH}/drivers.conf)
919	@perl ${.CURDIR}/scripts/driver-remove.pl \
920		${.CURDIR}/${MACHINE_ARCH}/drivers.conf \
921		${.CURDIR}/../sys/${MACHINE}/conf/BOOTMFS
922.endif
923
924#
925# --==## Compile a kernel by name ${KERNEL} ##==--
926#
927# We don't erase the sys/${MACHINE}/compile/${KERNEL} directory, since somebody
928# may want to reuse it (release.8 presently)
929#
930doKERNEL:
931	@rm -f ${RD}/kernels/${KERNEL}
932	@cd ${.CURDIR}/../sys/${MACHINE}/conf && config ${KERNEL}
933	@cd ${.CURDIR}/../sys/${MACHINE}/compile/${KERNEL} && \
934			make kernel-depend && \
935			make ${KERNEL_FLAGS} ${KERNEL_KO} && \
936			make kernel-reinstall DESTDIR=${RD}/kernels && \
937			[ -r ${.CURDIR}/../sys/${MACHINE}/conf/${KERNEL}.hints ] && \
938			cp ${.CURDIR}/../sys/${MACHINE}/conf/${KERNEL}.hints ${RD}/kernels
939
940doMODULES:
941	@rm -f ${RD}/kernels/*.ko
942	@cd ${.CURDIR}/../sys/${MACHINE}/conf && config ${KERNEL}
943	@cd ${.CURDIR}/../sys/${MACHINE}/compile/${KERNEL} && \
944			make kernel-depend && \
945			make ${KERNEL_FLAGS} modules && \
946			make modules-reinstall DESTDIR=${RD}/kernels && \
947
948doSTDKERNEL:
949	@rm -f ${RD}/kernels/${KERNEL}
950	@cd ${.CURDIR}/../sys/${MACHINE}/conf && config ${KERNEL}
951	@cd ${.CURDIR}/../sys/${MACHINE}/compile/${KERNEL} && \
952			make depend && \
953			make ${KERNEL_FLAGS} KERNEL=${KERNEL} && \
954			make KERNEL=${KERNEL} DESTDIR=${RD}/kernels install && \
955			[ -r ${.CURDIR}/../sys/${MACHINE}/conf/${KERNEL}.hints ] && \
956			cp ${.CURDIR}/../sys/${MACHINE}/conf/${KERNEL}.hints ${RD}/kernels
957	@-cd ${.CURDIR}/../sys/${MACHINE}/compile/${KERNEL} && \
958			make KERNEL=${KERNEL} DESTDIR=${RD}/kernels \
959				kernel-reinstall.debug
960
961#
962# --==## Put a filesystem into a BOOTMFS kernel ##==--
963#
964doMFSKERN:
965	@echo "Running doMFSKERN for ${FSIMAGE}"
966	@rm -f ${RD}/kernels/BOOTMFS.${FSIMAGE}
967	@cd ${.CURDIR} && ${MAKE} createBOOTMFS 
968	@cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=BOOTMFS KERNEL_KO=BOOTMFS KODIR=""
969	@rm -rf ${RD}/image.${FSIMAGE}
970	@mkdir  ${RD}/image.${FSIMAGE}
971	@cd ${RD}/kernels && \
972	  (chflags noschg BOOTMFS || true) && \
973	  strip BOOTMFS && \
974	  cp BOOTMFS BOOTMFS.${FSIMAGE} && \
975	  [ -r BOOTMFS.hints ] && mv BOOTMFS.hints BOOTMFS.${FSIMAGE}.hints
976	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
977	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
978	@mkdir -p ${RD}/image.${FSIMAGE}/boot
979	@cp /boot/loader ${RD}/image.${FSIMAGE}/boot
980	@[ -r ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints ] && \
981	  sed -e '/^hint/s/^/set /' -e '/^#/d' \
982	    ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints > \
983	    ${RD}/image.${FSIMAGE}/boot/device.hints && \
984	  echo "include /boot/device.hints" > ${RD}/image.${FSIMAGE}/boot/loader.rc
985	@echo "load /kernel" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
986.if !defined(FDSIZE) || ${FDSIZE} != "BIG"
987	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
988	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
989	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
990.endif
991	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
992	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
993	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
994.if ${MACHINE_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
995	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
996.endif
997	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
998	@rm -f ${RD}/floppies/${FSIMAGE}.flp
999.if defined(FDSIZE) && ${FDSIZE} == "BIG"
1000	@cp mfsroot.gz ${RD}/image.${FSIMAGE}
1001	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1002		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
1003		${BOOTINODE} ${BIGBOOTLABEL}
1004.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
1005	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1006		${RD} ${MNT} ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} \
1007		${BOOTINODE} ${SMALLBOOTLABEL}
1008.else
1009	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
1010		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
1011		${BOOTINODE} ${BOOTLABEL}
1012.endif
1013	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1014
1015.include <bsd.prog.mk>
1016