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