xref: /freebsd/release/Makefile (revision c8fa8e25d77016f36e63790f2ceccb90613ccb2e)
1# $FreeBSD$
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.0-RELEASE
22#
23# Automatic SNAP versioning:
24DATE != date +%Y%m%d
25BASE = 5.0
26BUILDNAME?=${BASE}-${DATE}-SNAP
27#
28#CHROOTDIR=/junk/release
29# If this is a -stable snapshot, then set
30#RELEASETAG=RELENG_4
31#
32# To add other options to the CVS subcommands (co,up), set
33#CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
34#
35# To add other options to the CVS command, set
36#CVSARGS="-lfq"
37#
38# To prefix the cvs command
39#CVSPREFIX="/usr/bin/time"
40#
41# Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
42# are building an official release.  Otherwise, we are building for
43# a branch.
44.if defined(RELEASETAG)
45ISRELEASE!=	expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
46.if ${ISRELEASE} != 0
47# Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
48AUXRELEASETAG!=	echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
49DOCRELEASETAG?=		${AUXRELEASETAG}
50PORTSRELEASETAG?=	${AUXRELEASETAG}
51.endif
52.endif
53
54# If you want to pass flags to the world build such as -j X, use
55# WORLD_FLAGS.  Similarly, you can specify make flags for kernel
56# builds via KERNEL_FLAGS.
57# Similarly, you can specify make flags for make readmes via PORTREADMES_FLAGS.
58#WORLD_FLAGS=-j4
59#KERNEL_FLAGS=-j4
60#PORTREADMES_FLAGS=-j4
61
62TARGET_ARCH?=	${MACHINE_ARCH}
63.if ${TARGET_ARCH} == ${MACHINE_ARCH}
64TARGET?=	${MACHINE}
65.else
66TARGET?=	${TARGET_ARCH}
67.endif
68CROSSMAKE=	${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
69NATIVEMAKE=	${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
70
71# If you are using a local CVS repository with components stored in
72# non-standard modules, override these on the make commandline or
73# in the environment.
74RELEASESRCMODULE?=	src
75RELEASEDOCMODULE?=	doc
76RELEASEPORTSMODULE?=	ports
77
78# Uncomment this to disable the doc.1 target.  Docs normally require
79# the ports tree, so NOPORTS can be set together with NODOC in order
80# to have neither ports or docs.  If only NOPORTS is set to YES, but
81# docs are still desired, the DOMINIMALDOCPORTS logic below will only
82# install the ports that are minimally required for the docs.  This is
83# intended as a compromise, less disk space is required than for using
84# the entire ports collection (and much less time due to the huge number
85# of directories it would create), but still quite a bit as well as some
86# CPU cycles (some of the programs are C++, and things like ghostscript
87# belong to the required ports nevertheless).
88#
89# Setting this also disables building of release note documentation
90# (RELNOTESng).
91#NODOC=  YES
92#NOPORTS=  YES
93
94# Modify this definition if you want the release notes
95# and other release documentation in a language other than English.
96RELNOTES_LANG?=	en_US.ISO8859-1
97
98# As an alternative to installing the entire ports collection (which
99# can take a huge amount of time, in particular on slower disks),
100# setting ${MINIMALDOCPORTS} allows to install and build just those
101# ports that are really required for getting the docs up & running.
102.if defined(NOPORTS) && !defined(NODOC)
103DOMINIMALDOCPORTS=	YES
104.include "Makefile.inc.docports"
105RELEASEPORTSMODULE=	${MINIMALDOCPORTS}
106.endif
107
108# Helper variable
109.if defined(NOPORTS)
110.if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
111NOPORTSATALL=	YES
112.endif
113.endif
114
115# By default, documentation (Handbook, FAQ, etc.) is built for all
116# the languages.  To speed up building, set the DOC_LANG to just
117# the languages you need.  (The language for the release notes is
118# controlled by the RELNOTES_LANG variable above.)
119#DOC_LANG=	en_US.ISO8859-1
120DOCPORTS=	textproc/docproj
121# Set this to wherever the distfiles required by release procedures.
122.if defined(DOCDISTFILES)
123# Respect DOCDISTFILES which is used before.
124RELEASEDISTFILES?=	${DOCDISTFILES}
125.else
126RELEASEDISTFILES?=	${.CURDIR}/../../ports/distfiles
127.endif
128# Set this to 1 if you want -P to be used for automatic keyboard detection
129# on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
130AUTO_KEYBOARD_DETECT?= 0
131
132.if !defined(NODOC)
133DIST_DOCS_ARCH_INDEP=	readme errata early-adopter
134DIST_DOCS_ARCH_DEP=	installation relnotes hardware
135.endif
136
137# Things which without too much trouble can be considered variables
138# BASE_DISTS are special in that they get full /etc installation sets.
139#
140.if ${TARGET_ARCH} == "i386"
141COMPAT_DISTS?=	compat1x compat20 compat21 compat22 compat3x compat4x
142.elif ${TARGET_ARCH} != "ia64"
143COMPAT_DISTS?=	compat4x
144.endif
145OTHER_DISTS?=	catpages manpages games proflibs dict info doc
146CRYPTO_DISTS?=	crypto
147BASE_DISTS?=	base
148DISTRIBUTIONS?=	${BASE_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS}
149
150# mountpoint for filesystems.
151MNT=			/mnt
152
153# Various floppy image parameters.
154#
155
156.if ${TARGET_ARCH} == "i386"
157.if ${TARGET} == "pc98"
158SMALLBOOTSIZE=		1200
159BOOTSIZE=		1440
160SMALLFIXITSIZE=		1200
161FIXITSIZE=		1440
162MFSSIZE=		4320
163BOOTINODE=		80000
164FIXITINODE=		40000
165MFSINODE=		8000
166SMALLBOOTLABEL=		fd1200
167BOOTLABEL=		fd1440
168SMALLFIXITLABEL=	fd1200
169FIXITLABEL=		fd1440
170MFSLABEL=		minimum3
171.else
172DRIVERSIZE=		1440
173BOOTSIZE=		1440
174FIXITSIZE=		1440
175MFSSIZE=		4320
176BIGBOOTSIZE=		2880
177DRIVERINODE=		40000
178BOOTINODE=		80000
179FIXITINODE=		40000
180MFSINODE=		8000
181DRIVERLABEL=		fd1440
182BOOTLABEL=		fd1440
183FIXITLABEL=		fd1440
184MFSLABEL=		minimum3
185BIGBOOTLABEL=		minimum2
186.endif
187.elif ${TARGET_ARCH} == "alpha"
188DRIVERSIZE=		1440
189BOOTSIZE=		1440
190FIXITSIZE=		2880
191MFSSIZE=		4320
192BIGBOOTSIZE=		2880
193DRIVERINODE=		40000
194BOOTINODE=		80000
195FIXITINODE=		40000
196MFSINODE=		8000
197DRIVERLABEL=		fd1440
198BOOTLABEL=		fd1440
199FIXITLABEL=		minimum2
200MFSLABEL=		auto
201BIGBOOTLABEL=		minimum2
202.elif ${TARGET_ARCH} == "sparc64"
203DISKLABEL=		sunlabel
204BIGBOOTSIZE=		4096
205MFSSIZE=		4096
206BOOTINODE=		8192
207MFSINODE=		8192
208BIGBOOTLABEL=		auto
209MFSLABEL=		auto
210.elif ${TARGET_ARCH} == "ia64"
211BIGBOOTLABEL=		efi
212BIGBOOTSIZE=		5154
213BOOTINODE=		15872
214MFSINODE=		8192
215MFSLABEL=		auto
216MFSSIZE=		8192
217.endif
218
219.if exists(/sbin/bsdlabel)
220DISKLABEL?=		bsdlabel
221.else
222DISKLABEL?=		disklabel
223.endif
224
225ZIPNSPLIT=		gzip --no-name -9 -c | split -b 1423k -
226
227# Things that need to be compiled without crypto support in releases
228.if !defined(FIXCRYPTO)
229FIXCRYPTO!=	cd ${.CURDIR}/../kerberos5; ${MAKE} -V KPROGS
230FIXCRYPTO+=	bin/ed usr.sbin/ppp usr.sbin/pppd usr.sbin/tcpdump/tcpdump \
231		lib/libfetch usr.bin/fetch
232.if !defined(NO_SENDMAIL)
233FIXCRYPTO+=	usr.sbin/sendmail
234.endif
235.endif
236
237
238# Things which may get you into trouble if you change them
239MTREEFILES=		${.CURDIR}/../etc/mtree
240_R?=			/R
241RD=			${_R}/stage
242RND=			${RD}/release.doc
243FD=			${_R}/ftp
244CD=			${_R}/cdrom
245CD_DISC1=		${CD}/disc1
246CD_DISC2=		${CD}/disc2
247
248# Where the bootstrap ports (see DOCPORTS) get installed.
249LOCALDIR=		/usr/local/bin
250
251.if exists(${.CURDIR}/${TARGET_ARCH}/doFS.sh)
252DOFS_SH=	${.CURDIR}/${TARGET_ARCH}/doFS.sh
253.elif ${TARGET} != ${MACHINE}
254DOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ${TARGET}
255.else
256DOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ""
257.endif
258
259.if ${TARGET_ARCH} == "sparc64"
260CRUNCH_TARGETS= boot
261FIXIT_TARGET=
262.elif ${TARGET_ARCH} == "ia64"
263CRUNCH_TARGETS= boot
264FIXIT_TARGET=
265.elif ${TARGET} == "pc98"
266CRUNCH_TARGETS=	boot fixit fixit-small
267.endif
268
269.if !defined(CRUNCH_TARGETS)
270CRUNCH_TARGETS=	boot fixit
271.endif
272
273.if !defined(FIXIT_TARGET)
274FIXIT_TARGET= release.10
275.endif
276
277EXTRAS= ftp.1
278.if !defined(NOCDROM)
279EXTRAS+= cdrom.1
280.if defined(MAKE_ISOS)
281EXTRAS+= iso.1
282.endif
283.if ${TARGET} != "pc98"
284BOOTABLE="-b"
285.endif
286.endif
287
288.if !defined(NODOC)
289DOCREL= doc.1 doc.2
290.endif
291
292WMAKEENV!=	cd ${.CURDIR}/..; ${CROSSMAKE} -f Makefile.inc1 -V WMAKEENV
293WMAKE=		${WMAKEENV} ${MAKE} -m ${.CURDIR}/../share/mk
294
295CVS_SRCARGS=	-P
296.if defined(RELEASETAG)
297CVS_SRCARGS+=	-r ${RELEASETAG}
298.endif
299
300CVS_DOCARGS=	-P
301.if defined(DOCRELEASETAG)
302CVS_DOCARGS+=	-r ${DOCRELEASETAG}
303.endif
304
305CVS_PORTSARGS=	-P
306.if defined(PORTSRELEASETAG)
307CVS_PORTSARGS+=	-r ${PORTSRELEASETAG}
308.endif
309
310release rerelease:
311.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
312	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
313.endif
314.if defined(NOPORTSATALL) && !defined(NODOC)
315	@echo "Ports are required for building the docs.  Either set NODOC or"
316	@echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
317	@exit 1
318.endif
319.if make(release)
320.if exists(${CHROOTDIR})
321# The first command will fail on a handful of files that have their schg
322# flags set.  But it greatly speeds up the next two commands.
323	# NB: clear any vestigal devfs mount, just in case
324	-umount ${CHROOTDIR}/dev > /dev/null 2>&1
325	-rm -rf ${CHROOTDIR} 2>/dev/null
326	-chflags -R noschg ${CHROOTDIR}/.
327	-rm -rf ${CHROOTDIR}
328.endif
329	mkdir -p ${CHROOTDIR}
330	@echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
331	cd ${.CURDIR}/.. && ${NATIVEMAKE} -DNOGAMES -DNOHTML -DNOINFO -DNOMAN \
332	    -DNOPROFILE installworld DESTDIR=${CHROOTDIR}
333	cd ${.CURDIR}/../etc && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
334	if [ -f /etc/resolv.conf ]; then \
335		cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
336	fi
337.if defined(EXTLOCALDIR)
338	rm -rf ${CHROOTDIR}/usr/local
339	cd ${CHROOTDIR}/usr && cp -R -H ${EXTLOCALDIR} local
340.endif
341	rm -rf ${CHROOTDIR}/usr/src
342.if defined(EXTSRCDIR)
343	cd ${CHROOTDIR}/usr && \
344		cp -R -H ${EXTSRCDIR} src
345.else
346	cd ${CHROOTDIR}/usr && \
347		${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
348.endif
349.if defined(LOCAL_PATCHES) && exists(${LOCAL_PATCHES})
350	cd ${CHROOTDIR}/usr/src && patch ${PATCH_FLAGS} < ${LOCAL_PATCHES}
351.endif
352.if defined(LOCAL_SCRIPT) && exists(${LOCAL_SCRIPT})
353	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
354.endif
355	rm -rf ${CHROOTDIR}/usr/ports
356.if !defined(NOPORTSATALL)
357	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
358.endif
359.if !defined(NODOC)
360	rm -rf ${CHROOTDIR}/usr/doc
361.if defined(EXTDOCDIR)
362	cd ${CHROOTDIR}/usr && cp -R -H ${EXTDOCDIR} doc
363.else
364	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
365.endif
366	if [ -d ${RELEASEDISTFILES}/ ]; then \
367		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
368	else \
369		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
370	fi
371.if !defined(NO_PREFETCHDISTFILES)
372	@cd ${.CURDIR} && ${MAKE} fetch-distfiles
373.endif
374.endif
375.endif
376.if make(rerelease)
377.if !defined(RELEASENOUPDATE)
378.if !defined(RELEASETAG)
379	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d -A
380.else
381	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
382.endif
383	rm -f ${CHROOTDIR}/tmp/.world_done
384.if !defined(NOPORTS)
385	cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d
386.endif
387.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
388	for i in ${MINIMALDOCPORTS}; do \
389		( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d ) ; \
390	done
391.endif
392.if !defined(NODOC)
393	cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q update ${CVSCMDARGS} -P -d
394.endif
395.endif
396.endif
397	# Add version information to those things that need it.
398	if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
399		cd ${CHROOTDIR}/usr/src/sys/conf && \
400		mv newvers.sh foo && \
401		sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && \
402		rm foo; \
403	fi
404	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
405	echo "#!/bin/sh"			> ${CHROOTDIR}/mk
406	echo "set -ex"				>> ${CHROOTDIR}/mk
407	echo "trap 'umount /dev || true' 0"	>> ${CHROOTDIR}/mk
408	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${CHROOTDIR}/mk
409.for var in \
410	AUTO_KEYBOARD_DETECT \
411	BOOT_CONFIG \
412	BUILDNAME \
413	CD_EXTRA_BITS \
414	DISTRIBUTIONS \
415	DOC_LANG \
416	DOMINIMALDOCPORTS \
417	EXTRA_SRC \
418	FIXCRYPTO \
419	FTP_PASSIVE_MODE \
420	FTP_PROXY \
421	HTTP_PROXY \
422	KERNELS \
423	KERNEL_FLAGS \
424	MAKE_ISOS \
425	NOCDROM \
426	NODOC \
427	NOPORTS \
428	NOSHARED \
429	NOSRC \
430	NO_CPU_CFLAGS \
431	NO_CPU_COPTFLAGS \
432	NO_FLOPPIES \
433	NO_SENDMAIL \
434	RELEASETAG \
435	RELNOTES_LANG \
436	TARGET \
437	TARGET_ARCH \
438	WORLD_FLAGS
439.if defined(${var})
440	echo "export ${var}=\"${${var}}\""	>> ${CHROOTDIR}/mk
441.endif
442.endfor
443	# Don't remove this, or the build will fall over!
444	echo "export RELEASEDIR=${_R}"		>> ${CHROOTDIR}/mk
445	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${CHROOTDIR}/mk
446	echo "export MANBUILDCAT=YES"		>> ${CHROOTDIR}/mk
447	# NB: these may fail if the host is running w/o devfs
448	echo "umount /dev >/dev/null 2>&1 || true" >> ${CHROOTDIR}/mk
449	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true" \
450						>> ${CHROOTDIR}/mk
451	echo "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
452	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
453	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNOCLEAN buildworld && \\" >> ${CHROOTDIR}/mk
454	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
455	echo "fi"				>> ${CHROOTDIR}/mk
456.if defined(NOPORTS) || defined(NOPORTREADMES)
457	echo "if false; then"			>> ${CHROOTDIR}/mk
458.else
459	echo "if true; then"			>> ${CHROOTDIR}/mk
460.endif
461	echo "	echo \">>> make readmes started on \`LC_ALL=C TZ=GMT date\`\"" >> ${CHROOTDIR}/mk
462	echo "	cd /usr/ports"			>> ${CHROOTDIR}/mk
463	echo "	make ${PORTREADMES_FLAGS} readmes" >> ${CHROOTDIR}/mk
464	echo "	echo \">>> make readmes finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${CHROOTDIR}/mk
465	echo "fi"				>> ${CHROOTDIR}/mk
466	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
467	echo "make obj"				>> ${CHROOTDIR}/mk
468	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
469	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${CHROOTDIR}/mk
470	chmod 755 ${CHROOTDIR}/mk
471	# Ensure md.ko is loaded if md(4) is not statically compiled into the kernel
472	-mdconfig 2>/dev/null
473	env -i /usr/sbin/chroot ${CHROOTDIR} /mk
474
475clean:
476	rm -rf boot_crunch release.[0-9]
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	mkdir ${RD}/floppies
494	mkdir ${RD}/trees
495	mkdir ${RD}/kernels
496	for i in ${DISTRIBUTIONS} ; do \
497		mkdir ${RD}/trees/$$i && \
498		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
499		    -p ${RD}/trees/$$i > /dev/null && \
500		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
501		    -p ${RD}/trees/$$i/usr > /dev/null && \
502		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
503		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
504		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
505		    -p ${RD}/trees/$$i/var > /dev/null ; \
506	done
507	touch release.1
508
509# Install the system into the various distributions.
510release.2:
511	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
512	cd ${.CURDIR}/.. && ${CROSSMAKE} distributeworld DISTDIR=${RD}/trees
513	touch release.2
514
515# Build and install crypto distributions.
516release.3:
517	# Handle some grief caused by the munition braindeadness.
518	cd ${.CURDIR}/..; \
519	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DNOCRYPT \
520	    SUBDIR_OVERRIDE="${FIXCRYPTO}" \
521	    buildworld distributeworld DISTDIR=${RD}/trees
522	-chflags -R noschg ${RD}/trees
523	touch release.3
524
525# Make and install the generic kernel(s).
526release.4:
527.for kernel in ${KERNELS}
528	cd ${.CURDIR}/..; \
529	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
530	    KERNCONF=${kernel} INSTKERNNAME=${kernel} kernel \
531	    DESTDIR=${RD}/trees/base
532.endfor
533	# Install a standard boot kernel+modules.
534	cd ${.CURDIR}/..; \
535	${CROSSMAKE} ${KERNEL_FLAGS} \
536	    kernel \
537	    DESTDIR=${RD}/trees/base; \
538	cd ${.CURDIR}/..; \
539	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
540	    reinstallkernel -DINSTALL_DEBUG \
541	    DESTDIR=${RD}/trees/base
542	touch release.4
543
544# Make and install the three crunched binaries which live on the floppies.
545# You are not supposed to like this :-)
546release.5:
547	rm -rf ${RD}/crunch
548	mkdir -p ${RD}/crunch
549.for j in ${CRUNCH_TARGETS}
550	rm -rf ${j}_crunch
551	mkdir ${j}_crunch
552.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
553	cd ${j}_crunch; ${WMAKEENV} crunchgen -o ${.CURDIR}/${TARGET}/${j}_crunch.conf
554.else
555	cd ${j}_crunch; ${WMAKEENV} crunchgen -o ${.CURDIR}/${j}_crunch.conf
556.endif
557	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
558	cd ${.CURDIR}/..; ${MAKE} -m ${.CURDIR}/../share/mk -f Makefile.inc1 \
559	    _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.endfor
565	touch release.5
566
567#
568# --==## Fix up the distributions. ##==--
569#
570release.6:
571	# Create any "synthetic dists" now.
572	@for i in ${DISTRIBUTIONS}; do \
573		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
574			echo -n "Running $$i dist creation script... "; \
575			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
576			echo "Done."; \
577		fi \
578	done \
579
580	# Remove all the directories we don't need.
581	-cd ${RD}/trees && \
582		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
583	touch release.6
584
585#
586# --==## Package up the tarballs from assembled trees ##==--
587#
588release.7:
589	rm -rf ${RD}/dists
590	mkdir -p ${RD}/dists
591	@for i in ${DISTRIBUTIONS} ; \
592	do \
593		if [ -d ${RD}/trees/$${i} ] ; then \
594			cd ${.CURDIR} && $(MAKE) doTARBALL \
595				SD=${RD}/trees/$${i} \
596				TN=$$i TD=$$i ARG="." && \
597			echo "$${i} distribution is finished."; \
598		fi ; \
599	done
600	touch release.7
601
602
603#
604# --==## Make source dists ##==--
605#
606release.8:
607.if !defined(NOSRC)
608	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
609		TD=src TN=sbase ARG="[A-Z]*"
610	@for i in `cd /usr/src && echo [a-z]*` ; do \
611		if [ -d /usr/src/$$i ] ; then \
612			cd ${.CURDIR} && $(MAKE) doTARBALL \
613				TN=`echo s$$i | tr -d '.' | \
614				    sed -e 's/usr/u/' \
615					-e 's/kerberos5/krb5/'` \
616				SD=/usr/src TD=src ARG="$$i" ; \
617		fi ; \
618	done
619.if defined(EXTRA_SRC)
620	@set ${EXTRA_SRC} && \
621	while [ $$# -ge 2 ] ; do \
622		if [ -d /usr/src/$$1 ] ; then \
623			cd ${.CURDIR} && $(MAKE) doTARBALL \
624				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
625		fi && shift && shift ; \
626	done
627.endif
628	if [ -d ${RD}/dists/crypto ] ; then ( cd ${RD}/dists/src && \
629		if [ -f ssecure.aa ] ; then mv ssecure.* ../crypto ; fi && \
630		if [ -f scrypto.aa ] ; then mv scrypto.* ../crypto ; fi && \
631		if [ -f skrb5.aa ] ; then mv skrb5.* ../crypto ; fi ; \
632		cd ${RD}/dists/crypto; rm -f CHECKSUM.MD5; \
633		md5 * > CHECKSUM.MD5 ) ; fi
634	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
635	@echo "src distribution is finished."
636.endif
637	touch release.8
638
639# Complete the bootfd
640#
641# Now, just to get this picture down once and for all:
642#
643# +------------------------------------------------------------------------+
644# |boot.flp                                                                |
645# +-----+-----+------------------------------------------------------------+
646# |boot1|boot2|floppy filesystem "bootfd"                                  |
647# +-----+-----+-+----------------------+---------------------------------+-+
648#               |kernel.gz             |mfsroot.gz                       |
649#               +----------------------+---------------------------------+
650#
651
652release.9:
653.if ${TARGET_ARCH} != "ia64" || ${TARGET_ARCH} == ${MACHINE_ARCH}
654	cp ${RD}/trees/base/etc/disktab /etc
655	rm -rf ${RD}/mfsfd
656	mkdir ${RD}/mfsfd
657	cd ${RD}/mfsfd && \
658		mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help
659	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
660		DIR=${RD}/mfsfd/stand ZIP=false
661	( cd ${RD}/mfsfd && \
662	  for dir in bin sbin ; do \
663		ln -sf /stand $$dir; \
664	  done )
665	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
666.if ${TARGET} == "pc98"
667	cp ${.CURDIR}/../etc/defaults/pccard.conf ${RD}/mfsfd/etc/defaults/pccard.conf
668.endif
669	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
670	( for F in defaults/rc.conf netconfig protocols ; do \
671		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
672		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
673	  done )
674	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
675	    ${RD}/trees/base/etc/services | \
676	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
677	    > ${RD}/mfsfd/stand/etc/services
678	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
679	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
680	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
681.if !defined(NODOC)
682	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
683	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
684	done
685	@for i in ${DIST_DOCS_ARCH_DEP}; do \
686	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
687	done
688	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT ${RD}/mfsfd/stand/help/INSTALL.TXT
689	@mv ${RD}/mfsfd/stand/help/EARLY-ADOPTER.TXT ${RD}/mfsfd/stand/help/EARLY.TXT
690.endif
691	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
692	@mkdir -p ${RD}/mfsfd/boot
693.if ${TARGET_ARCH} != "ia64"
694	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
695.endif
696.if ${TARGET} == "i386"
697	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
698.endif
699	@echo "Making the regular boot floppy."
700	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
701		tar xf - -C ${RD}/mfsfd/stand
702.if ${TARGET_ARCH} == "alpha" && !defined(NO_FLOPPIES)
703	rm -rf ${RD}/mfsfd/stand/help/*
704.endif
705.if defined(SMALLBOOTSIZE)
706.if exists(${.CURDIR}/${TARGET}/drivers-small.conf)
707	@rm -rf ${RD}/mfsfd/modules
708	@mkdir -p ${RD}/mfsfd/modules
709	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
710	    ${.CURDIR}/${TARGET}/drivers-small.conf \
711	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/modules
712.endif
713	sh -e ${DOFS_SH} mfsroot ${RD} ${MNT} \
714		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
715	@gzip -9vc mfsroot > mfsroot.gz
716	@sh -e ${DOFS_SH} ${RD}/floppies/mfsroot-small.flp \
717		${RD} ${MNT} ${SMALLBOOTSIZE} mfsroot.gz \
718		${BOOTINODE} ${SMALLBOOTLABEL}
719.endif
720.if exists(${.CURDIR}/${TARGET}/drivers.conf)
721	@rm -rf ${RD}/mfsfd/modules
722	@mkdir -p ${RD}/mfsfd/modules
723	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
724	    ${.CURDIR}/${TARGET}/drivers.conf \
725	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/modules
726	@rm -rf ${RD}/driversfd
727	@mkdir ${RD}/driversfd
728	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 3 \
729	    ${.CURDIR}/${TARGET}/drivers.conf \
730	    ${RD}/trees/base/boot/kernel ${RD}/driversfd
731	-@rmdir ${RD}/driversfd
732	if [ -d ${RD}/driversfd ]; then \
733	    sh -e ${DOFS_SH} \
734		${RD}/floppies/drivers.flp ${RD} ${MNT} ${DRIVERSIZE} \
735		${RD}/driversfd ${DRIVERINODE} ${DRIVERLABEL}; \
736	    cd ${RD}/driversfd && awk -f  ${.CURDIR}/scripts/driver-desc.awk \
737		*.dsc >> ${RD}/floppies/DRIVERS.TXT; \
738	fi
739.endif
740	sh -e ${DOFS_SH} mfsroot ${RD} ${MNT} \
741		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
742	@gzip -9vc mfsroot > mfsroot.gz
743	@mkdir -p ${RD}/mfsroot
744	@cp mfsroot.gz ${RD}/mfsroot
745.if !defined(NO_FLOPPIES)
746.if defined(BOOTSIZE)
747	@sh -e ${DOFS_SH} ${RD}/floppies/mfsroot.flp \
748		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
749	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
750.endif
751.if defined(SMALLBOOTSIZE)
752	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
753.endif
754.if defined(BIGBOOTSIZE)
755	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
756.endif
757.endif
758	@rm mfsroot mfsroot.gz
759	@echo "Regular and MFS boot floppies made."
760.endif
761	touch release.9
762
763#
764# --==## Create a fixit floppy ##==--
765#
766release.10:
767.if !defined(NO_FLOPPIES)
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	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
794		DIR=${RD}/fixitfd/stand ZIP=false
795	@sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} \
796		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
797# Do our last minute floppies directory setup in a convenient place.
798.if !defined(NODOC)
799	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
800		${RD}/floppies/README.TXT
801	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
802.else
803	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
804.endif
805.endif
806	touch release.10
807
808#
809# --==## Setup a suitable ftp-area ##==--
810#
811ftp.1:
812	@echo "Setting up FTP distribution area"
813	@mkdir -p ${FD}
814	-@ln -s . ${FD}/${BUILDNAME}
815	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
816	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
817.if !defined(NODOC)
818	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
819	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
820	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
821	done
822	@for i in ${DIST_DOCS_ARCH_DEP}; do \
823	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
824	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
825	done
826	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
827	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
828	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
829	@mv ${FD}/EARLY-ADOPTER.TXT ${FD}/EARLY.TXT
830	@mv ${FD}/EARLY-ADOPTER.HTM ${FD}/EARLY.HTM
831.endif
832	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
833.if !defined(NOPORTS)
834	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
835.endif
836	touch ftp.1
837
838#
839# --==## Setup a suitable cdrom-area ##==--
840#
841cdrom.1:
842	@echo "Setting up CDROM distribution area"
843	@mkdir -p ${CD_DISC1} ${CD_DISC2}
844	-@ln -s . ${CD_DISC1}/${BUILDNAME}
845	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
846	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
847	@for i in ${DISTRIBUTIONS} ; \
848	do \
849		if [ -d ${RD}/trees/$${i} ] ; then \
850			chflags -R noschg ${RD}/trees/$${i} || true ; \
851			( cd ${RD}/trees/$${i} && \
852			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
853		fi \
854	done
855	@rm -f ${CD_DISC2}/.profile
856	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
857	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
858	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
859.if !defined(NODOC)
860	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
861	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
862	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
863	done
864	@for i in ${DIST_DOCS_ARCH_DEP}; do \
865	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
866	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
867	done
868	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
869	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
870	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
871	@mv ${CD_DISC1}/EARLY-ADOPTER.TXT ${CD_DISC1}/EARLY.TXT
872	@mv ${CD_DISC1}/EARLY-ADOPTER.HTM ${CD_DISC1}/EARLY.HTM
873.endif
874.if ${TARGET} != "pc98"
875	@echo "Setting up /boot"
876	@rm -f ${CD_DISC2}/boot/loader.conf
877	@cp ${RD}/mfsroot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
878	@echo 'mfsroot_load="YES"' > ${CD_DISC2}/boot/loader.conf
879	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC2}/boot/loader.conf
880	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC2}/boot/loader.conf
881	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
882.endif
883.if ${TARGET} == "i386"
884	@mkdir -p ${CD_DISC2}/floppies
885	@cp ${CD_DISC1}/floppies/boot.flp ${CD_DISC2}/floppies
886.endif
887.if !defined(NOPORTS)
888	@mkdir -p ${CD_DISC1}/ports && \
889	  tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
890	  ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
891	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
892	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
893.endif
894	touch cdrom.1
895
896iso.1:
897.if exists(${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh)
898	@echo "Creating ISO images..."
899	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
900	    fbsd_miniinst \
901	    ${CD}/${BUILDNAME}-${TARGET}-miniinst.iso ${CD_DISC1}
902	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
903	    fbsd_livefs \
904	    ${CD}/${BUILDNAME}-${TARGET}-disc2.iso ${CD_DISC2}
905.if defined(CD_EXTRA_BITS)
906	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh \
907	    ${BOOTABLE} fbsd_boot \
908	    ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} \
909	    ${CD_EXTRA_BITS} \
910	    && false
911.endif
912	touch iso.1
913.else
914	@echo "Do not know how to create an ISO for ${TARGET_ARCH}."
915.endif
916
917#
918# --==## Documentation Project files such as the Handbook and FAQ ##==--
919#
920doc.1:
921	@echo "Making docs..."
922	@for i in ${DOCPORTS}; do \
923	    cd /usr/ports/$$i && \
924	    env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \
925		make all install clean BATCH=yes WITHOUT_X11=yes JADETEX=no \
926		WITHOUT_PYTHON=yes FORCE_PKG_REGISTER=yes; \
927	done
928	@cd /usr/doc && make all install 'FORMATS=html html-split txt' INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc
929	touch doc.1
930
931#
932# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
933#
934doc.2:
935	@echo "Making release documentation..."
936	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' INSTALL_COMPRESSED='' DOCDIR=${RND}
937	touch doc.2
938
939# Various "subroutine" and other supporting targets.
940
941# RD=
942# SD=
943# TD=
944# ARG=
945doTARBALL:
946.if !defined(SD)
947	@echo "SD undefined in doTARBALL" && exit 1
948.endif
949.if !defined(TD)
950	@echo "TD undefined in doTARBALL" && exit 1
951.endif
952.if !defined(ARG)
953	@echo "ARG undefined in doTARBALL" && exit 1
954.endif
955	@rm -rf ${RD}/dists/${TD}/${TN}*
956	@mkdir -p ${RD}/dists/${TD}
957	@( cd ${SD} && \
958		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
959		echo rolling ${TD}/$$tn tarball &&\
960		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
961		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
962		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
963		   ${RD}/dists/${TD}/$$tn.inf && \
964		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
965		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
966		fi && \
967		if [ "${SD}" != "/usr/src" ]; then \
968			mtree -c -i -p ${SD}/${ARG} \
969			  -k gname,md5digest,mode,nlink,uname,size,link,type \
970			  > ${RD}/dists/${TD}/$$tn.mtree ; \
971		else \
972			true; \
973		fi; \
974		(cd ${RD}/dists/${TD}; \
975		   rm -f CHECKSUM.MD5; \
976		   md5 * > CHECKSUM.MD5) \
977	)
978
979.if target(release.9.${TARGET_ARCH})
980RELEASE9=release.9.${TARGET_ARCH}
981.else
982RELEASE9=release.9
983.endif
984
985doRELEASE:  release.1 release.2 release.3 ${DOCREL} release.4 release.5 \
986		release.6 release.7 release.8 ${RELEASE9} ${FIXIT_TARGET}
987	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
988	@echo "Release done"
989
990floppies:
991	@cd ${.CURDIR} && ${MAKE} boot.flp
992	@cd ${.CURDIR} && ${MAKE} fixit.flp
993	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
994
995boot.flp:
996	@rm -f release.5 release.9
997	@cd ${.CURDIR} && ${MAKE} release.5 release.9 CRUNCH_TARGETS=boot
998
999fixit.flp:
1000	@rm -f release.5 release.10
1001	@cd ${.CURDIR} && ${MAKE} release.5 release.10 CRUNCH_TARGETS=fixit
1002
1003installCRUNCH:
1004.if !defined(CRUNCH)
1005	@echo "CRUNCH undefined in installCRUNCH" && exit 1
1006.endif
1007.if !defined(DIR)
1008	@echo "DIR undefined in installCRUNCH" && exit 1
1009.endif
1010.if !defined(ZIP)
1011	@echo "ZIP undefined in installCRUNCH" && exit 1
1012.endif
1013	@if ${ZIP} ; then \
1014		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
1015	else \
1016		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
1017	fi
1018	@chmod 555 ${DIR}/${CRUNCH}_crunch
1019	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
1020		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
1021			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1022		done \
1023	else \
1024		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
1025			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1026		done \
1027	fi
1028
1029#
1030# --==## Put a filesystem into a BOOTMFS kernel ##==--
1031#
1032doMFSKERN:
1033	@echo "Running ${.TARGET} for ${FSIMAGE}"
1034	@rm -f ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
1035	@cd ${.CURDIR}/../sys/${TARGET}/conf && \
1036	    sh ${.CURDIR}/${TARGET}/dokern.sh ${FDSIZE} < GENERIC > BOOTMFS && \
1037	    [ -r GENERIC.hints ] && cp GENERIC.hints BOOTMFS.hints
1038.if defined(FDSIZE) && ${FDSIZE} == "SMALL" && \
1039    exists(${.CURDIR}/${TARGET}/drivers-small.conf)
1040	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
1041		${.CURDIR}/${TARGET}/drivers-small.conf \
1042		${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
1043.elif exists(${.CURDIR}/${TARGET}/drivers.conf)
1044	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
1045		${.CURDIR}/${TARGET}/drivers.conf \
1046		${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
1047.endif
1048	cd ${.CURDIR}/..; \
1049	KERNEL_KO=BOOTMFS KODIR= \
1050	    ${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES -DNO_KERNELCLEAN \
1051	    KERNCONF=BOOTMFS COPTFLAGS="-Os -pipe" -DNO_CPU_COPTFLAGS \
1052	    buildkernel reinstallkernel \
1053	    DESTDIR=${RD}/kernels
1054	[ -r ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ] && \
1055	cp ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ${RD}/kernels
1056	@rm -rf ${RD}/image.${FSIMAGE}
1057	@mkdir ${RD}/image.${FSIMAGE}
1058	@cd ${RD}/kernels && \
1059	  (chflags noschg BOOTMFS || true) && \
1060	  ${WMAKEENV} strip -R .comment BOOTMFS && \
1061	  cp BOOTMFS BOOTMFS.${FSIMAGE} && \
1062	  [ -r BOOTMFS.hints ] && mv BOOTMFS.hints BOOTMFS.${FSIMAGE}.hints
1063	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
1064	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
1065	@mkdir -p ${RD}/image.${FSIMAGE}/boot
1066.if ${TARGET} == "i386"
1067	@${WMAKEENV} kgzip -v -l ${RD}/trees/base/usr/lib/kgzldr.o \
1068	    -o ${RD}/image.${FSIMAGE}/boot/loader ${RD}/trees/base/boot/loader
1069.elif ${TARGET_ARCH} == "ia64"
1070	@cp ${RD}/trees/base/boot/loader.efi ${RD}/image.${FSIMAGE}/boot
1071.else
1072	@cp ${RD}/trees/base/boot/loader ${RD}/image.${FSIMAGE}/boot
1073.endif
1074	@[ -r ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints ] && \
1075	  sed -e '/^hint/s/^/set /' -e '/^#/d' \
1076	    ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints > \
1077	    ${RD}/image.${FSIMAGE}/boot/device.hints && \
1078	  echo "include /boot/device.hints" > ${RD}/image.${FSIMAGE}/boot/loader.rc
1079	@echo "load /kernel" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1080.if !defined(FDSIZE) || ${FDSIZE} != "BIG"
1081	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1082	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1083	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1084.endif
1085	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1086.if ${TARGET_ARCH} != "ia64"
1087	@echo "set hint.acpi.0.disabled=1" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1088.endif
1089	@if [ -r ${RD}/floppies/drivers.flp ]; then \
1090	    echo "set driver_floppy=YES" >> ${RD}/image.${FSIMAGE}/boot/loader.rc; \
1091	fi
1092	@echo "set module_path=\"/modules;/dist\"" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1093	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1094	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1095.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
1096	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
1097.endif
1098	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
1099	@rm -f ${RD}/floppies/${FSIMAGE}.flp
1100.if defined(FDSIZE) && ${FDSIZE} == "BIG"
1101	@cp mfsroot.gz ${RD}/image.${FSIMAGE}
1102	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp \
1103		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
1104		${BOOTINODE} ${BIGBOOTLABEL}
1105.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
1106	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp \
1107		${RD} ${MNT} ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} \
1108		${BOOTINODE} ${SMALLBOOTLABEL}
1109.else
1110	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp \
1111		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
1112		${BOOTINODE} ${BOOTLABEL}
1113.endif
1114	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1115
1116.include <bsd.obj.mk>
1117