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