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