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