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