Makefile revision 133202
1# $FreeBSD: head/release/Makefile 133202 2004-08-06 10:04:06Z ru $
2#
3# make release [BUILDNAME=somename] CHROOTDIR=/some/dir 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 present in the kernel
13# (either by being compiled in or available as a kld(4) module),
14# otherwise the target 'release.8' and possibly others will fail.
15#
16# Note: If you add options to this file, please keep release(7) updated!
17#
18# Set these, release builder!
19#
20# Fixed version:
21#BUILDNAME=5.2-RELEASE
22#
23# Automatic SNAP versioning:
24DATE != date +%Y%m%d
25BASE = 5.2
26BUILDNAME?=${BASE}-${DATE}-SNAP
27#
28#CHROOTDIR=/junk/release
29# If this is a -stable snapshot, then set
30#RELEASETAG=RELENG_4
31#
32# To test a release with a source tree containing patches and
33# other work. This tree will get copied instead of getting the
34# src/ tree from a CVS checkout. For "rerelease", this will NOT
35# be copied; cvs update will be used instead.
36#EXTSRCDIR=/usr/src
37#
38# To add other options to the CVS subcommands (co,up), set
39#CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
40#
41# To add other options to the CVS command, set
42#CVSARGS="-lfq"
43#
44# To prefix the cvs command
45#CVSPREFIX="/usr/bin/time"
46#
47# Where the CVS repository is
48#CVSROOT="/home/ncvs"
49#
50# Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
51# are building an official release.  Otherwise, we are building for
52# a branch.
53.if defined(RELEASETAG)
54ISRELEASE!=	expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
55.if ${ISRELEASE} != 0
56# Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
57AUXRELEASETAG!=	echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
58DOCRELEASETAG?=		${AUXRELEASETAG}
59PORTSRELEASETAG?=	${AUXRELEASETAG}
60.endif
61.endif
62
63# If you want to pass flags to the world build such as -j X, use
64# WORLD_FLAGS.  Similarly, you can specify make flags for kernel
65# builds via KERNEL_FLAGS.
66# Similarly, you can specify make flags for make readmes via PORTREADMES_FLAGS.
67#WORLD_FLAGS=-j4
68#KERNEL_FLAGS=-j4
69#PORTREADMES_FLAGS=-j4
70
71TARGET_ARCH?=	${MACHINE_ARCH}
72.if ${TARGET_ARCH} == ${MACHINE_ARCH}
73TARGET?=	${MACHINE}
74.else
75TARGET?=	${TARGET_ARCH}
76.endif
77CROSSENV=	TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
78CROSSMAKE=	${MAKE} ${CROSSENV}
79NATIVEMAKE=	${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
80
81# If you are using a local CVS repository with components stored in 
82# non-standard modules, override these on the make commandline or
83# in the environment.
84RELEASESRCMODULE?=	src
85RELEASEDOCMODULE?=	doc
86RELEASEPORTSMODULE?=	ports
87
88# Uncomment this to disable the doc.1 target.  Docs normally require
89# the ports tree, so NOPORTS can be set together with NODOC in order
90# to have neither ports or docs.  If only NOPORTS is set to YES, but
91# docs are still desired, the DOMINIMALDOCPORTS logic below will only
92# install the ports that are minimally required for the docs.  This is
93# intended as a compromise, less disk space is required than for using
94# the entire ports collection (and much less time due to the huge number
95# of directories it would create), but still quite a bit as well as some
96# CPU cycles (some of the programs are C++, and things like ghostscript
97# belong to the required ports nevertheless).
98#
99# Setting this also disables building of release note documentation
100# (RELNOTESng).
101#NODOC=  YES
102#NOPORTS=  YES
103
104# Modify this definition if you want the release notes 
105# and other release documentation in a language other than English.
106RELNOTES_LANG?=	en_US.ISO8859-1
107
108# As an alternative to installing the entire ports collection (which
109# can take a huge amount of time, in particular on slower disks),
110# setting ${MINIMALDOCPORTS} allows to install and build just those
111# ports that are really required for getting the docs up & running.
112.if defined(NOPORTS) && !defined(NODOC)
113DOMINIMALDOCPORTS=	YES
114.include "Makefile.inc.docports"
115RELEASEPORTSMODULE=	${MINIMALDOCPORTS}
116.endif
117
118# Make changing names of disc1/disc2 CD's possible.
119DISC1_LABEL?=	fbsd_miniinst
120DISC1_NAME?=	miniinst
121DISC2_LABEL?=	fbsd_livefs
122DISC2_NAME?=	disc2
123
124# Helper variable
125.if defined(NOPORTS)
126.if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
127NOPORTSATALL=	YES
128.endif
129.endif
130
131# By default, documentation (Handbook, FAQ, etc.) is built for all
132# the languages.  To speed up building, set the DOC_LANG to just
133# the languages you need.  (The language for the release notes is
134# controlled by the RELNOTES_LANG variable above.)
135#DOC_LANG=	en_US.ISO8859-1
136DOCPORTS=	textproc/docproj
137# Set this to wherever the distfiles required by release procedures.
138.if defined(DOCDISTFILES)
139# Respect DOCDISTFILES which is used before.
140RELEASEDISTFILES?=	${DOCDISTFILES}
141.else
142RELEASEDISTFILES?=	${.CURDIR}/../../ports/distfiles
143.endif
144# Set this to 1 if you want -P to be used for automatic keyboard detection
145# on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
146AUTO_KEYBOARD_DETECT?= 0
147
148.if !defined(NODOC)
149DIST_DOCS_ARCH_INDEP=	readme errata early-adopter
150DIST_DOCS_ARCH_DEP=	installation relnotes hardware
151.endif
152
153# Things which without too much trouble can be considered variables
154# BASE_DISTS are special in that they get full /etc installation sets.
155#
156.if ${TARGET_ARCH} == "i386"
157COMPAT_DISTS?=	compat1x compat20 compat21 compat22 compat3x compat4x
158.elif ${TARGET_ARCH} == "alpha"
159COMPAT_DISTS?=	compat4x
160.endif
161OTHER_DISTS?=	catpages manpages games proflibs dict info doc
162BASE_DISTS?=	base
163DISTRIBUTIONS?=	${BASE_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS}
164
165# mountpoint for filesystems.
166MNT=			/mnt
167
168# Various floppy image parameters.
169#
170
171.if ${TARGET_ARCH} == "i386"
172.if ${TARGET} == "pc98"
173SMALLFLOPPYSIZE=	1200
174SMALLFLOPPYSPLITSIZE=	1152
175SMALLFLOPPYLABEL=	fd1200
176SPLIT_MFSROOT=
177.endif
178FLOPPYSIZE=		1440
179FLOPPYSPLITSIZE=	1392
180FLOPPYINODE=		40000
181FLOPPYLABEL=		fd1440
182BOOTINODE=		80000
183MFSSIZE=		4320
184MFSINODE=		8000
185MFSLABEL=		minimum3
186.elif ${TARGET_ARCH} == "alpha"
187FLOPPYSIZE=		1440
188FLOPPYSPLITSIZE=	1392
189FLOPPYINODE=		40000
190FLOPPYLABEL=		fd1440
191BOOTINODE=		80000
192MFSSIZE=		4320
193MFSINODE=		8000
194MFSLABEL=		auto
195SPLIT_MFSROOT=
196.elif ${TARGET_ARCH} == "sparc64"
197DISKLABEL=		sunlabel
198MFSSIZE=		4096
199MFSINODE=		8192
200MFSLABEL=		auto
201MINIROOT=
202NO_FLOPPIES=
203.elif ${TARGET_ARCH} == "ia64"
204MFSSIZE=		8192
205MFSINODE=		8192
206MFSLABEL=		auto
207NO_FLOPPIES=
208.elif ${TARGET_ARCH} == "amd64"
209MFSSIZE=		4096
210MFSINODE=		8192
211MFSLABEL=		auto
212NO_FLOPPIES=
213.endif
214
215.if exists(/sbin/bsdlabel)
216DISKLABEL?=		bsdlabel
217.else
218DISKLABEL?=		disklabel
219.endif
220
221ZIPNSPLIT=		gzip --no-name -9 -c | split -b 1392k -
222
223# Things which may get you into trouble if you change them
224MTREEFILES=		${.CURDIR}/../etc/mtree
225_R?=			/R
226RD=			${_R}/stage
227RND=			${RD}/release.doc
228FD=			${_R}/ftp
229CD=			${_R}/cdrom
230.if ${TARGET} != "pc98"
231CD_BOOT=		${CD}/bootonly
232.endif
233CD_DISC1=		${CD}/disc1
234CD_DISC2=		${CD}/disc2
235_MK?=			${CHROOTDIR}/mk
236
237# Where the bootstrap ports (see DOCPORTS) get installed.
238LOCALDIR=		/usr/local/bin
239
240.if ${TARGET} != ${MACHINE} && ${DISKLABEL} == "bsdlabel"
241DOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ${TARGET}
242.else
243DOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ""
244.endif
245
246CRUNCH_TARGETS=	boot
247.if ${TARGET_ARCH} == "i386"
248CRUNCH_TARGETS+=fixit
249.if ${TARGET} == "pc98"
250CRUNCH_TARGETS+=fixit-small
251.endif
252.endif
253
254.if !defined(NO_FLOPPIES)
255EXTRAS= floppies.1
256.if ${TARGET_ARCH} == "i386"
257EXTRAS+= floppies.2
258.endif
259EXTRAS+= floppies.3
260.endif
261EXTRAS+= ftp.1
262.if !defined(NOCDROM)
263EXTRAS+= cdrom.1
264.if defined(MAKE_ISOS)
265EXTRAS+= iso.1
266.endif
267.if ${TARGET} == "pc98"
268BOOTABLE=
269.else
270BOOTABLE="-b"
271.endif
272.endif
273
274.if !defined(NODOC)
275DOCREL= doc.1 doc.2
276.endif
277
278.if !make(release) && !make(rerelease)
279BINMAKE!=	cd ${.CURDIR}/..; ${MAKE} -V BINMAKE
280WMAKEENV!=	cd ${.CURDIR}/..; \
281		${BINMAKE} ${CROSSENV} -f Makefile.inc1 -V WMAKEENV
282WMAKE=		${WMAKEENV} ${BINMAKE}
283.endif
284
285CVS_SRCARGS=	-P
286.if defined(RELEASETAG)
287CVS_SRCARGS+=	-r ${RELEASETAG}
288.endif
289
290CVS_DOCARGS=	-P
291.if defined(DOCRELEASETAG)
292CVS_DOCARGS+=	-r ${DOCRELEASETAG}
293.endif
294
295CVS_PORTSARGS=	-P
296.if defined(PORTSRELEASETAG)
297CVS_PORTSARGS+=	-r ${PORTSRELEASETAG}
298.endif
299
300WORLDDIR?=	${.CURDIR}/..
301
302release rerelease:
303.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
304	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
305.endif
306.if defined(NOPORTSATALL) && !defined(NODOC)
307	@echo "Ports are required for building the docs.  Either set NODOC or"
308	@echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
309	@exit 1
310.endif
311.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
312.for p in ${LOCAL_PATCHES}
313.if !exists(${p})
314	@echo "The patch file ${p} does not exist!"
315	@exit 1
316.endif
317.endfor
318.endif
319.if defined(LOCAL_SCRIPT) && !exists(${LOCAL_SCRIPT})
320	@echo "The local script ${LOCAL_SCRIPT} does not exist!"
321	@exit 1
322.endif
323.if make(release)
324.if exists(${CHROOTDIR})
325# The first command will fail on a handful of files that have their schg
326# flags set.  But it greatly speeds up the next two commands.
327	# NB: clear any vestigal devfs mount, just in case
328	-umount ${CHROOTDIR}/dev > /dev/null 2>&1
329	-rm -rf ${CHROOTDIR} 2>/dev/null
330	-chflags -R noschg ${CHROOTDIR}/.
331	-rm -rf ${CHROOTDIR}
332.endif
333	mkdir -p ${CHROOTDIR}
334	@echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
335	cd ${WORLDDIR} && ${NATIVEMAKE} -DNOGAMES -DNOHTML -DNOINFO -DNOMAN \
336	    -DNOPROFILE installworld DESTDIR=${CHROOTDIR}
337	cd ${WORLDDIR}/etc && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
338	if [ -f /etc/resolv.conf ]; then \
339		cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
340	fi
341.if defined(EXTLOCALDIR)
342	rm -rf ${CHROOTDIR}/usr/local
343	cd ${CHROOTDIR}/usr && cp -R -H ${EXTLOCALDIR} local
344.endif
345	rm -rf ${CHROOTDIR}/usr/src
346.if defined(EXTSRCDIR)
347	cd ${CHROOTDIR}/usr && \
348	    cp -R -H ${EXTSRCDIR} src
349.else
350	cd ${CHROOTDIR}/usr && \
351	    ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
352	    co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
353.endif
354.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
355.for p in ${LOCAL_PATCHES}
356	patch -d ${CHROOTDIR}/usr/${RELEASESRCMODULE} ${PATCH_FLAGS} < ${p}
357.endfor
358.endif
359.if defined(LOCAL_SCRIPT)
360	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} \
361	    RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
362.endif
363	rm -rf ${CHROOTDIR}/usr/ports
364.if !defined(NOPORTSATALL)
365	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
366	    co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
367.endif
368.if !defined(NODOC)
369	rm -rf ${CHROOTDIR}/usr/doc
370.if defined(EXTDOCDIR)
371	cd ${CHROOTDIR}/usr && cp -R -H ${EXTDOCDIR} doc
372.else
373	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
374	    co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
375.endif
376	if [ -d ${RELEASEDISTFILES}/ ]; then \
377		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
378	else \
379		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
380	fi
381.if !defined(NO_PREFETCHDISTFILES)
382	@cd ${.CURDIR} && ${MAKE} fetch-distfiles
383.endif
384.endif
385.endif
386.if make(rerelease)
387.if !defined(RELEASENOUPDATE)
388.if !defined(RELEASETAG)
389	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
390	    update ${CVSCMDARGS} -P -d -A
391.else
392	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
393	    update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
394.endif
395	rm -f ${CHROOTDIR}/tmp/.world_done 
396.if !defined(NOPORTS)
397	cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
398	    update ${CVSCMDARGS} -P -d
399.endif
400.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
401	for i in ${MINIMALDOCPORTS}; do \
402	    ( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
403		update ${CVSCMDARGS} -P -d ) ; \
404	done
405.endif
406.if !defined(NODOC)
407	cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
408	    update ${CVSCMDARGS} -P -d
409.endif
410.endif
411.endif
412	# Add version information to those things that need it.
413	if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
414		cd ${CHROOTDIR}/usr/src/sys/conf && \
415		mv newvers.sh foo && \
416		sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && \
417		rm foo; \
418	fi
419	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
420	echo "#!/bin/sh"			> ${_MK}
421	echo "set -ex"				>> ${_MK}
422	echo "trap 'umount /dev || true' 0"	>> ${_MK}
423	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${_MK}
424.for var in \
425	AUTO_KEYBOARD_DETECT \
426	BOOT_CONFIG \
427	BUILDNAME \
428	CD_EXTRA_BITS \
429	DISC1_LABEL \
430	DISC1_NAME \
431	DISC2_LABEL \
432	DISC2_NAME \
433	DISTRIBUTIONS \
434	DOC_LANG \
435	DOMINIMALDOCPORTS \
436	EXTRA_SRC \
437	FTP_PASSIVE_MODE \
438	FTP_PROXY \
439	HTTP_PROXY \
440	KERNELS \
441	KERNEL_FLAGS \
442	MAKE_ISOS \
443	NOCDROM \
444	NODOC \
445	NOPORTS \
446	NOSHARED \
447	NOSRC \
448	NO_CPU_CFLAGS \
449	NO_CPU_COPTFLAGS \
450	NO_FLOPPIES \
451	NO_SENDMAIL \
452	RELEASETAG \
453	RELNOTES_LANG \
454	TARGET \
455	TARGET_ARCH \
456	WORLD_FLAGS
457.if defined(${var})
458	echo "export ${var}=\"${${var}}\""	>> ${_MK}
459.endif
460.endfor
461	# Don't remove this, or the build will fall over!
462	echo "export RELEASEDIR=${_R}"		>> ${_MK}
463	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${_MK}
464	echo "export MANBUILDCAT=YES"		>> ${_MK}
465	# NB: these may fail if the host is running w/o devfs
466	echo "umount /dev >/dev/null 2>&1 || true" >> ${_MK}
467	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true"	>> ${_MK}
468	echo "if [ -x /etc/rc.d/ldconfig ]; then" >> ${_MK}
469	echo "	/etc/rc.d/ldconfig start"	>> ${_MK}
470	echo "else"				>> ${_MK}
471	echo "	ldconfig /lib /usr/lib /usr/local/lib || true" >> ${_MK}
472	echo "fi"				>> ${_MK}
473	echo "if [ ! -f /tmp/.world_done ]; then" >> ${_MK}
474	echo "	cd /usr/src"			>> ${_MK}
475	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNOCLEAN buildworld && \\" >> ${_MK}
476	echo "	touch /tmp/.world_done || exit 1" >> ${_MK}
477	echo "fi"				>> ${_MK}
478	echo "if [ ! -f /tmp/.skip_ports ]; then" >> ${_MK}
479	echo "	echo \">>> make readmes started on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
480	echo "	cd /usr/ports"			>> ${_MK}
481	echo "	make ${PORTREADMES_FLAGS} readmes" >> ${_MK}
482	echo "	touch /tmp/.skip_ports"		>> ${_MK}
483	echo "	echo \">>> make readmes finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
484	echo "fi"				>> ${_MK}
485	echo "cd /usr/src/release"		>> ${_MK}
486	echo "make obj"				>> ${_MK}
487	echo "make \$${_RELTARGET}"		>> ${_MK}
488	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
489	chmod 755 ${_MK}
490.if defined(NOPORTS) || defined(NOPORTREADMES)
491	touch ${CHROOTDIR}/tmp/.skip_ports
492.endif
493	# Ensure md.ko is loaded if md(4) is not statically compiled into 
494	# the kernel
495	-mdconfig 2>/dev/null
496	env -i /usr/sbin/chroot `dirname ${_MK}` /`basename ${_MK}`
497
498clean:
499	rm -rf ${CRUNCH_TARGETS:S/$/_crunch/} release.[0-8] ${EXTRAS}
500
501fetch-distfiles:
502	@for i in ${DOCPORTS}; do \
503		cd ${CHROOTDIR}/usr/ports/$$i && \
504			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
505			WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
506			checksum-recursive ; \
507	done
508
509# Clean out ${_R} and make the directory structure.
510release.1:
511	mkdir -p ${_R}
512	-rm -rf ${_R}/* 2> /dev/null
513	-chflags -R noschg ${_R}/.
514	rm -rf ${_R}/*
515	mkdir ${RD}
516.if !defined(NO_FLOPPIES)
517	mkdir ${RD}/floppies
518.endif
519	mkdir ${RD}/trees
520	mkdir ${RD}/kernels
521	for i in ${DISTRIBUTIONS}; do \
522		mkdir ${RD}/trees/$$i && \
523		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
524		    -p ${RD}/trees/$$i > /dev/null && \
525		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
526		    -p ${RD}/trees/$$i/usr > /dev/null && \
527		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
528		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
529		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
530		    -p ${RD}/trees/$$i/var > /dev/null ; \
531	done
532	touch ${.TARGET}
533
534# Install the system into the various distributions.
535release.2:
536	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
537	cd ${.CURDIR}/.. && ${CROSSMAKE} distributeworld DISTDIR=${RD}/trees
538	touch ${.TARGET}
539
540# Make and install the generic kernel(s).
541release.3:
542.for kernel in ${KERNELS}
543	cd ${.CURDIR}/..; \
544	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
545	    KERNCONF=${kernel} INSTKERNNAME=${kernel} kernel \
546	    DESTDIR=${RD}/trees/base
547.endfor
548	# Install a standard boot kernel+modules.
549	cd ${.CURDIR}/..; \
550	${CROSSMAKE} ${KERNEL_FLAGS} \
551	    kernel \
552	    DESTDIR=${RD}/trees/base; \
553	cd ${.CURDIR}/..; \
554	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
555	    reinstallkernel -DINSTALL_DEBUG \
556	    DESTDIR=${RD}/trees/base
557	touch ${.TARGET}
558
559# Make and install the three crunched binaries which live on the floppies.
560# You are not supposed to like this :-)
561release.4:
562	rm -rf ${RD}/crunch
563	mkdir -p ${RD}/crunch
564.for j in ${CRUNCH_TARGETS}
565.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
566	rm -rf ${j}_crunch
567	mkdir ${j}_crunch
568	cd ${j}_crunch; ${WMAKEENV} crunchgen -o \
569	    ${.CURDIR}/${TARGET}/${j}_crunch.conf
570	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
571	cd ${.CURDIR}/..; ${BINMAKE} -f Makefile.inc1 _build-tools
572	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk \
573	    CFLAGS="-Os -pipe" -DNO_CPU_CFLAGS all
574	${WMAKEENV} strip -R .comment ${j}_crunch/${j}_crunch
575	mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
576.endif
577.endfor
578	touch ${.TARGET}
579
580#
581# --==## Fix up the distributions. ##==--
582#
583release.5:
584	# Create any "synthetic dists" now.
585	@for i in ${DISTRIBUTIONS}; do \
586		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
587			echo -n "Running $$i dist creation script... "; \
588			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
589			echo "Done."; \
590		fi \
591	done \
592
593	# Remove all the directories we don't need.
594	-cd ${RD}/trees && \
595		find ${OTHER_DISTS} ${COMPAT_DISTS} -depth -type d -print | xargs rmdir
596	touch ${.TARGET}
597
598#
599# --==## Package up the tarballs from assembled trees ##==--
600#
601release.6:
602	rm -rf ${RD}/dists
603	mkdir -p ${RD}/dists
604	@for i in ${DISTRIBUTIONS} ; \
605	do \
606		if [ -d ${RD}/trees/$${i} ] ; then \
607			cd ${.CURDIR} && $(MAKE) doTARBALL \
608				SD=${RD}/trees/$${i} \
609				TN=$$i TD=$$i ARG="." && \
610			echo "$${i} distribution is finished."; \
611		fi ; \
612	done
613.if !defined(NOPORTS)
614	# XXX: Inline stripped version of doTARBALL
615	@rm -rf ${RD}/dists/ports/ports*
616	@mkdir -p ${RD}/dists/ports
617	@echo rolling ports/ports tarball
618	@tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
619	  ${RD}/dists/ports/ports.tgz -C /usr ports
620	@cp ${.CURDIR}/scripts/ports-install.sh ${RD}/dists/ports/install.sh
621	@(cd ${RD}/dists/ports; \
622	  rm -f CHECKSUM.MD5; \
623	  md5 * > CHECKSUM.MD5)
624	@echo "ports distribution is finished."
625.endif
626	touch ${.TARGET}
627
628
629#
630# --==## Make source dists ##==--
631#
632release.7:
633.if !defined(NOSRC)
634	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
635		TD=src TN=sbase ARG="[A-Z]*"
636	@for i in `cd /usr/src && echo [a-z]*` ; do \
637		if [ -d /usr/src/$$i ] ; then \
638			cd ${.CURDIR} && $(MAKE) doTARBALL \
639				TN=`echo s$$i | tr -d '.' | \
640				    sed -e 's/usr/u/' \
641					-e 's/kerberos5/krb5/'` \
642				SD=/usr/src TD=src ARG="$$i" ; \
643		fi ; \
644	done
645.if defined(EXTRA_SRC)
646	@set ${EXTRA_SRC} && \
647	while [ $$# -ge 2 ] ; do \
648		if [ -d /usr/src/$$1 ] ; then \
649			cd ${.CURDIR} && $(MAKE) doTARBALL \
650				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
651		fi && shift && shift ; \
652	done
653.endif
654	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
655	@echo "src distribution is finished."
656.endif
657	touch ${.TARGET}
658
659# Build the memory root filesystem.
660release.8:
661	cp ${RD}/trees/base/etc/disktab /etc
662	rm -rf ${RD}/mfsfd
663	mkdir ${RD}/mfsfd
664	cd ${RD}/mfsfd && \
665		mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help
666	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
667		DIR=${RD}/mfsfd/stand ZIP=false
668	( cd ${RD}/mfsfd && \
669	  for dir in bin sbin ; do \
670		ln -sf /stand $$dir; \
671	  done )
672	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
673.if ${TARGET} == "pc98"
674	cp ${.CURDIR}/../etc/defaults/pccard.conf \
675	    ${RD}/mfsfd/etc/defaults/pccard.conf
676.endif
677	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
678	( for F in defaults/rc.conf netconfig protocols ; do \
679		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
680		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
681	  done )
682	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
683	    ${RD}/trees/base/etc/services | \
684	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
685	    > ${RD}/mfsfd/stand/etc/services
686	grep 'operator' ${RD}/trees/base/etc/group \
687	    > ${RD}/mfsfd/stand/etc/group
688	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
689	ln ${RD}/mfsfd/stand/etc/group ${RD}/mfsfd/etc/group
690	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
691	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
692.if !defined(NODOC)
693	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
694	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
695	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
696	done
697	@for i in ${DIST_DOCS_ARCH_DEP}; do \
698	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
699	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
700	done
701	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT \
702	    ${RD}/mfsfd/stand/help/INSTALL.TXT
703	@mv ${RD}/mfsfd/stand/help/EARLY-ADOPTER.TXT \
704	    ${RD}/mfsfd/stand/help/EARLY.TXT
705.endif
706	-test -f ${.CURDIR}/install.cfg \
707	    && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
708	@mkdir -p ${RD}/mfsfd/boot
709.if ${TARGET_ARCH} != "ia64"
710	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
711.endif
712.if ${TARGET} == "i386" || ${TARGET_ARCH} == "amd64"
713	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
714.endif
715	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
716		tar xf - -C ${RD}/mfsfd/stand
717	@mkdir -p ${RD}/mfsroot
718	sh -e ${DOFS_SH} ${RD}/mfsroot/mfsroot ${RD} ${MNT} \
719	    ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
720	@gzip -9fnv ${RD}/mfsroot/mfsroot
721	touch ${.TARGET}
722
723KERNFLOPPYSET=		${RD}/floppyset/kern/kernel.gz
724.if defined(SMALLFLOPPYSIZE)
725SMALLKERNFLOPPYSET=	${RD}/floppyset/kern-small/kernel.gz
726.endif
727.if defined(SPLIT_MFSROOT)
728MFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot/mfsroot.gz
729.if defined(SMALLFLOPPYSIZE)
730SMALLMFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot-small/mfsroot.gz
731.endif
732.endif
733
734# Build boot and install floppies.
735floppies.1:
736	@gzip -9nc ${RD}/trees/base/boot/kernel/kernel > ${RD}/kernels/kernel.gz
737	@echo "Making the kernel boot floppies..."
738	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern \
739	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz
740.if defined(SMALLFLOPPYSIZE)
741	@echo "Making the small kernel boot floppies..."
742	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern-small \
743	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz \
744	    FDSIZE="SMALL"
745.endif
746.if defined(SPLIT_MFSROOT)
747	@echo "Making the mfsroot boot floppies..."
748	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot \
749	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz
750.if defined(SMALLFLOPPYSIZE)
751	@echo "Making the small mfsroot boot floppies..."
752	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot-small \
753	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz \
754	    FDSIZE="SMALL"
755.endif
756	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
757	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
758	    MFSROOTFILE="${MFSROOTFLOPPYSET}.split ${MFSROOTFLOPPYSET}.boot"
759.if defined(SMALLFLOPPYSIZE)
760	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
761	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
762	    MFSROOTFILE="${SMALLMFSROOTFLOPPYSET}.split ${SMALLMFSROOTFLOPPYSET}.boot" \
763	    FDSIZE="SMALL"
764.endif
765.else	# !SPLIT_MFSROOT
766	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
767	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
768	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz
769.if defined(SMALLFLOPPYSIZE)
770	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
771	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
772	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz \
773	    FDSIZE="SMALL"
774.endif
775.endif	# SPLIT_MFSROOT
776	touch ${.TARGET}
777
778# Build fixit floppy.
779floppies.2:
780	@echo "Making fixit floppy."
781	@rm -rf ${RD}/fixitfd
782	@mkdir ${RD}/fixitfd
783	@cd ${RD}/fixitfd && \
784	    mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
785	    usr/share/misc
786	@cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
787	    ${RD}/fixitfd/etc
788	@sed -e 's/#.*//' ${RD}/trees/base/etc/protocols \
789	    > ${RD}/fixitfd/etc/protocols
790	@sed -e 's/#.*//' ${RD}/trees/base/usr/share/misc/scsi_modes \
791	    > ${RD}/fixitfd/usr/share/misc/scsi_modes
792	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
793	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
794	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
795	@chmod 555 ${RD}/fixitfd/stand/tar
796.if defined(SMALLFLOPPYSIZE)
797	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit-small \
798	    DIR=${RD}/fixitfd/stand ZIP=false
799	@sh -e ${DOFS_SH} ${RD}/floppies/fixit-small.flp ${RD} ${MNT} \
800	    ${SMALLFLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${SMALLFLOPPYLABEL}
801	@rm -rf ${RD}/fixitfd/stand
802	@mkdir ${RD}/fixitfd/stand
803.endif
804	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
805	    DIR=${RD}/fixitfd/stand ZIP=false
806	@sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} ${MNT} \
807	    ${FLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${FLOPPYLABEL}
808	touch ${.TARGET}
809
810# Do our last minute floppies directory setup
811floppies.3:
812.if !defined(NODOC)
813	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
814	    ${RD}/floppies/README.TXT
815	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
816.else
817	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
818.endif
819	touch ${.TARGET}
820
821#
822# --==## Setup a suitable ftp-area ##==--
823#
824ftp.1:
825	@echo "Setting up FTP distribution area"
826	@mkdir -p ${FD}
827	-@ln -s . ${FD}/${BUILDNAME}
828.if !defined(NO_FLOPPIES)
829	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
830.endif
831	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
832.if !defined(NODOC)
833	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
834		cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
835		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
836		cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
837		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
838	done
839	@for i in ${DIST_DOCS_ARCH_DEP}; do \
840		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
841		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
842		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
843		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
844	done
845	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
846	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
847	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
848	@mv ${FD}/EARLY-ADOPTER.TXT ${FD}/EARLY.TXT
849	@mv ${FD}/EARLY-ADOPTER.HTM ${FD}/EARLY.HTM
850.endif
851	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
852	touch ${.TARGET}
853
854#
855# --==## Setup a suitable cdrom-area ##==--
856#
857cdrom.1:
858	@echo "Setting up CDROM distribution area"
859	@mkdir -p ${CD_BOOT} ${CD_DISC1} ${CD_DISC2}
860	-@ln -s . ${CD_DISC1}/${BUILDNAME}
861.if !defined(NO_FLOPPIES)
862	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
863.endif
864	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
865	@for i in ${DISTRIBUTIONS} ; \
866	do \
867		if [ -d ${RD}/trees/$${i} ] ; then \
868			chflags -R noschg ${RD}/trees/$${i} || true ; \
869			( cd ${RD}/trees/$${i} && \
870			    find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
871		fi \
872	done
873	@rm -f ${CD_DISC2}/.profile
874	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
875	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
876	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
877.if !defined(NODOC)
878	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
879	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
880	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
881	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
882	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
883	done
884	@for i in ${DIST_DOCS_ARCH_DEP}; do \
885	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
886	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
887	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
888	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
889	done
890	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
891	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
892	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
893	@mv ${CD_DISC1}/EARLY-ADOPTER.TXT ${CD_DISC1}/EARLY.TXT
894	@mv ${CD_DISC1}/EARLY-ADOPTER.HTM ${CD_DISC1}/EARLY.HTM
895.endif
896.if ${TARGET} != "pc98"
897	@echo "Setting up boot area"
898	@rm -f ${CD_DISC2}/boot/loader.conf
899	@cp ${RD}/mfsroot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
900	@echo 'mfsroot_load="YES"' > ${CD_DISC2}/boot/loader.conf
901	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC2}/boot/loader.conf
902	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC2}/boot/loader.conf
903.if defined(CD_BOOT)
904	@cp -Rp ${CD_DISC2}/boot ${CD_BOOT}
905.if defined(MINIROOT)
906	@mkdir -p ${FD}/miniroot
907	@sh -e ${DOFS_SH} ${FD}/miniroot/miniroot.ufs \
908	    ${RD} ${MNT} 0 ${CD_BOOT} 8192 auto
909	@gzip -9v ${FD}/miniroot/miniroot.ufs
910.endif
911.endif
912	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
913.endif
914	touch ${.TARGET}
915
916iso.1:
917.if exists(${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh)
918	@echo "Creating ISO images..."
919.if defined(CD_BOOT)
920	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
921	    fbsd_bootonly \
922	    ${CD}/${BUILDNAME}-${TARGET}-bootonly.iso ${CD_BOOT}
923.endif
924	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
925	    ${DISC1_LABEL} \
926	    ${CD}/${BUILDNAME}-${TARGET}-${DISC1_NAME}.iso ${CD_DISC1}
927	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
928	    ${DISC2_LABEL} \
929	    ${CD}/${BUILDNAME}-${TARGET}-${DISC2_NAME}.iso ${CD_DISC2}
930.if defined(CD_EXTRA_BITS)
931	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
932	    fbsd_boot \
933	    ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} \
934	    ${CD_EXTRA_BITS} \
935	    && false
936.endif
937	@(cd ${CD} && md5 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.MD5)
938	touch ${.TARGET}
939.else
940	@echo "Do not know how to create an ISO for ${TARGET_ARCH}."
941.endif
942
943#
944# --==## Documentation Project files such as the Handbook and FAQ ##==--
945#
946doc.1:
947	@echo "Making docs..."
948	@for i in ${DOCPORTS}; do \
949	    cd /usr/ports/$$i && \
950	    env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \
951		make all install clean BATCH=yes WITHOUT_X11=yes JADETEX=no \
952		WITHOUT_PYTHON=yes FORCE_PKG_REGISTER=yes; \
953	done
954	@cd /usr/doc && make all install 'FORMATS=html html-split txt' \
955	    INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc \
956	    URLS_ABSOLUTE=YES	
957	touch ${.TARGET}
958
959#
960# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
961#
962doc.2:
963	@echo "Making release documentation..."
964	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' \
965	    INSTALL_COMPRESSED='' DOCDIR=${RND}
966	touch ${.TARGET}
967
968# Various "subroutine" and other supporting targets.
969
970# RD=
971# SD=
972# TD=
973# ARG=
974doTARBALL:
975.if !defined(SD)
976	@echo "SD undefined in doTARBALL" && exit 1
977.endif
978.if !defined(TD)
979	@echo "TD undefined in doTARBALL" && exit 1
980.endif
981.if !defined(ARG)
982	@echo "ARG undefined in doTARBALL" && exit 1
983.endif
984	@rm -rf ${RD}/dists/${TD}/${TN}*
985	@mkdir -p ${RD}/dists/${TD}
986	@( cd ${SD} && \
987		tn=`echo ${TN} | tr 'A-Z' 'a-z' | cut -c1-8` && \
988		echo rolling ${TD}/$$tn tarball &&\
989		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
990		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
991		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn \
992		    > ${RD}/dists/${TD}/$$tn.inf && \
993		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
994			cp -p ${.CURDIR}/scripts/$${TD}-install.sh \
995			    ${RD}/dists/${TD}/install.sh; \
996		fi && \
997		if [ "${SD}" != "/usr/src" ]; then \
998			mtree -c -i -p ${SD}/${ARG} \
999			  -k gname,md5digest,mode,nlink,uname,size,link,type \
1000			  > ${RD}/dists/${TD}/$$tn.mtree ; \
1001		else \
1002			true; \
1003		fi; \
1004		( cd ${RD}/dists/${TD}; \
1005		rm -f CHECKSUM.MD5; \
1006		md5 * > CHECKSUM.MD5 ) \
1007	)
1008
1009doRELEASE: release.1 release.2 ${DOCREL} release.3 release.4 \
1010    release.5 release.6 release.7 release.8 ${EXTRAS}
1011	@echo "Release done"
1012
1013floppies:
1014	@rm -f release.4 release.8 floppies.[123]
1015	@cd ${.CURDIR} && ${MAKE} release.4 release.8 floppies.1 floppies.2 \
1016	    floppies.3
1017	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
1018
1019installCRUNCH:
1020.if !defined(CRUNCH)
1021	@echo "CRUNCH undefined in installCRUNCH" && exit 1
1022.endif
1023.if !defined(DIR)
1024	@echo "DIR undefined in installCRUNCH" && exit 1
1025.endif
1026.if !defined(ZIP)
1027	@echo "ZIP undefined in installCRUNCH" && exit 1
1028.endif
1029	@if ${ZIP} ; then \
1030		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
1031	else \
1032		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
1033	fi
1034	@chmod 555 ${DIR}/${CRUNCH}_crunch
1035	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
1036		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
1037			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1038		done \
1039	else \
1040		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
1041			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1042		done \
1043	fi
1044
1045#
1046# --==## Build a floppy set for a splitfs file ##==--
1047#
1048# FLOPPYBASE - basename of floppy image files
1049# FLOPPYDESC - description of floppy set
1050# SPLITFILE - filename of the file to split
1051# FDSIZE - if specified and "small", small floppy is created
1052
1053.if make(makeFloppySet)
1054SPLITDIR=	${RD}/floppyset/${FLOPPYBASE}
1055.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1056FLPSPLITSIZE=	${SMALLFLOPPYSPLITSIZE}
1057FLPSIZE=	${SMALLFLOPPYSIZE}
1058FLPLABEL=	${SMALLFLOPPYLABEL}
1059.else
1060FLPSPLITSIZE=	${FLOPPYSPLITSIZE}
1061FLPSIZE=	${FLOPPYSIZE}
1062FLPLABEL=	${FLOPPYLABEL}
1063.endif
1064.endif
1065
1066makeFloppySet:
1067.if !defined(FLOPPYBASE)
1068	@echo "FLOPPYBASE undefined in ${.TARGET}" && exit 1
1069.endif
1070.if !defined(FLOPPYDESC)
1071	@echo "FLOPPYDESC undefined in ${.TARGET}" && exit 1
1072.endif
1073.if !defined(SPLITFILE)
1074	@echo "SPLITFILE undefined in ${.TARGET}" && exit 1
1075.endif
1076	sh ${.CURDIR}/scripts/split-file.sh ${SPLITFILE} \
1077	    ${RD}/floppyset/${FLOPPYBASE} ${FLPSPLITSIZE} "${FLOPPYDESC}"
1078	( splitfile=${SPLITDIR}/`basename ${SPLITFILE}`.split ; \
1079	lines=`cat $${splitfile} | wc -l`; \
1080	lines=$$((lines - 1)) ; \
1081	for line in `jot $$lines`; do \
1082		file=`head -n $$(($${line} + 1)) $${splitfile} | tail -1 | cut -f 1 -d ' '` ; \
1083		sh -e ${DOFS_SH} ${RD}/floppies/${FLOPPYBASE}$${line}.flp \
1084		${RD} ${MNT} ${FLPSIZE} ${SPLITDIR}/$${file} \
1085		${BOOTINODE} ${FLPLABEL}; \
1086	done )
1087
1088#
1089# --==## Build a boot floppy ##==--
1090#
1091# FSIMAGE - base floppy image name
1092# FDSIZE - if specified and "small", small floppy is created
1093# KERNFILE - path to kernel split file
1094# MFSROOTFILE - path to mfsroot split file
1095
1096.if make(buildBootFloppy)
1097IMAGEDIR=	${RD}/image.${FSIMAGE}
1098BOOTDIR=	${RD}/trees/base/boot
1099HINTSFILE=	${BOOTDIR}/device.hints
1100ACPI_KO=	${BOOTDIR}/kernel/acpi.ko
1101IMAGEFILE=	${RD}/floppies/${FSIMAGE}.flp
1102.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1103FLPSIZE=	${SMALLFLOPPYSIZE}
1104FLPLABEL=	${SMALLFLOPPYLABEL}
1105.else
1106FLPSIZE=	${FLOPPYSIZE}
1107FLPLABEL=	${FLOPPYLABEL}
1108.endif
1109.endif
1110
1111buildBootFloppy:
1112.if !defined(FSIMAGE)
1113	@echo "FSIMAGE undefined in ${.TARGET}" && exit 1
1114.endif
1115.if !defined(KERNFILE)
1116	@echo "KERNFILE undefined in ${.TARGET}" && exit 1
1117.endif
1118.if !defined(MFSROOTFILE)
1119	@echo "MFSROOTFILE undefined in ${.TARGET}" && exit 1
1120.endif
1121	@echo "Running ${.TARGET} for ${FSIMAGE}"
1122	@rm -rf ${IMAGEDIR}
1123	@mkdir ${IMAGEDIR}
1124	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
1125	@mkdir -p ${IMAGEDIR}/boot
1126.if ${TARGET} == "i386"
1127	@${WMAKEENV} kgzip -v -l ${RD}/trees/base/usr/lib/kgzldr.o -o \
1128	    ${IMAGEDIR}/boot/loader ${BOOTDIR}/loader
1129.else
1130	@cp ${BOOTDIR}/loader ${IMAGEDIR}/boot
1131.endif
1132	@cp -Rp ${BOOTDIR}/*.4th ${BOOTDIR}/defaults ${BOOTDIR}/loader.help \
1133	    ${BOOTDIR}/loader.rc ${IMAGEDIR}/boot
1134.if exists(${HINTSFILE})
1135	@gzip -9nc ${HINTSFILE} > ${IMAGEDIR}/boot/device.hints.gz
1136.endif
1137	@gzip -9n ${IMAGEDIR}/boot/*.4th ${IMAGEDIR}/boot/loader.help \
1138	    ${IMAGEDIR}/boot/defaults/loader.conf
1139	@echo 'bootfile="/kernel"' > ${IMAGEDIR}/boot/loader.conf
1140.if exists(${ACPI_KO})
1141	@gzip -9nc ${ACPI_KO} > ${IMAGEDIR}/acpi.ko.gz
1142	@echo 'acpi_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1143	@echo 'acpi_name="/acpi.ko"' >> ${IMAGEDIR}/boot/loader.conf
1144	@echo 'acpi_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1145.endif
1146	@echo 'mfsroot_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1147	@echo 'mfsroot_type="mfs_root"' >> ${IMAGEDIR}/boot/loader.conf
1148	@echo 'mfsroot_name="/mfsroot"' >> ${IMAGEDIR}/boot/loader.conf
1149.if !exists(${ACPI_KO})
1150	@echo 'mfsroot_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1151.endif
1152.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
1153	@echo "-P" >> ${IMAGEDIR}/boot.config
1154.endif
1155	@rm -f ${IMAGEFILE}
1156	@cp ${KERNFILE} ${MFSROOTFILE} ${IMAGEDIR}
1157	sh -e ${DOFS_SH} ${IMAGEFILE} ${RD} ${MNT} ${FLPSIZE} ${IMAGEDIR} \
1158	    ${BOOTINODE} ${FLPLABEL}
1159	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1160
1161.include <bsd.obj.mk>
1162