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