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