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