Makefile revision 124549
1# $FreeBSD: head/release/Makefile 124549 2004-01-15 10:17:43Z nyan $
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
204MFSSIZE=		4096
205MFSINODE=		8192
206MFSLABEL=		auto
207MINIROOT=
208NO_FLOPPIES=
209.elif ${TARGET_ARCH} == "ia64"
210MFSINODE=		8192
211MFSLABEL=		auto
212MFSSIZE=		8192
213NO_FLOPPIES=
214.elif ${TARGET_ARCH} == "amd64"
215MFSSIZE=		4096
216MFSINODE=		8192
217MFSLABEL=		auto
218NO_FLOPPIES=
219.endif
220
221.if exists(/sbin/bsdlabel)
222DISKLABEL?=		bsdlabel
223.else
224DISKLABEL?=		disklabel
225.endif
226
227ZIPNSPLIT=		gzip --no-name -9 -c | split -b 1423k -
228
229# Things that need to be compiled without crypto support in releases
230.if !defined(FIXCRYPTO) && !make(release) && !make(rerelease)
231FIXCRYPTO!=	cd ${.CURDIR}/../kerberos5; ${MAKE} -V KPROGS; \
232		cd ${.CURDIR}/../secure; ${MAKE} -V SPROGS
233.endif
234
235# Things which may get you into trouble if you change them
236MTREEFILES=		${.CURDIR}/../etc/mtree
237_R?=			/R
238RD=			${_R}/stage
239RND=			${RD}/release.doc
240FD=			${_R}/ftp
241CD=			${_R}/cdrom
242.if ${TARGET} != "pc98"
243CD_BOOT=		${CD}/bootonly
244.endif
245CD_DISC1=		${CD}/disc1
246CD_DISC2=		${CD}/disc2
247_MK?=			${CHROOTDIR}/mk
248
249# Where the bootstrap ports (see DOCPORTS) get installed.
250LOCALDIR=		/usr/local/bin
251
252.if ${TARGET} != ${MACHINE} && ${DISKLABEL} == "bsdlabel"
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} \
347	    co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
348.endif
349.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
350.for p in ${LOCAL_PATCHES}
351.if exists(${p})
352	patch -d ${CHROOTDIR}/usr/${RELEASESRCMODULE} ${PATCH_FLAGS} < ${p}
353.endif
354.endfor
355.endif
356.if defined(LOCAL_SCRIPT) && exists(${LOCAL_SCRIPT})
357	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} \
358	    RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
359.endif
360	rm -rf ${CHROOTDIR}/usr/ports
361.if !defined(NOPORTSATALL)
362	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
363	    co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
364.endif
365.if !defined(NODOC)
366	rm -rf ${CHROOTDIR}/usr/doc
367.if defined(EXTDOCDIR)
368	cd ${CHROOTDIR}/usr && cp -R -H ${EXTDOCDIR} doc
369.else
370	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
371	    co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
372.endif
373	if [ -d ${RELEASEDISTFILES}/ ]; then \
374		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
375	else \
376		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
377	fi
378.if !defined(NO_PREFETCHDISTFILES)
379	@cd ${.CURDIR} && ${MAKE} fetch-distfiles
380.endif
381.endif
382.endif
383.if make(rerelease)
384.if !defined(RELEASENOUPDATE)
385.if !defined(RELEASETAG)
386	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
387	    update ${CVSCMDARGS} -P -d -A
388.else
389	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
390	    update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
391.endif
392	rm -f ${CHROOTDIR}/tmp/.world_done 
393.if !defined(NOPORTS)
394	cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
395	    update ${CVSCMDARGS} -P -d
396.endif
397.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
398	for i in ${MINIMALDOCPORTS}; do \
399	    ( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
400		update ${CVSCMDARGS} -P -d ) ; \
401	done
402.endif
403.if !defined(NODOC)
404	cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
405	    update ${CVSCMDARGS} -P -d
406.endif
407.endif
408.endif
409	# Add version information to those things that need it.
410	if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
411		cd ${CHROOTDIR}/usr/src/sys/conf && \
412		mv newvers.sh foo && \
413		sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && \
414		rm foo; \
415	fi
416	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
417	echo "#!/bin/sh"			> ${_MK}
418	echo "set -ex"				>> ${_MK}
419	echo "trap 'umount /dev || true' 0"	>> ${_MK}
420	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${_MK}
421.for var in \
422	AUTO_KEYBOARD_DETECT \
423	BOOT_CONFIG \
424	BUILDNAME \
425	CD_EXTRA_BITS \
426	DISTRIBUTIONS \
427	DOC_LANG \
428	DOMINIMALDOCPORTS \
429	EXTRA_SRC \
430	FIXCRYPTO \
431	FTP_PASSIVE_MODE \
432	FTP_PROXY \
433	HTTP_PROXY \
434	KERNELS \
435	KERNEL_FLAGS \
436	MAKE_ISOS \
437	NOCDROM \
438	NODOC \
439	NOPORTS \
440	NOSHARED \
441	NOSRC \
442	NO_CPU_CFLAGS \
443	NO_CPU_COPTFLAGS \
444	NO_FLOPPIES \
445	NO_SENDMAIL \
446	RELEASETAG \
447	RELNOTES_LANG \
448	TARGET \
449	TARGET_ARCH \
450	WORLD_FLAGS
451.if defined(${var})
452	echo "export ${var}=\"${${var}}\""	>> ${_MK}
453.endif
454.endfor
455	# Don't remove this, or the build will fall over!
456	echo "export RELEASEDIR=${_R}"		>> ${_MK}
457	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${_MK}
458	echo "export MANBUILDCAT=YES"		>> ${_MK}
459	# NB: these may fail if the host is running w/o devfs
460	echo "umount /dev >/dev/null 2>&1 || true" >> ${_MK}
461	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true"	>> ${_MK}
462	echo "/etc/rc.d/ldconfig start"		>> ${_MK}
463	echo "if [ ! -f /tmp/.world_done ]; then" >> ${_MK}
464	echo "	cd /usr/src"			>> ${_MK}
465	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNOCLEAN buildworld && \\" >> ${_MK}
466	echo "	touch /tmp/.world_done"		>> ${_MK}
467	echo "fi"				>> ${_MK}
468	echo "if [ ! -f /tmp/.skip_ports ]; then" >> ${_MK}
469	echo "	echo \">>> make readmes started on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
470	echo "	cd /usr/ports"			>> ${_MK}
471	echo "	make ${PORTREADMES_FLAGS} readmes" >> ${_MK}
472	echo "	touch /tmp/.skip_ports"		>> ${_MK}
473	echo "	echo \">>> make readmes finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
474	echo "fi"				>> ${_MK}
475	echo "cd /usr/src/release"		>> ${_MK}
476	echo "make obj"				>> ${_MK}
477	echo "make \$${_RELTARGET}"		>> ${_MK}
478	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
479	chmod 755 ${_MK}
480.if defined(NOPORTS) || defined(NOPORTREADMES)
481	touch ${CHROOTDIR}/tmp/.skip_ports
482.endif
483	# Ensure md.ko is loaded if md(4) is not statically compiled into 
484	# the kernel
485	-mdconfig 2>/dev/null
486	env -i /usr/sbin/chroot `dirname ${_MK}` /`basename ${_MK}`
487
488clean:
489	rm -rf ${CRUNCH_TARGETS:S/$/_crunch/} release.[0-9] release.10 \
490	    ${EXTRAS}
491
492fetch-distfiles:
493	@for i in ${DOCPORTS}; do \
494		cd ${CHROOTDIR}/usr/ports/$$i && \
495			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
496			WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
497			checksum-recursive ; \
498	done
499
500# Clean out ${_R} and make the directory structure.
501release.1:
502	mkdir -p ${_R}
503	-rm -rf ${_R}/* 2> /dev/null
504	-chflags -R noschg ${_R}/.
505	rm -rf ${_R}/*
506	mkdir ${RD}
507.if !defined(NO_FLOPPIES)
508	mkdir ${RD}/floppies
509.endif
510	mkdir ${RD}/trees
511	mkdir ${RD}/kernels
512	for i in ${DISTRIBUTIONS} special; do \
513		mkdir ${RD}/trees/$$i && \
514		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
515		    -p ${RD}/trees/$$i > /dev/null && \
516		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
517		    -p ${RD}/trees/$$i/usr > /dev/null && \
518		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
519		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
520		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
521		    -p ${RD}/trees/$$i/var > /dev/null ; \
522	done
523	touch ${.TARGET}
524
525# Install the system into the various distributions.
526release.2:
527	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
528	cd ${.CURDIR}/.. && ${CROSSMAKE} distributeworld DISTDIR=${RD}/trees
529	touch ${.TARGET}
530
531# Build and install non-crypto versions of some tools.
532release.3:
533	# Handle some grief caused by the munition braindeadness.
534	cd ${.CURDIR}/..; \
535	${CROSSMAKE} ${WORLD_FLAGS} -DNO_MAKEDB_RUN -DNOCRYPT \
536	    SUBDIR_OVERRIDE="${FIXCRYPTO}" \
537	    buildworld distributeworld DISTDIR=${RD}/trees
538	-chflags -R noschg ${RD}/trees
539	touch ${.TARGET}
540
541# Make and install the generic kernel(s).
542release.4:
543.for kernel in ${KERNELS}
544	cd ${.CURDIR}/..; \
545	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
546	    KERNCONF=${kernel} INSTKERNNAME=${kernel} kernel \
547	    DESTDIR=${RD}/trees/base
548.endfor
549	# Install a standard boot kernel+modules.
550	cd ${.CURDIR}/..; \
551	${CROSSMAKE} ${KERNEL_FLAGS} \
552	    kernel \
553	    DESTDIR=${RD}/trees/base; \
554	cd ${.CURDIR}/..; \
555	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
556	    reinstallkernel -DINSTALL_DEBUG \
557	    DESTDIR=${RD}/trees/base
558	touch ${.TARGET}
559
560# Make and install the three crunched binaries which live on the floppies.
561# You are not supposed to like this :-)
562release.5:
563	rm -rf ${RD}/crunch
564	mkdir -p ${RD}/crunch
565.for j in ${CRUNCH_TARGETS}
566.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
567	rm -rf ${j}_crunch
568	mkdir ${j}_crunch
569	cd ${j}_crunch; ${WMAKEENV} crunchgen -o \
570	    ${.CURDIR}/${TARGET}/${j}_crunch.conf
571	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
572	cd ${.CURDIR}/..; ${BINMAKE} -f Makefile.inc1 _build-tools
573	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk \
574	    CFLAGS="-Os -pipe" -DNO_CPU_CFLAGS all
575	${WMAKEENV} strip -R .comment ${j}_crunch/${j}_crunch
576	mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
577.endif
578.endfor
579	touch ${.TARGET}
580
581#
582# --==## Fix up the distributions. ##==--
583#
584release.6:
585	# Create any "synthetic dists" now.
586	@for i in ${DISTRIBUTIONS}; do \
587		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
588			echo -n "Running $$i dist creation script... "; \
589			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
590			echo "Done."; \
591		fi \
592	done \
593
594	# Remove all the directories we don't need.
595	-cd ${RD}/trees && \
596		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
597	touch ${.TARGET}
598
599#
600# --==## Package up the tarballs from assembled trees ##==--
601#
602release.7:
603	rm -rf ${RD}/dists
604	mkdir -p ${RD}/dists
605	@for i in ${DISTRIBUTIONS} ; \
606	do \
607		if [ -d ${RD}/trees/$${i} ] ; then \
608			cd ${.CURDIR} && $(MAKE) doTARBALL \
609				SD=${RD}/trees/$${i} \
610				TN=$$i TD=$$i ARG="." && \
611			echo "$${i} distribution is finished."; \
612		fi ; \
613	done
614.if !defined(NOPORTS)
615	# XXX: Inline stripped version of doTARBALL
616	@rm -rf ${RD}/dists/ports/ports*
617	@mkdir -p ${RD}/dists/ports
618	@echo rolling ports/ports tarball
619	@tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
620	  ${RD}/dists/ports/ports.tgz -C /usr ports
621	@cp ${.CURDIR}/scripts/ports-install.sh ${RD}/dists/ports/install.sh
622	@(cd ${RD}/dists/ports; \
623	  rm -f CHECKSUM.MD5; \
624	  md5 * > CHECKSUM.MD5)
625	@echo "ports distribution is finished."
626.endif
627	touch ${.TARGET}
628
629
630#
631# --==## Make source dists ##==--
632#
633release.8:
634.if !defined(NOSRC)
635	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
636		TD=src TN=sbase ARG="[A-Z]*"
637	@for i in `cd /usr/src && echo [a-z]*` ; do \
638		if [ -d /usr/src/$$i ] ; then \
639			cd ${.CURDIR} && $(MAKE) doTARBALL \
640				TN=`echo s$$i | tr -d '.' | \
641				    sed -e 's/usr/u/' \
642					-e 's/kerberos5/krb5/'` \
643				SD=/usr/src TD=src ARG="$$i" ; \
644		fi ; \
645	done
646.if defined(EXTRA_SRC)
647	@set ${EXTRA_SRC} && \
648	while [ $$# -ge 2 ] ; do \
649		if [ -d /usr/src/$$1 ] ; then \
650			cd ${.CURDIR} && $(MAKE) doTARBALL \
651				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
652		fi && shift && shift ; \
653	done
654.endif
655	if [ -d ${RD}/dists/crypto ] ; then ( cd ${RD}/dists/src && \
656		if [ -f ssecure.aa ] ; then mv ssecure.* ../crypto ; fi && \
657		if [ -f scrypto.aa ] ; then mv scrypto.* ../crypto ; fi && \
658		if [ -f skrb5.aa ] ; then mv skrb5.* ../crypto ; fi ; \
659		cd ${RD}/dists/crypto; rm -f CHECKSUM.MD5; \
660		md5 * > CHECKSUM.MD5 ) ; fi
661	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
662	@echo "src distribution is finished."
663.endif
664	touch ${.TARGET}
665
666# Complete the bootfd
667#
668# Now, just to get this picture down once and for all:
669#
670# +------------------------------------------------------------------------+
671# |boot.flp                                                                |
672# +-----+-----+------------------------------------------------------------+
673# |boot1|boot2|floppy filesystem "bootfd"                                  |
674# +-----+-----+-+----------------------+---------------------------------+-+
675#               |kernel.gz             |mfsroot.gz                       |
676#               +----------------------+---------------------------------+
677#
678
679release.9:
680.if exists(${.CURDIR}/../sys/boot/${TARGET}/loader)
681	cd ${.CURDIR}/../sys/boot/${TARGET}/loader; \
682	${WMAKE} clean cleandepend; \
683	${WMAKE} -DNOMAN -DNOFORTH all; \
684	${WMAKE} -DNOMAN -DNOFORTH install DESTDIR=${RD}/trees/special
685.endif
686	cp ${RD}/trees/base/etc/disktab /etc
687	rm -rf ${RD}/mfsfd
688	mkdir ${RD}/mfsfd
689	cd ${RD}/mfsfd && \
690		mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help
691	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
692		DIR=${RD}/mfsfd/stand ZIP=false
693	( cd ${RD}/mfsfd && \
694	  for dir in bin sbin ; do \
695		ln -sf /stand $$dir; \
696	  done )
697	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
698.if ${TARGET} == "pc98"
699	cp ${.CURDIR}/../etc/defaults/pccard.conf \
700	    ${RD}/mfsfd/etc/defaults/pccard.conf
701.endif
702	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
703	( for F in defaults/rc.conf netconfig protocols ; do \
704		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
705		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
706	  done )
707	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
708	    ${RD}/trees/base/etc/services | \
709	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
710	    > ${RD}/mfsfd/stand/etc/services
711	grep 'operator' ${RD}/trees/base/etc/group \
712	    > ${RD}/mfsfd/stand/etc/group
713	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
714	ln ${RD}/mfsfd/stand/etc/group ${RD}/mfsfd/etc/group
715	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
716	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
717.if !defined(NODOC)
718	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
719	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
720	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
721	done
722	@for i in ${DIST_DOCS_ARCH_DEP}; do \
723	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
724	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
725	done
726	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT \
727	    ${RD}/mfsfd/stand/help/INSTALL.TXT
728	@mv ${RD}/mfsfd/stand/help/EARLY-ADOPTER.TXT \
729	    ${RD}/mfsfd/stand/help/EARLY.TXT
730.endif
731	-test -f ${.CURDIR}/install.cfg \
732	    && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
733	@mkdir -p ${RD}/mfsfd/boot
734.if ${TARGET_ARCH} != "ia64"
735	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
736.endif
737.if ${TARGET} == "i386" || ${TARGET_ARCH} == "amd64"
738	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
739.endif
740	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
741		tar xf - -C ${RD}/mfsfd/stand
742.if defined(SMALLBOOTSIZE)
743	@mkdir -p ${RD}/mfsroot-small
744.if exists(${.CURDIR}/${TARGET}/drivers-small.conf)
745	@mkdir -p ${RD}/mfsfd/modules
746	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
747	    ${.CURDIR}/${TARGET}/drivers-small.conf \
748	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/modules
749.endif
750	sh -e ${DOFS_SH} ${RD}/mfsroot-small/mfsroot ${RD} ${MNT} \
751	    ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
752	@gzip -9nv ${RD}/mfsroot-small/mfsroot
753	@rm -rf ${RD}/mfsfd/modules
754.endif
755.if exists(${.CURDIR}/${TARGET}/drivers.conf)
756	@mkdir -p ${RD}/mfsfd/modules
757	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 2 \
758	    ${.CURDIR}/${TARGET}/drivers.conf \
759	    ${RD}/trees/base/boot/kernel ${RD}/mfsfd/modules
760.endif
761	@mkdir -p ${RD}/mfsroot
762	sh -e ${DOFS_SH} ${RD}/mfsroot/mfsroot ${RD} ${MNT} \
763	    ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
764	@gzip -9nv ${RD}/mfsroot/mfsroot
765	touch ${.TARGET}
766
767release.10:
768.if !defined(NO_FLOPPIES)
769.if exists(${.CURDIR}/${TARGET}/drivers.conf)
770	@echo "Making the drivers floppy."
771	@rm -rf ${RD}/driversfd
772	@mkdir ${RD}/driversfd
773	@awk -f  ${.CURDIR}/scripts/driver-copy2.awk 3 \
774	    ${.CURDIR}/${TARGET}/drivers.conf \
775	    ${RD}/trees/base/boot/kernel ${RD}/driversfd
776	-@rmdir ${RD}/driversfd
777	if [ -d ${RD}/driversfd ]; then \
778	    sh -e ${DOFS_SH} ${RD}/floppies/drivers.flp ${RD} ${MNT} \
779	        ${DRIVERSIZE} ${RD}/driversfd ${DRIVERINODE} ${DRIVERLABEL}; \
780	    cd ${RD}/driversfd && awk -f  ${.CURDIR}/scripts/driver-desc.awk \
781		*.dsc >> ${RD}/floppies/DRIVERS.TXT; \
782	fi
783.endif
784.if defined(BOOTSIZE)
785	@echo "Making the regular boot floppy."
786	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
787.endif
788.if defined(SMALLBOOTSIZE)
789	@echo "Making the small boot floppy."
790	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
791.endif
792.if defined(BIGBOOTSIZE)
793	@echo "Making the big boot floppy."
794	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
795.endif
796.if defined(FIXITSIZE) || defined(SMALLFIXITSIZE)
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(SMALLFIXITSIZE)
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	    ${SMALLFIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${SMALLFIXITLABEL}
818	@rm -rf ${RD}/fixitfd/stand
819	@mkdir ${RD}/fixitfd/stand
820.endif
821.if defined(FIXITSIZE)
822	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
823	    DIR=${RD}/fixitfd/stand ZIP=false
824	@sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} ${MNT} \
825	    ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
826.endif
827.endif
828# Do our last minute floppies directory setup in a convenient place.
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.endif
837	touch ${.TARGET}
838
839#
840# --==## Setup a suitable ftp-area ##==--
841#
842ftp.1:
843	@echo "Setting up FTP distribution area"
844	@mkdir -p ${FD}
845	-@ln -s . ${FD}/${BUILDNAME}
846.if !defined(NO_FLOPPIES)
847	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
848.endif
849	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
850.if !defined(NODOC)
851	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
852		cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
853		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
854		cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
855		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
856	done
857	@for i in ${DIST_DOCS_ARCH_DEP}; do \
858		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
859		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
860		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
861		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
862	done
863	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
864	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
865	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
866	@mv ${FD}/EARLY-ADOPTER.TXT ${FD}/EARLY.TXT
867	@mv ${FD}/EARLY-ADOPTER.HTM ${FD}/EARLY.HTM
868.endif
869	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
870	touch ${.TARGET}
871
872#
873# --==## Setup a suitable cdrom-area ##==--
874#
875cdrom.1:
876	@echo "Setting up CDROM distribution area"
877	@mkdir -p ${CD_BOOT} ${CD_DISC1} ${CD_DISC2}
878	-@ln -s . ${CD_DISC1}/${BUILDNAME}
879.if !defined(NO_FLOPPIES)
880	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
881.endif
882	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
883	@for i in ${DISTRIBUTIONS} ; \
884	do \
885		if [ -d ${RD}/trees/$${i} ] ; then \
886			chflags -R noschg ${RD}/trees/$${i} || true ; \
887			( cd ${RD}/trees/$${i} && \
888			    find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
889		fi \
890	done
891	@rm -f ${CD_DISC2}/.profile
892	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
893	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
894	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
895.if !defined(NODOC)
896	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
897	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
898	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
899	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
900	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
901	done
902	@for i in ${DIST_DOCS_ARCH_DEP}; do \
903	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
904	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
905	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
906	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
907	done
908	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
909	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
910	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
911	@mv ${CD_DISC1}/EARLY-ADOPTER.TXT ${CD_DISC1}/EARLY.TXT
912	@mv ${CD_DISC1}/EARLY-ADOPTER.HTM ${CD_DISC1}/EARLY.HTM
913.endif
914.if ${TARGET} != "pc98"
915	@echo "Setting up boot area"
916	@rm -f ${CD_DISC2}/boot/loader.conf
917	@cp ${RD}/mfsroot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
918	@echo 'mfsroot_load="YES"' > ${CD_DISC2}/boot/loader.conf
919	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC2}/boot/loader.conf
920	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC2}/boot/loader.conf
921.if defined(CD_BOOT)
922	@cp -Rp ${CD_DISC2}/boot ${CD_BOOT}
923.if defined(MINIROOT)
924	@mkdir -p ${FD}/miniroot
925	@sh -e ${DOFS_SH} ${FD}/miniroot/miniroot.ufs \
926	    ${RD} ${MNT} 0 ${CD_BOOT} 8192 auto
927	@gzip -9v ${FD}/miniroot/miniroot.ufs
928.endif
929.endif
930	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
931.if ${TARGET} == "i386" && defined(EMUL_BOOT) && !defined(NO_FLOPPIES)
932	# In case bootable ISO with floppy emulation is desired.
933.if defined(CD_BOOT)
934	@mkdir -p ${CD_BOOT}/floppies
935	@cp ${CD_DISC1}/floppies/boot.flp ${CD_BOOT}/floppies
936.endif
937	@mkdir -p ${CD_DISC2}/floppies
938	@cp ${CD_DISC1}/floppies/boot.flp ${CD_DISC2}/floppies
939.endif
940.endif
941	touch ${.TARGET}
942
943iso.1:
944.if exists(${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh)
945	@echo "Creating ISO images..."
946.if defined(CD_BOOT)
947	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
948	    fbsd_bootonly \
949	    ${CD}/${BUILDNAME}-${TARGET}-bootonly.iso ${CD_BOOT}
950.endif
951	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
952	    fbsd_miniinst \
953	    ${CD}/${BUILDNAME}-${TARGET}-miniinst.iso ${CD_DISC1}
954	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
955	    fbsd_livefs \
956	    ${CD}/${BUILDNAME}-${TARGET}-disc2.iso ${CD_DISC2}
957.if defined(CD_EXTRA_BITS)
958	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
959	    fbsd_boot \
960	    ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} \
961	    ${CD_EXTRA_BITS} \
962	    && false
963.endif
964	@(cd ${CD} && md5 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.MD5)
965	touch ${.TARGET}
966.else
967	@echo "Do not know how to create an ISO for ${TARGET_ARCH}."
968.endif
969
970#
971# --==## Documentation Project files such as the Handbook and FAQ ##==--
972#
973doc.1:
974	@echo "Making docs..."
975	@for i in ${DOCPORTS}; do \
976	    cd /usr/ports/$$i && \
977	    env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \
978		make all install clean BATCH=yes WITHOUT_X11=yes JADETEX=no \
979		WITHOUT_PYTHON=yes FORCE_PKG_REGISTER=yes; \
980	done
981	@cd /usr/doc && make all install 'FORMATS=html html-split txt' \
982	    INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc
983	touch ${.TARGET}
984
985#
986# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
987#
988doc.2:
989	@echo "Making release documentation..."
990	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' \
991	    INSTALL_COMPRESSED='' DOCDIR=${RND}
992	touch ${.TARGET}
993
994# Various "subroutine" and other supporting targets.
995
996# RD=
997# SD=
998# TD=
999# ARG=
1000doTARBALL:
1001.if !defined(SD)
1002	@echo "SD undefined in doTARBALL" && exit 1
1003.endif
1004.if !defined(TD)
1005	@echo "TD undefined in doTARBALL" && exit 1
1006.endif
1007.if !defined(ARG)
1008	@echo "ARG undefined in doTARBALL" && exit 1
1009.endif
1010	@rm -rf ${RD}/dists/${TD}/${TN}*
1011	@mkdir -p ${RD}/dists/${TD}
1012	@( cd ${SD} && \
1013		tn=`echo ${TN} | tr 'A-Z' 'a-z' | cut -c1-8` && \
1014		echo rolling ${TD}/$$tn tarball &&\
1015		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
1016		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
1017		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn \
1018		    > ${RD}/dists/${TD}/$$tn.inf && \
1019		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
1020			cp -p ${.CURDIR}/scripts/$${TD}-install.sh \
1021			    ${RD}/dists/${TD}/install.sh; \
1022		fi && \
1023		if [ "${SD}" != "/usr/src" ]; then \
1024			mtree -c -i -p ${SD}/${ARG} \
1025			  -k gname,md5digest,mode,nlink,uname,size,link,type \
1026			  > ${RD}/dists/${TD}/$$tn.mtree ; \
1027		else \
1028			true; \
1029		fi; \
1030		( cd ${RD}/dists/${TD}; \
1031		rm -f CHECKSUM.MD5; \
1032		md5 * > CHECKSUM.MD5 ) \
1033	)
1034
1035doRELEASE: release.1 release.2 release.3 ${DOCREL} release.4 release.5 \
1036    release.6 release.7 release.8 release.9 release.10 ${EXTRAS}
1037	@echo "Release done"
1038
1039floppies:
1040	@rm -f release.5 release.9 release.10
1041	@cd ${.CURDIR} && ${MAKE} release.5 release.9 release.10
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# --==## Put a filesystem into a BOOTMFS kernel ##==--
1072#
1073doMFSKERN:
1074	@echo "Running ${.TARGET} for ${FSIMAGE}"
1075	@rm -f ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
1076	@cd ${.CURDIR}/../sys/${TARGET}/conf; \
1077	if [ -r ${.CURDIR}/${TARGET}/dokern.sh ]; then \
1078	    sh ${.CURDIR}/${TARGET}/dokern.sh ${FDSIZE}; \
1079	else \
1080	    sed -e 's/ident.*GENERIC/ident		BOOTMFS/g'; \
1081	fi < GENERIC > BOOTMFS; \
1082	[ -r GENERIC.hints ] && cp GENERIC.hints BOOTMFS.hints
1083.if defined(FDSIZE) && ${FDSIZE} == "SMALL" && \
1084    exists(${.CURDIR}/${TARGET}/drivers-small.conf)
1085	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
1086	    ${.CURDIR}/${TARGET}/drivers-small.conf \
1087	    ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
1088.elif exists(${.CURDIR}/${TARGET}/drivers.conf)
1089	@awk -f ${.CURDIR}/scripts/driver-remove.awk \
1090	    ${.CURDIR}/${TARGET}/drivers.conf \
1091	    ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
1092.endif
1093	cd ${.CURDIR}/..; \
1094	KERNEL_KO=BOOTMFS KODIR= \
1095	    ${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES -DNO_KERNELCLEAN \
1096	    KERNCONF=BOOTMFS COPTFLAGS="-Os -pipe" -DNO_CPU_COPTFLAGS \
1097	    buildkernel reinstallkernel \
1098	    DESTDIR=${RD}/kernels
1099	[ -r ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ] && \
1100	    cp ${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS.hints ${RD}/kernels
1101	@rm -rf ${RD}/image.${FSIMAGE}
1102	@mkdir ${RD}/image.${FSIMAGE}
1103	@cd ${RD}/kernels && \
1104	    (chflags noschg BOOTMFS || true) && \
1105	    ${WMAKEENV} strip -R .comment BOOTMFS && \
1106	    cp BOOTMFS BOOTMFS.${FSIMAGE} && \
1107	    [ -r BOOTMFS.hints ] && mv BOOTMFS.hints BOOTMFS.${FSIMAGE}.hints
1108	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
1109	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
1110	@mkdir -p ${RD}/image.${FSIMAGE}/boot
1111.if ${TARGET} == "i386"
1112	@${WMAKEENV} kgzip -v -l ${RD}/trees/base/usr/lib/kgzldr.o -o \
1113	    ${RD}/image.${FSIMAGE}/boot/loader ${RD}/trees/special/boot/loader
1114.else
1115	@cp ${RD}/trees/special/boot/loader ${RD}/image.${FSIMAGE}/boot
1116.endif
1117	@[ -r ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints ] && \
1118	  sed -e '/^hint/s/^/set /' -e '/^#/d' \
1119	      ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints > \
1120	      ${RD}/image.${FSIMAGE}/boot/device.hints && \
1121	  echo "include /boot/device.hints" \
1122	      > ${RD}/image.${FSIMAGE}/boot/loader.rc
1123	@echo "load /kernel" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1124.if !defined(FDSIZE) || ${FDSIZE} != "BIG"
1125	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1126	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1127	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1128.endif
1129	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1130	@echo "set hint.acpi.0.disabled=1" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1131	@if [ -r ${RD}/floppies/drivers.flp ]; then \
1132		echo "set driver_floppy=YES" >> ${RD}/image.${FSIMAGE}/boot/loader.rc; \
1133	fi
1134	@echo "set module_path=\"/modules;/dist\"" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1135	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1136	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
1137.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
1138	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
1139.endif
1140	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
1141	@rm -f ${RD}/floppies/${FSIMAGE}.flp
1142.if defined(FDSIZE) && ${FDSIZE} == "BIG"
1143	@cp ${RD}/mfsroot/mfsroot.gz ${RD}/image.${FSIMAGE}
1144	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp ${RD} ${MNT} \
1145	    ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} ${BOOTINODE} ${BIGBOOTLABEL}
1146.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
1147	sh -e ${DOFS_SH} ${RD}/floppies/mfsroot-small.flp ${RD} ${MNT} \
1148	    ${SMALLBOOTSIZE} ${RD}/mfsroot-small/mfsroot.gz ${BOOTINODE} \
1149	    ${SMALLBOOTLABEL}
1150	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp ${RD} ${MNT} \
1151	    ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} ${BOOTINODE} \
1152	    ${SMALLBOOTLABEL}
1153.else
1154	sh -e ${DOFS_SH} ${RD}/floppies/mfsroot.flp ${RD} ${MNT} \
1155	    ${BOOTSIZE} ${RD}/mfsroot/mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
1156	sh -e ${DOFS_SH} ${RD}/floppies/${FSIMAGE}.flp ${RD} ${MNT} \
1157	    ${BOOTSIZE} ${RD}/image.${FSIMAGE} ${BOOTINODE} ${BOOTLABEL}
1158.endif
1159	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1160
1161.include <bsd.obj.mk>
1162