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