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