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