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