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