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