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