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