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