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