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