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