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