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