Makefile revision 133952
1166768Sbmah# $FreeBSD: head/release/Makefile 133952 2004-08-18 11:11:46Z grehan $
2166768Sbmah#
3166768Sbmah# make release [BUILDNAME=somename] CHROOTDIR=/some/dir CVSROOT=/cvs/dir \
4166768Sbmah#     [RELEASETAG=tag]
5166768Sbmah#
6166768Sbmah# Where "/some/dir" is the pathname of a directory on a some filesystem with
7166768Sbmah# at least 1000MB of free space, "somename" is what you want the release to
8166768Sbmah# call itself, "/cvs/dir" is where our source repo resides and, optionally,
9166768Sbmah# which CVS "tag" name should be used when checking out the sources to build
10166768Sbmah# the release (default is HEAD).
11166768Sbmah#
12166768Sbmah# Please note: the md(4) driver must be present in the kernel
13166768Sbmah# (either by being compiled in or available as a kld(4) module),
14166768Sbmah# otherwise the target 'release.8' and possibly others will fail.
15183626Ssimon#
16183626Ssimon# Note: If you add options to this file, please keep release(7) updated!
17166768Sbmah#
18183626Ssimon# Set these, release builder!
19166768Sbmah#
20183626Ssimon# Fixed version:
21166768Sbmah#BUILDNAME=5.2-RELEASE
22183626Ssimon#
23183626Ssimon# Automatic SNAP versioning:
24183626SsimonDATE != date +%Y%m%d
25183626SsimonBASE = 5.2
26183626SsimonBUILDNAME?=${BASE}-${DATE}-SNAP
27183626Ssimon#
28183626Ssimon#CHROOTDIR=/junk/release
29183626Ssimon# If this is a -stable snapshot, then set
30183626Ssimon#RELEASETAG=RELENG_4
31183626Ssimon#
32191511Sblackend# To test a release with a source tree containing patches and
33227742Sbrueffer# other work. This tree will get copied instead of getting the
34227742Sbrueffer# src/ tree from a CVS checkout. For "rerelease", this will NOT
35229977Sbrueffer# be copied; cvs update will be used instead.
36183626Ssimon#EXTSRCDIR=/usr/src
37183626Ssimon#
38166771Sbmah# To add other options to the CVS subcommands (co,up), set
39183626Ssimon#CVSCMDARGS="-D '01/01/2002 00:00:00 UTC'"
40183626Ssimon#
41183626Ssimon# To add other options to the CVS command, set
42208459Smarius#CVSARGS="-lfq"
43183626Ssimon#
44183626Ssimon# To prefix the cvs command
45183626Ssimon#CVSPREFIX="/usr/bin/time"
46183626Ssimon#
47183626Ssimon# Where the CVS repository is
48183626Ssimon#CVSROOT="/home/ncvs"
49172094Sbmah#
50183626Ssimon# Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we
51172094Sbmah# are building an official release.  Otherwise, we are building for
52183626Ssimon# a branch.
53183626Ssimon.if defined(RELEASETAG)
54166768SbmahISRELEASE!=	expr "${RELEASETAG}" : '^RELENG_.*_RELEASE$$' || true
55183626Ssimon.if ${ISRELEASE} != 0
56183626Ssimon# Convert "RELENG_ver_RELEASE" to "RELEASE_ver" for ports and doc trees.
57183626SsimonAUXRELEASETAG!=	echo ${RELEASETAG} | sed -e 's/^RELENG_/RELEASE_/' -e 's/_RELEASE$$//'
58183626SsimonDOCRELEASETAG?=		${AUXRELEASETAG}
59183626SsimonPORTSRELEASETAG?=	${AUXRELEASETAG}
60183626Ssimon.endif
61166768Sbmah.endif
62183626Ssimon
63183626Ssimon# If you want to pass flags to the world build such as -j X, use
64166768Sbmah# WORLD_FLAGS.  Similarly, you can specify make flags for kernel
65183626Ssimon# builds via KERNEL_FLAGS.
66183626Ssimon# Similarly, you can specify make flags for make readmes via PORTREADMES_FLAGS.
67183626Ssimon#WORLD_FLAGS=-j4
68166768Sbmah#KERNEL_FLAGS=-j4
69183626Ssimon#PORTREADMES_FLAGS=-j4
70183626Ssimon
71166770SbmahTARGET_ARCH?=	${MACHINE_ARCH}
72183626Ssimon.if ${TARGET_ARCH} == ${MACHINE_ARCH}
73183626SsimonTARGET?=	${MACHINE}
74183626Ssimon.else
75183626SsimonTARGET?=	${TARGET_ARCH}
76183626Ssimon.endif
77183626SsimonCROSSENV=	TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
78166770SbmahCROSSMAKE=	${MAKE} ${CROSSENV}
79183626SsimonNATIVEMAKE=	${MAKE} TARGET_ARCH=${MACHINE_ARCH} TARGET=${MACHINE}
80183626Ssimon
81183626Ssimon# If you are using a local CVS repository with components stored in 
82183626Ssimon# non-standard modules, override these on the make commandline or
83183626Ssimon# in the environment.
84166770SbmahRELEASESRCMODULE?=	src
85183626SsimonRELEASEDOCMODULE?=	doc
86183626SsimonRELEASEPORTSMODULE?=	ports
87166770Sbmah
88183626Ssimon# Uncomment this to disable the doc.1 target.  Docs normally require
89183626Ssimon# the ports tree, so NOPORTS can be set together with NODOC in order
90183626Ssimon# to have neither ports or docs.  If only NOPORTS is set to YES, but
91183626Ssimon# docs are still desired, the DOMINIMALDOCPORTS logic below will only
92166770Sbmah# install the ports that are minimally required for the docs.  This is
93183626Ssimon# intended as a compromise, less disk space is required than for using
94183626Ssimon# the entire ports collection (and much less time due to the huge number
95183626Ssimon# of directories it would create), but still quite a bit as well as some
96166770Sbmah# CPU cycles (some of the programs are C++, and things like ghostscript
97183626Ssimon# belong to the required ports nevertheless).
98186204Smurray#
99186208Smurray# Setting this also disables building of release note documentation
100183626Ssimon# (RELNOTESng).
101166770Sbmah#NODOC=  YES
102183626Ssimon#NOPORTS=  YES
103186204Smurray
104186204Smurray# Modify this definition if you want the release notes 
105186204Smurray# and other release documentation in a language other than English.
106186204SmurrayRELNOTES_LANG?=	en_US.ISO8859-1
107183626Ssimon
108186204Smurray# As an alternative to installing the entire ports collection (which
109186204Smurray# can take a huge amount of time, in particular on slower disks),
110186204Smurray# setting ${MINIMALDOCPORTS} allows to install and build just those
111186204Smurray# ports that are really required for getting the docs up & running.
112186204Smurray.if defined(NOPORTS) && !defined(NODOC)
113186204SmurrayDOMINIMALDOCPORTS=	YES
114186204Smurray.include "Makefile.inc.docports"
115186204SmurrayRELEASEPORTSMODULE=	${MINIMALDOCPORTS}
116186204Smurray.endif
117186204Smurray
118186204Smurray# Make changing names of disc1/disc2 CD's possible.
119186204SmurrayDISC1_LABEL?=	fbsd_miniinst
120186204SmurrayDISC1_NAME?=	miniinst
121186204SmurrayDISC2_LABEL?=	fbsd_livefs
122186204SmurrayDISC2_NAME?=	disc2
123186204Smurray
124186204Smurray# Helper variable
125186204Smurray.if defined(NOPORTS)
126186204Smurray.if !defined(DOMINIMALDOCPORTS) || ${DOMINIMALDOCPORTS} != "YES"
127186204SmurrayNOPORTSATALL=	YES
128186204Smurray.endif
129186204Smurray.endif
130186204Smurray
131186204Smurray# By default, documentation (Handbook, FAQ, etc.) is built for all
132183626Ssimon# the languages.  To speed up building, set the DOC_LANG to just
133166770Sbmah# the languages you need.  (The language for the release notes is
134183626Ssimon# controlled by the RELNOTES_LANG variable above.)
135183626Ssimon#DOC_LANG=	en_US.ISO8859-1
136183626SsimonDOCPORTS=	textproc/docproj
137183626Ssimon# Set this to wherever the distfiles required by release procedures.
138183626Ssimon.if defined(DOCDISTFILES)
139166770Sbmah# Respect DOCDISTFILES which is used before.
140186242SmurrayRELEASEDISTFILES?=	${DOCDISTFILES}
141183626Ssimon.else
142183626SsimonRELEASEDISTFILES?=	${.CURDIR}/../../ports/distfiles
143166770Sbmah.endif
144183626Ssimon# Set this to 1 if you want -P to be used for automatic keyboard detection
145183626Ssimon# on the boot floppy.  WARNING: Breaks on some Athlon (K7) motherboards.
146183626SsimonAUTO_KEYBOARD_DETECT?= 0
147183626Ssimon
148183626Ssimon.if !defined(NODOC)
149166770SbmahDIST_DOCS_ARCH_INDEP=	readme errata early-adopter
150183626SsimonDIST_DOCS_ARCH_DEP=	installation relnotes hardware
151183626Ssimon.endif
152183626Ssimon
153183626Ssimon# Things which without too much trouble can be considered variables
154166770Sbmah# BASE_DISTS are special in that they get full /etc installation sets.
155183626Ssimon#
156166770Sbmah.if ${TARGET_ARCH} == "i386"
157183626SsimonCOMPAT_DISTS?=	compat1x compat20 compat21 compat22 compat3x compat4x
158183626Ssimon.elif ${TARGET_ARCH} == "alpha"
159166770SbmahCOMPAT_DISTS?=	compat4x
160183626Ssimon.endif
161183626SsimonOTHER_DISTS?=	catpages manpages games proflibs dict info doc
162183626SsimonBASE_DISTS?=	base
163183626SsimonDISTRIBUTIONS?=	${BASE_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS}
164183626Ssimon
165183626Ssimon# mountpoint for filesystems.
166166770SbmahMNT=			/mnt
167183626Ssimon
168183626Ssimon# Various floppy image parameters.
169183626Ssimon#
170183626Ssimon
171183626Ssimon.undef MAKE_FLOPPIES
172183626Ssimon.if ${TARGET_ARCH} == "i386"
173183626SsimonMAKE_FLOPPIES=		true
174183626Ssimon.if ${TARGET} == "pc98"
175183626SsimonSMALLFLOPPYSIZE=	1200
176183626SsimonSMALLFLOPPYSPLITSIZE=	1152
177183626SsimonSMALLFLOPPYLABEL=	fd1200
178183626SsimonSPLIT_MFSROOT=
179166770Sbmah.endif
180183626SsimonFLOPPYSIZE=		1440
181183626SsimonFLOPPYSPLITSIZE=	1392
182183626SsimonFLOPPYINODE=		40000
183183626SsimonFLOPPYLABEL=		fd1440
184183626SsimonBOOTINODE=		80000
185166770SbmahMFSSIZE=		4320
186183626SsimonMFSINODE=		8000
187183626SsimonMFSLABEL=		minimum3
188183626Ssimon.elif ${TARGET_ARCH} == "alpha"
189183626SsimonMAKE_FLOPPIES=		true
190166770SbmahFLOPPYSIZE=		1440
191183626SsimonFLOPPYSPLITSIZE=	1392
192183626SsimonFLOPPYINODE=		40000
193183626SsimonFLOPPYLABEL=		fd1440
194183626SsimonBOOTINODE=		80000
195183626SsimonMFSSIZE=		4320
196183626SsimonMFSINODE=		8000
197183626SsimonMFSLABEL=		auto
198183626SsimonSPLIT_MFSROOT=
199183626Ssimon.elif ${TARGET_ARCH} == "sparc64"
200183626SsimonDISKLABEL=		sunlabel
201224529SavgMFSSIZE=		4096
202224528SavgMFSINODE=		8192
203224528SavgMFSLABEL=		auto
204166770SbmahMINIROOT=
205183626Ssimon.elif ${TARGET_ARCH} == "ia64"
206183626SsimonMFSSIZE=		8192
207183626SsimonMFSINODE=		8192
208183626SsimonMFSLABEL=		auto
209183626Ssimon.elif ${TARGET_ARCH} == "amd64"
210183626SsimonMFSSIZE=		4096
211183626SsimonMFSINODE=		8192
212166770SbmahMFSLABEL=		auto
213183626Ssimon.elif ${TARGET_ARCH} == "powerpc"
214183626SsimonDISKLABEL=		""
215183626SsimonMFSSIZE=		4096
216183626SsimonMFSINODE=		8192
217183626SsimonMFSLABEL=		auto
218183626Ssimon.endif
219183626Ssimon.if defined(NO_FLOPPIES)
220183626Ssimon.undef MAKE_FLOPPIES
221166770Sbmah.endif
222183626Ssimon
223183626Ssimon.if exists(/sbin/bsdlabel)
224183626SsimonDISKLABEL?=		bsdlabel
225183626Ssimon.else
226183626SsimonDISKLABEL?=		disklabel
227183626Ssimon.endif
228183626Ssimon
229183626SsimonZIPNSPLIT=		gzip --no-name -9 -c | split -b 1392k -
230183626Ssimon
231166770Sbmah# Things which may get you into trouble if you change them
232183626SsimonMTREEFILES=		${.CURDIR}/../etc/mtree
233166770Sbmah_R?=			/R
234183626SsimonRD=			${_R}/stage
235183626SsimonRND=			${RD}/release.doc
236183626SsimonFD=			${_R}/ftp
237183626SsimonCD=			${_R}/cdrom
238166770Sbmah.if ${TARGET} != "pc98"
239183626SsimonCD_BOOT=		${CD}/bootonly
240183626Ssimon.endif
241183626SsimonCD_DISC1=		${CD}/disc1
242183626SsimonCD_DISC2=		${CD}/disc2
243183626Ssimon_MK?=			${CHROOTDIR}/mk
244183626Ssimon
245183626Ssimon# Where the bootstrap ports (see DOCPORTS) get installed.
246183626SsimonLOCALDIR=		/usr/local/bin
247183626Ssimon
248183626Ssimon.if ${TARGET} != ${MACHINE} && ${DISKLABEL} == "bsdlabel"
249183626SsimonDOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ${TARGET}
250183626Ssimon.else
251166770SbmahDOFS_SH=	${.CURDIR}/scripts/doFS.sh ${DISKLABEL} ""
252183626Ssimon.endif
253183626Ssimon
254166770SbmahCRUNCH_TARGETS=	boot
255183626Ssimon.if ${TARGET_ARCH} == "i386"
256183626SsimonCRUNCH_TARGETS+=fixit
257183626Ssimon.if ${TARGET} == "pc98"
258183626SsimonCRUNCH_TARGETS+=fixit-small
259183626Ssimon.endif
260166770Sbmah.endif
261183626Ssimon
262166770Sbmah.if defined(MAKE_FLOPPIES)
263183626SsimonEXTRAS= floppies.1
264183626Ssimon.if ${TARGET_ARCH} == "i386"
265183626SsimonEXTRAS+= floppies.2
266183626Ssimon.endif
267166770SbmahEXTRAS+= floppies.3
268183626Ssimon.endif
269183626SsimonEXTRAS+= ftp.1
270183626Ssimon.if !defined(NOCDROM)
271166770SbmahEXTRAS+= cdrom.1
272183626Ssimon.if defined(MAKE_ISOS)
273183626SsimonEXTRAS+= iso.1
274183626Ssimon.endif
275183626Ssimon.if ${TARGET} == "pc98"
276166770SbmahBOOTABLE=
277183626Ssimon.else
278183626SsimonBOOTABLE="-b"
279171814Sbmah.endif
280183626Ssimon.endif
281183626Ssimon
282183626Ssimon.if !defined(NODOC)
283183626SsimonDOCREL= doc.1 doc.2
284183626Ssimon.endif
285183626Ssimon
286183626Ssimon.if !make(release) && !make(rerelease)
287183626SsimonBINMAKE!=	cd ${.CURDIR}/..; ${MAKE} -V BINMAKE
288166770SbmahWMAKEENV!=	cd ${.CURDIR}/..; \
289183626Ssimon		${BINMAKE} ${CROSSENV} -f Makefile.inc1 -V WMAKEENV
290183626SsimonWMAKE=		${WMAKEENV} ${BINMAKE}
291166770Sbmah.endif
292183626Ssimon
293183626SsimonCVS_SRCARGS=	-P
294183626Ssimon.if defined(RELEASETAG)
295183626SsimonCVS_SRCARGS+=	-r ${RELEASETAG}
296166770Sbmah.endif
297183626Ssimon
298183626SsimonCVS_DOCARGS=	-P
299183626Ssimon.if defined(DOCRELEASETAG)
300166770SbmahCVS_DOCARGS+=	-r ${DOCRELEASETAG}
301183626Ssimon.endif
302183626Ssimon
303166770SbmahCVS_PORTSARGS=	-P
304183626Ssimon.if defined(PORTSRELEASETAG)
305183626SsimonCVS_PORTSARGS+=	-r ${PORTSRELEASETAG}
306183626Ssimon.endif
307166770Sbmah
308183626SsimonWORLDDIR?=	${.CURDIR}/..
309183626Ssimon
310183626Ssimonrelease rerelease:
311166770Sbmah.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
312183626Ssimon	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
313183626Ssimon.endif
314183626Ssimon.if defined(NOPORTSATALL) && !defined(NODOC)
315183626Ssimon	@echo "Ports are required for building the docs.  Either set NODOC or"
316183626Ssimon	@echo "unset NOPORTS, or set at least DOMINIMALDOCPORTS to YES!"
317166770Sbmah	@exit 1
318183626Ssimon.endif
319183626Ssimon.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
320166770Sbmah.for p in ${LOCAL_PATCHES}
321203527Snwhitehorn.if !exists(${p})
322203527Snwhitehorn	@echo "The patch file ${p} does not exist!"
323203527Snwhitehorn	@exit 1
324203527Snwhitehorn.endif
325203527Snwhitehorn.endfor
326203527Snwhitehorn.endif
327203527Snwhitehorn.if defined(LOCAL_SCRIPT) && !exists(${LOCAL_SCRIPT})
328203527Snwhitehorn	@echo "The local script ${LOCAL_SCRIPT} does not exist!"
329203527Snwhitehorn	@exit 1
330203527Snwhitehorn.endif
331208461Snwhitehorn.if make(release)
332208461Snwhitehorn.if exists(${CHROOTDIR})
333203527Snwhitehorn# The first command will fail on a handful of files that have their schg
334203527Snwhitehorn# flags set.  But it greatly speeds up the next two commands.
335203527Snwhitehorn	# NB: clear any vestigal devfs mount, just in case
336208461Snwhitehorn	-umount ${CHROOTDIR}/dev > /dev/null 2>&1
337203527Snwhitehorn	-rm -rf ${CHROOTDIR} 2>/dev/null
338203527Snwhitehorn	-chflags -R noschg ${CHROOTDIR}/.
339208461Snwhitehorn	-rm -rf ${CHROOTDIR}
340208461Snwhitehorn.endif
341208461Snwhitehorn	mkdir -p ${CHROOTDIR}
342208461Snwhitehorn	@echo ">>> make release for ${TARGET} started on `LC_ALL=C TZ=GMT date`"
343208461Snwhitehorn	cd ${WORLDDIR} && ${NATIVEMAKE} -DNOGAMES -DNOHTML -DNOINFO -DNOMAN \
344208461Snwhitehorn	    -DNOPROFILE installworld DESTDIR=${CHROOTDIR}
345203527Snwhitehorn	cd ${WORLDDIR}/etc && ${NATIVEMAKE} distribution DESTDIR=${CHROOTDIR}
346203527Snwhitehorn	if [ -f /etc/resolv.conf ]; then \
347203527Snwhitehorn		cp -p /etc/resolv.conf ${CHROOTDIR}/etc; \
348203527Snwhitehorn	fi
349203527Snwhitehorn.if defined(EXTLOCALDIR)
350203527Snwhitehorn	rm -rf ${CHROOTDIR}/usr/local
351208461Snwhitehorn	cd ${CHROOTDIR}/usr && cp -R -H ${EXTLOCALDIR} local
352203527Snwhitehorn.endif
353203527Snwhitehorn	rm -rf ${CHROOTDIR}/usr/src
354208461Snwhitehorn.if defined(EXTSRCDIR)
355203527Snwhitehorn	cd ${CHROOTDIR}/usr && \
356203527Snwhitehorn	    cp -R -H ${EXTSRCDIR} src
357208461Snwhitehorn.else
358208461Snwhitehorn	cd ${CHROOTDIR}/usr && \
359208461Snwhitehorn	    ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
360208461Snwhitehorn	    co ${CVSCMDARGS} ${CVS_SRCARGS} ${RELEASESRCMODULE}
361208461Snwhitehorn.endif
362208461Snwhitehorn.if defined(LOCAL_PATCHES) && !empty(LOCAL_PATCHES)
363203527Snwhitehorn.for p in ${LOCAL_PATCHES}
364203527Snwhitehorn	patch -d ${CHROOTDIR}/usr/${RELEASESRCMODULE} ${PATCH_FLAGS} < ${p}
365203527Snwhitehorn.endfor
366203527Snwhitehorn.endif
367203527Snwhitehorn.if defined(LOCAL_SCRIPT)
368203527Snwhitehorn	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} \
369203527Snwhitehorn	    RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
370203527Snwhitehorn.endif
371203527Snwhitehorn	rm -rf ${CHROOTDIR}/usr/ports
372203527Snwhitehorn.if !defined(NOPORTSATALL)
373203527Snwhitehorn	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
374203527Snwhitehorn	    co ${CVSCMDARGS} ${CVS_PORTSARGS} ${RELEASEPORTSMODULE}
375203527Snwhitehorn.endif
376203527Snwhitehorn.if !defined(NODOC)
377203527Snwhitehorn	rm -rf ${CHROOTDIR}/usr/doc
378183626Ssimon.if defined(EXTDOCDIR)
379166770Sbmah	cd ${CHROOTDIR}/usr && cp -R -H ${EXTDOCDIR} doc
380183626Ssimon.else
381183626Ssimon	cd ${CHROOTDIR}/usr && ${CVSPREFIX} cvs -R ${CVSARGS} -d ${CVSROOT} \
382166770Sbmah	    co ${CVSCMDARGS} ${CVS_DOCARGS} ${RELEASEDOCMODULE}
383183626Ssimon.endif
384208511Smarius	if [ -d ${RELEASEDISTFILES}/ ]; then \
385208459Smarius		cp -rp ${RELEASEDISTFILES} ${CHROOTDIR}/usr/ports/distfiles; \
386183626Ssimon	else \
387183626Ssimon		mkdir -p ${CHROOTDIR}/usr/ports/distfiles; \
388183626Ssimon	fi
389166770Sbmah.if !defined(NO_PREFETCHDISTFILES)
390183626Ssimon	@cd ${.CURDIR} && ${MAKE} fetch-distfiles
391183626Ssimon.endif
392166770Sbmah.endif
393191491Smarius.endif
394191491Smarius.if make(rerelease)
395208511Smarius.if !defined(RELEASENOUPDATE)
396208511Smarius.if !defined(RELEASETAG)
397191491Smarius	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
398191491Smarius	    update ${CVSCMDARGS} -P -d -A
399191491Smarius.else
400166770Sbmah	cd ${CHROOTDIR}/usr/src && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
401183626Ssimon	    update ${CVSCMDARGS} -P -d -r ${RELEASETAG}
402183626Ssimon.endif
403183626Ssimon	rm -f ${CHROOTDIR}/tmp/.world_done 
404183626Ssimon.if !defined(NOPORTS)
405166770Sbmah	cd ${CHROOTDIR}/usr/ports && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
406191511Sblackend	    update ${CVSCMDARGS} -P -d
407172094Sbmah.endif
408183626Ssimon.if defined(DOMINIMALDOCPORTS) && ${DOMINIMALDOCPORTS} == "YES"
409183626Ssimon	for i in ${MINIMALDOCPORTS}; do \
410208459Smarius	    ( cd ${CHROOTDIR}/usr/$$i && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
411208459Smarius		update ${CVSCMDARGS} -P -d ) ; \
412208459Smarius	done
413208459Smarius.endif
414183626Ssimon.if !defined(NODOC)
415183626Ssimon	cd ${CHROOTDIR}/usr/doc && ${CVSPREFIX} cvs -R ${CVSARGS} -q \
416166770Sbmah	    update ${CVSCMDARGS} -P -d
417183626Ssimon.endif
418183626Ssimon.endif
419183626Ssimon.endif
420166770Sbmah	# Add version information to those things that need it.
421166770Sbmah	if [ ! -f ${CHROOTDIR}/tmp/.world_done ]; then \
422208459Smarius		cd ${CHROOTDIR}/usr/src/sys/conf && \
423191491Smarius		mv newvers.sh foo && \
424191491Smarius		sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && \
425191491Smarius		rm foo; \
426183626Ssimon	fi
427183626Ssimon	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
428183626Ssimon	echo "#!/bin/sh"			> ${_MK}
429183626Ssimon	echo "set -ex"				>> ${_MK}
430183626Ssimon	echo "trap 'umount /dev || true' 0"	>> ${_MK}
431183626Ssimon	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${_MK}
432183626Ssimon.for var in \
433183626Ssimon	AUTO_KEYBOARD_DETECT \
434183626Ssimon	BOOT_CONFIG \
435183626Ssimon	BUILDNAME \
436183626Ssimon	CD_EXTRA_BITS \
437183626Ssimon	DISC1_LABEL \
438172094Sbmah	DISC1_NAME \
439166770Sbmah	DISC2_LABEL \
440183626Ssimon	DISC2_NAME \
441183626Ssimon	DISTRIBUTIONS \
442208459Smarius	DOC_LANG \
443208459Smarius	DOMINIMALDOCPORTS \
444208459Smarius	EXTRA_SRC \
445208459Smarius	FTP_PASSIVE_MODE \
446208459Smarius	FTP_PROXY \
447183626Ssimon	HTTP_PROXY \
448183626Ssimon	KERNELS \
449183626Ssimon	KERNEL_FLAGS \
450183626Ssimon	MAKE_FLOPPIES \
451183626Ssimon	MAKE_ISOS \
452183626Ssimon	NOCDROM \
453183626Ssimon	NODOC \
454183626Ssimon	NOPORTS \
455208511Smarius	NOSHARED \
456183626Ssimon	NOSRC \
457183626Ssimon	NO_CPU_CFLAGS \
458183626Ssimon	NO_CPU_COPTFLAGS \
459208511Smarius	NO_FLOPPIES \
460183626Ssimon	NO_SENDMAIL \
461183626Ssimon	RELEASETAG \
462183626Ssimon	RELNOTES_LANG \
463208511Smarius	TARGET \
464183626Ssimon	TARGET_ARCH \
465183626Ssimon	WORLD_FLAGS
466183626Ssimon.if defined(${var})
467208511Smarius	echo "export ${var}=\"${${var}}\""	>> ${_MK}
468183626Ssimon.endif
469183626Ssimon.endfor
470183626Ssimon	# Don't remove this, or the build will fall over!
471208511Smarius	echo "export RELEASEDIR=${_R}"		>> ${_MK}
472183626Ssimon	echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:${LOCALDIR}"	>> ${_MK}
473183626Ssimon	echo "export MANBUILDCAT=YES"		>> ${_MK}
474183626Ssimon	# NB: these may fail if the host is running w/o devfs
475208511Smarius	echo "umount /dev >/dev/null 2>&1 || true" >> ${_MK}
476183626Ssimon	echo "mount -t devfs devfs /dev >/dev/null 2>&1 || true"	>> ${_MK}
477183626Ssimon	echo "if [ -x /etc/rc.d/ldconfig ]; then" >> ${_MK}
478183626Ssimon	echo "	/etc/rc.d/ldconfig start"	>> ${_MK}
479208511Smarius	echo "else"				>> ${_MK}
480183626Ssimon	echo "	ldconfig /lib /usr/lib /usr/local/lib || true" >> ${_MK}
481183626Ssimon	echo "fi"				>> ${_MK}
482183626Ssimon	echo "if [ ! -f /tmp/.world_done ]; then" >> ${_MK}
483208511Smarius	echo "	cd /usr/src"			>> ${_MK}
484183626Ssimon	echo "	${CROSSMAKE} ${WORLD_FLAGS} -DNOCLEAN buildworld && \\" >> ${_MK}
485183626Ssimon	echo "	touch /tmp/.world_done || exit 1" >> ${_MK}
486183626Ssimon	echo "fi"				>> ${_MK}
487208511Smarius	echo "if [ ! -f /tmp/.skip_ports ]; then" >> ${_MK}
488191491Smarius	echo "	echo \">>> make readmes started on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
489191491Smarius	echo "	cd /usr/ports"			>> ${_MK}
490191491Smarius	echo "	make ${PORTREADMES_FLAGS} readmes" >> ${_MK}
491208511Smarius	echo "	touch /tmp/.skip_ports"		>> ${_MK}
492191491Smarius	echo "	echo \">>> make readmes finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
493191491Smarius	echo "fi"				>> ${_MK}
494191491Smarius	echo "cd /usr/src/release"		>> ${_MK}
495208511Smarius	echo "make obj"				>> ${_MK}
496183626Ssimon	echo "make \$${_RELTARGET}"		>> ${_MK}
497183626Ssimon	echo "echo \">>> make ${.TARGET} for ${TARGET} finished on \`LC_ALL=C TZ=GMT date\`\"" >> ${_MK}
498183626Ssimon	chmod 755 ${_MK}
499208511Smarius.if defined(NOPORTS) || defined(NOPORTREADMES)
500183626Ssimon	touch ${CHROOTDIR}/tmp/.skip_ports
501183626Ssimon.endif
502183626Ssimon	# Ensure md.ko is loaded if md(4) is not statically compiled into 
503208511Smarius	# the kernel
504208459Smarius	-mdconfig 2>/dev/null
505208459Smarius	env -i /usr/sbin/chroot `dirname ${_MK}` /`basename ${_MK}`
506208459Smarius
507183626Ssimonclean:
508183626Ssimon	rm -rf ${CRUNCH_TARGETS:S/$/_crunch/} release.[0-8] ${EXTRAS}
509183626Ssimon
510183626Ssimonfetch-distfiles:
511183626Ssimon	@for i in ${DOCPORTS}; do \
512183626Ssimon		cd ${CHROOTDIR}/usr/ports/$$i && \
513183626Ssimon			make PORTSDIR=${CHROOTDIR}/usr/ports BATCH=yes \
514183626Ssimon			WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes \
515183626Ssimon			checksum-recursive ; \
516183626Ssimon	done
517183626Ssimon
518183626Ssimon# Clean out ${_R} and make the directory structure.
519183626Ssimonrelease.1:
520183626Ssimon	mkdir -p ${_R}
521183626Ssimon	-rm -rf ${_R}/* 2> /dev/null
522183626Ssimon	-chflags -R noschg ${_R}/.
523183626Ssimon	rm -rf ${_R}/*
524183626Ssimon	mkdir ${RD}
525183626Ssimon.if defined(MAKE_FLOPPIES)
526183626Ssimon	mkdir ${RD}/floppies
527183626Ssimon.endif
528183626Ssimon	mkdir ${RD}/trees
529183626Ssimon	mkdir ${RD}/kernels
530183626Ssimon	for i in ${DISTRIBUTIONS}; do \
531183626Ssimon		mkdir ${RD}/trees/$$i && \
532183626Ssimon		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
533183626Ssimon		    -p ${RD}/trees/$$i > /dev/null && \
534183626Ssimon		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
535183626Ssimon		    -p ${RD}/trees/$$i/usr > /dev/null && \
536183626Ssimon		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
537191491Smarius		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
538191491Smarius		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
539191491Smarius		    -p ${RD}/trees/$$i/var > /dev/null ; \
540191491Smarius	done
541166770Sbmah	touch ${.TARGET}
542166770Sbmah
543183626Ssimon# Install the system into the various distributions.
544191491Smariusrelease.2:
545191492Smarius	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/base
546208511Smarius	cd ${.CURDIR}/.. && ${CROSSMAKE} distributeworld DISTDIR=${RD}/trees
547208511Smarius	touch ${.TARGET}
548166770Sbmah
549166770Sbmah# Make and install the generic kernel(s).
550183626Ssimonrelease.3:
551183626Ssimon.for kernel in ${KERNELS}
552183626Ssimon	cd ${.CURDIR}/..; \
553183626Ssimon	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
554183626Ssimon	    KERNCONF=${kernel} INSTKERNNAME=${kernel} kernel \
555183626Ssimon	    DESTDIR=${RD}/trees/base
556183626Ssimon.endfor
557166770Sbmah	# Install a standard boot kernel+modules.
558166770Sbmah	cd ${.CURDIR}/..; \
559208511Smarius	${CROSSMAKE} ${KERNEL_FLAGS} \
560191511Sblackend	    kernel \
561191491Smarius	    DESTDIR=${RD}/trees/base; \
562166770Sbmah	cd ${.CURDIR}/..; \
563166770Sbmah	${CROSSMAKE} ${KERNEL_FLAGS} -DNO_MODULES \
564183626Ssimon	    reinstallkernel -DINSTALL_DEBUG \
565191491Smarius	    DESTDIR=${RD}/trees/base
566183626Ssimon	touch ${.TARGET}
567191491Smarius
568191491Smarius# Make and install the three crunched binaries which live on the floppies.
569191491Smarius# You are not supposed to like this :-)
570191491Smariusrelease.4:
571191491Smarius	rm -rf ${RD}/crunch
572191491Smarius	mkdir -p ${RD}/crunch
573191491Smarius.for j in ${CRUNCH_TARGETS}
574191491Smarius.if exists(${.CURDIR}/${TARGET}/${j}_crunch.conf)
575191491Smarius	rm -rf ${j}_crunch
576191491Smarius	mkdir ${j}_crunch
577197368Smarius	cd ${j}_crunch; ${WMAKEENV} crunchgen -o \
578197368Smarius	    ${.CURDIR}/${TARGET}/${j}_crunch.conf
579197368Smarius	cd ${j}_crunch; ${WMAKE} -f ${j}_crunch.mk subclean
580197368Smarius	cd ${.CURDIR}/..; ${BINMAKE} -f Makefile.inc1 _build-tools
581191491Smarius	cd ${j}_crunch; CFLAGS="-Os -pipe" ${WMAKE} -f ${j}_crunch.mk \
582191491Smarius	    -DNO_CPU_CFLAGS all
583191491Smarius	${WMAKEENV} strip -R .comment ${j}_crunch/${j}_crunch
584191491Smarius	mv ${j}_crunch/${j}_crunch ${RD}/crunch/${j}
585191491Smarius.endif
586191491Smarius.endfor
587191491Smarius	touch ${.TARGET}
588191491Smarius
589214873Smarius#
590202453Smarius# --==## Fix up the distributions. ##==--
591202453Smarius#
592202453Smariusrelease.5:
593214873Smarius	# Create any "synthetic dists" now.
594214873Smarius	@for i in ${DISTRIBUTIONS}; do \
595214873Smarius		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
596214873Smarius			echo -n "Running $$i dist creation script... "; \
597228028Smarius			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
598228028Smarius			echo "Done."; \
599228028Smarius		fi \
600228028Smarius	done \
601197368Smarius
602191491Smarius	# Remove all the directories we don't need.
603191491Smarius	-cd ${RD}/trees && \
604191491Smarius		find ${OTHER_DISTS} ${COMPAT_DISTS} -depth -type d -print | xargs rmdir
605197368Smarius	touch ${.TARGET}
606214873Smarius
607197368Smarius#
608197368Smarius# --==## Package up the tarballs from assembled trees ##==--
609197368Smarius#
610202453Smariusrelease.6:
611228028Smarius	rm -rf ${RD}/dists
612228028Smarius	mkdir -p ${RD}/dists
613202453Smarius	@for i in ${DISTRIBUTIONS} ; \
614202453Smarius	do \
615202453Smarius		if [ -d ${RD}/trees/$${i} ] ; then \
616191491Smarius			cd ${.CURDIR} && $(MAKE) doTARBALL \
617191491Smarius				SD=${RD}/trees/$${i} \
618191491Smarius				TN=$$i TD=$$i ARG="." && \
619191491Smarius			echo "$${i} distribution is finished."; \
620214873Smarius		fi ; \
621208459Smarius	done
622208459Smarius.if !defined(NOPORTS)
623208459Smarius	# XXX: Inline stripped version of doTARBALL
624208459Smarius	@rm -rf ${RD}/dists/ports/ports*
625191491Smarius	@mkdir -p ${RD}/dists/ports
626191491Smarius	@echo rolling ports/ports tarball
627166770Sbmah	@tar --exclude CVS --exclude 'ports/distfiles/*' -czf \
628191491Smarius	  ${RD}/dists/ports/ports.tgz -C /usr ports
629208511Smarius	@cp ${.CURDIR}/scripts/ports-install.sh ${RD}/dists/ports/install.sh
630191509Sblackend	@(cd ${RD}/dists/ports; \
631191491Smarius	  rm -f CHECKSUM.MD5; \
632191491Smarius	  md5 * > CHECKSUM.MD5)
633191491Smarius	@echo "ports distribution is finished."
634191491Smarius.endif
635191491Smarius	touch ${.TARGET}
636191491Smarius
637191491Smarius
638214873Smarius#
639208459Smarius# --==## Make source dists ##==--
640208459Smarius#
641191491Smariusrelease.7:
642208459Smarius.if !defined(NOSRC)
643214873Smarius	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
644208511Smarius		TD=src TN=sbase ARG="[A-Z]*"
645208459Smarius	@for i in `cd /usr/src && echo [a-z]*` ; do \
646208459Smarius		if [ -d /usr/src/$$i ] ; then \
647208459Smarius			cd ${.CURDIR} && $(MAKE) doTARBALL \
648208459Smarius				TN=`echo s$$i | tr -d '.' | \
649208511Smarius				    sed -e 's/usr/u/' \
650208459Smarius					-e 's/kerberos5/krb5/'` \
651208459Smarius				SD=/usr/src TD=src ARG="$$i" ; \
652208459Smarius		fi ; \
653208511Smarius	done
654208459Smarius.if defined(EXTRA_SRC)
655208459Smarius	@set ${EXTRA_SRC} && \
656208459Smarius	while [ $$# -ge 2 ] ; do \
657208459Smarius		if [ -d /usr/src/$$1 ] ; then \
658208511Smarius			cd ${.CURDIR} && $(MAKE) doTARBALL \
659208459Smarius				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
660208459Smarius		fi && shift && shift ; \
661208459Smarius	done
662208511Smarius.endif
663208459Smarius	(cd ${RD}/dists/src; rm -f CHECKSUM.MD5; md5 * > CHECKSUM.MD5)
664208459Smarius	@echo "src distribution is finished."
665208459Smarius.endif
666208511Smarius	touch ${.TARGET}
667208459Smarius
668208459Smarius# Build the memory root filesystem.
669208459Smariusrelease.8:
670183626Ssimon	cp ${RD}/trees/base/etc/disktab /etc
671183626Ssimon	rm -rf ${RD}/mfsfd
672166770Sbmah	mkdir ${RD}/mfsfd
673183626Ssimon	cd ${RD}/mfsfd && \
674166770Sbmah		mkdir -p etc/defaults dev mnt stand/etc/defaults stand/help
675183626Ssimon	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
676183626Ssimon		DIR=${RD}/mfsfd/stand ZIP=false
677183626Ssimon	( cd ${RD}/mfsfd && \
67876082Sbmah	  for dir in bin sbin ; do \
679183626Ssimon		ln -sf /stand $$dir; \
680183626Ssimon	  done )
681183626Ssimon	cp ${RD}/trees/base/sbin/dhclient-script ${RD}/mfsfd/stand
682183626Ssimon.if ${TARGET} == "pc98"
683183626Ssimon	cp ${.CURDIR}/../etc/defaults/pccard.conf \
68476082Sbmah	    ${RD}/mfsfd/etc/defaults/pccard.conf
685183626Ssimon.endif
686183626Ssimon	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
687119431Sbmah	( for F in defaults/rc.conf netconfig protocols ; do \
688183626Ssimon		sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
689183626Ssimon		${RD}/trees/base/etc/$$F > ${RD}/mfsfd/stand/etc/$$F ; \
690183626Ssimon	  done )
691183626Ssimon	grep -E '^(ftp|nameserver|domain|sunrpc|cmd|nfsd)[^-\w]' \
69276082Sbmah	    ${RD}/trees/base/etc/services | \
693183626Ssimon	    sed -e '/^#.*$$/d' -e 's/[:space:]*#.*$$//g' \
694183626Ssimon	    > ${RD}/mfsfd/stand/etc/services
695183626Ssimon	grep 'operator' ${RD}/trees/base/etc/group \
696183626Ssimon	    > ${RD}/mfsfd/stand/etc/group
697183626Ssimon	ln ${RD}/mfsfd/stand/etc/services ${RD}/mfsfd/etc/services
698183626Ssimon	ln ${RD}/mfsfd/stand/etc/group ${RD}/mfsfd/etc/group
699183626Ssimon	ln ${RD}/mfsfd/stand/etc/netconfig ${RD}/mfsfd/etc/netconfig
700183626Ssimon	cp ${RD}/trees/base/COPYRIGHT ${RD}/mfsfd/stand/help/COPYRIGHT.hlp
70176082Sbmah.if !defined(NODOC)
702183626Ssimon	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
703183626Ssimon	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
70476082Sbmah	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
705183626Ssimon	done
706183626Ssimon	@for i in ${DIST_DOCS_ARCH_DEP}; do \
707183626Ssimon	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
708183626Ssimon	      ${RD}/mfsfd/stand/help/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
70976082Sbmah	done
710183626Ssimon	@mv ${RD}/mfsfd/stand/help/INSTALLATION.TXT \
711183626Ssimon	    ${RD}/mfsfd/stand/help/INSTALL.TXT
712183626Ssimon	@mv ${RD}/mfsfd/stand/help/EARLY-ADOPTER.TXT \
713183626Ssimon	    ${RD}/mfsfd/stand/help/EARLY.TXT
714183626Ssimon.endif
715183626Ssimon	-test -f ${.CURDIR}/install.cfg \
71676082Sbmah	    && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
717183626Ssimon	@mkdir -p ${RD}/mfsfd/boot
718183626Ssimon.if ${TARGET_ARCH} != "ia64" && ${TARGET_ARCH} != "powerpc"
719183626Ssimon	@cp ${RD}/trees/base/boot/boot* ${RD}/mfsfd/boot
720183626Ssimon.endif
721183626Ssimon.if ${TARGET} == "i386" || ${TARGET_ARCH} == "amd64"
722183626Ssimon	@cp ${RD}/trees/base/boot/mbr ${RD}/mfsfd/boot
72376560Sbmah.endif
724183626Ssimon	@tar --exclude CVS -cf - -C ${.CURDIR}/../usr.sbin/sysinstall help | \
725183626Ssimon		tar xf - -C ${RD}/mfsfd/stand
726119127Sbmah	@mkdir -p ${RD}/mfsroot
727183626Ssimon	sh -e ${DOFS_SH} ${RD}/mfsroot/mfsroot ${RD} ${MNT} \
728183626Ssimon	    ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
729183626Ssimon	@gzip -9fnv ${RD}/mfsroot/mfsroot
730124988Sbrueffer	touch ${.TARGET}
731183626Ssimon
732183626SsimonKERNFLOPPYSET=		${RD}/floppyset/kern/kernel.gz
73376082Sbmah.if defined(SMALLFLOPPYSIZE)
734183626SsimonSMALLKERNFLOPPYSET=	${RD}/floppyset/kern-small/kernel.gz
735107634Sbmah.endif
73697677Snyan.if defined(SPLIT_MFSROOT)
73797677SnyanMFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot/mfsroot.gz
738118979Sbmah.if defined(SMALLFLOPPYSIZE)
739183626SsimonSMALLMFSROOTFLOPPYSET=	${RD}/floppyset/mfsroot-small/mfsroot.gz
740122375Sbmah.endif
741183626Ssimon.endif
742150279Sbrueffer
743183626Ssimon# Build boot and install floppies.
744150279Sbruefferfloppies.1:
745183626Ssimon	@gzip -9nc ${RD}/trees/base/boot/kernel/kernel > ${RD}/kernels/kernel.gz
746118979Sbmah	@echo "Making the kernel boot floppies..."
747183626Ssimon	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern \
748118979Sbmah	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz
749183626Ssimon.if defined(SMALLFLOPPYSIZE)
75076082Sbmah	@echo "Making the small kernel boot floppies..."
751183626Ssimon	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=kern-small \
752102444Sbmah	    FLOPPYDESC="Kernel" SPLITFILE=${RD}/kernels/kernel.gz \
753183626Ssimon	    FDSIZE="SMALL"
75476082Sbmah.endif
755183626Ssimon.if defined(SPLIT_MFSROOT)
75676082Sbmah	@echo "Making the mfsroot boot floppies..."
757183626Ssimon	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot \
758133094Ssimon	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz
759183626Ssimon.if defined(SMALLFLOPPYSIZE)
760150279Sbrueffer	@echo "Making the small mfsroot boot floppies..."
761183626Ssimon	@cd ${.CURDIR} && ${MAKE} makeFloppySet FLOPPYBASE=mfsroot-small \
76276082Sbmah	    FLOPPYDESC="Memory Filesystem" SPLITFILE=${RD}/mfsroot/mfsroot.gz \
763183626Ssimon	    FDSIZE="SMALL"
76476082Sbmah.endif
765183626Ssimon	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
766119107Sbmah	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
767183626Ssimon	    MFSROOTFILE="${MFSROOTFLOPPYSET}.split ${MFSROOTFLOPPYSET}.boot"
768183626Ssimon.if defined(SMALLFLOPPYSIZE)
76987767Sbmah	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
770183626Ssimon	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
771183626Ssimon	    MFSROOTFILE="${SMALLMFSROOTFLOPPYSET}.split ${SMALLMFSROOTFLOPPYSET}.boot" \
772183626Ssimon	    FDSIZE="SMALL"
77387767Sbmah.endif
77476082Sbmah.else	# !SPLIT_MFSROOT
775183626Ssimon	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot" \
776150293Sbrueffer	    KERNFILE="${KERNFLOPPYSET}.split ${KERNFLOPPYSET}.boot" \
777229977Sbrueffer	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz
778229977Sbrueffer.if defined(SMALLFLOPPYSIZE)
779183626Ssimon	@cd ${.CURDIR} && ${MAKE} buildBootFloppy FSIMAGE="boot-small" \
780169841Sbrueffer	    KERNFILE="${SMALLKERNFLOPPYSET}.split ${SMALLKERNFLOPPYSET}.boot" \
781183626Ssimon	    MFSROOTFILE=${RD}/mfsroot/mfsroot.gz \
782144426Sbrueffer	    FDSIZE="SMALL"
783183626Ssimon.endif
784174662Sbmah.endif	# SPLIT_MFSROOT
785183626Ssimon	touch ${.TARGET}
786150279Sbrueffer
787183626Ssimon# Build fixit floppy.
788150279Sbruefferfloppies.2:
789183626Ssimon	@echo "Making fixit floppy."
790150279Sbrueffer	@rm -rf ${RD}/fixitfd
791232060Sbrueffer	@mkdir ${RD}/fixitfd
792232060Sbrueffer	@cd ${RD}/fixitfd && \
793183626Ssimon	    mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
794150279Sbrueffer	    usr/share/misc
795183626Ssimon	@cp ${RD}/trees/base/etc/spwd.db ${RD}/trees/base/etc/group \
796157274Sbrueffer	    ${RD}/fixitfd/etc
797183626Ssimon	@sed -e 's/#.*//' ${RD}/trees/base/etc/protocols \
79887767Sbmah	    > ${RD}/fixitfd/etc/protocols
79987767Sbmah	@sed -e 's/#.*//' ${RD}/trees/base/usr/share/misc/scsi_modes \
800183626Ssimon	    > ${RD}/fixitfd/usr/share/misc/scsi_modes
801183626Ssimon	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
802183626Ssimon	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
80387767Sbmah	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
80476082Sbmah	@chmod 555 ${RD}/fixitfd/stand/tar
805183626Ssimon.if defined(SMALLFLOPPYSIZE)
80676082Sbmah	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit-small \
807227516Sbrueffer	    DIR=${RD}/fixitfd/stand ZIP=false
808227516Sbrueffer	@sh -e ${DOFS_SH} ${RD}/floppies/fixit-small.flp ${RD} ${MNT} \
809183626Ssimon	    ${SMALLFLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${SMALLFLOPPYLABEL}
81076082Sbmah	@rm -rf ${RD}/fixitfd/stand
811227516Sbrueffer	@mkdir ${RD}/fixitfd/stand
812227516Sbrueffer.endif
813183626Ssimon	@cd ${.CURDIR} && ${MAKE} installCRUNCH CRUNCH=fixit \
81476082Sbmah	    DIR=${RD}/fixitfd/stand ZIP=false
815183626Ssimon	@sh -e ${DOFS_SH} ${RD}/floppies/fixit.flp ${RD} ${MNT} \
816133457Ssimon	    ${FLOPPYSIZE} ${RD}/fixitfd ${FLOPPYINODE} ${FLOPPYLABEL}
817183626Ssimon	touch ${.TARGET}
81876082Sbmah
819183626Ssimon# Do our last minute floppies directory setup
82076560Sbmahfloppies.3:
821183626Ssimon.if !defined(NODOC)
822108922Sbmah	@cp ${RND}/${RELNOTES_LANG}/installation/${TARGET}/article.txt \
823183626Ssimon	    ${RD}/floppies/README.TXT
82487100Sbmah	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
825183626Ssimon.else
82690031Sbmah	@(cd ${RD}/floppies; md5 *.flp > CHECKSUM.MD5)
827183626Ssimon.endif
828102321Sbmah	touch ${.TARGET}
829183626Ssimon
830137140Ssimon#
831183626Ssimon# --==## Setup a suitable ftp-area ##==--
832114978Sbmah#
833183626Ssimonftp.1:
834183626Ssimon	@echo "Setting up FTP distribution area"
835134916Ssimon	@mkdir -p ${FD}
836183626Ssimon	-@ln -s . ${FD}/${BUILDNAME}
837183626Ssimon.if defined(MAKE_FLOPPIES)
838183626Ssimon	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
839183626Ssimon.endif
840183626Ssimon	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
841183626Ssimon.if !defined(NODOC)
842183626Ssimon	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
843183626Ssimon		cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
844183626Ssimon		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
845183626Ssimon		cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
846183626Ssimon		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
84776082Sbmah	done
848183626Ssimon	@for i in ${DIST_DOCS_ARCH_DEP}; do \
849183626Ssimon		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
850183626Ssimon		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
85176082Sbmah		cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
852183626Ssimon		    ${FD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
853183626Ssimon	done
854183626Ssimon	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${FD}
85576082Sbmah	@mv ${FD}/INSTALLATION.TXT ${FD}/INSTALL.TXT
856116504Sbmah	@mv ${FD}/INSTALLATION.HTM ${FD}/INSTALL.HTM
857166767Sbmah	@mv ${FD}/EARLY-ADOPTER.TXT ${FD}/EARLY.TXT
858183626Ssimon	@mv ${FD}/EARLY-ADOPTER.HTM ${FD}/EARLY.HTM
859183626Ssimon.endif
86076082Sbmah	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
861116505Sbmah	touch ${.TARGET}
86276082Sbmah
86376082Sbmah#
86476082Sbmah# --==## Setup a suitable cdrom-area ##==--
86576082Sbmah#
86676082Sbmahcdrom.1:
867183626Ssimon	@echo "Setting up CDROM distribution area"
868183626Ssimon	@mkdir -p ${CD_BOOT} ${CD_DISC1} ${CD_DISC2}
86976082Sbmah	-@ln -s . ${CD_DISC1}/${BUILDNAME}
870183626Ssimon.if defined(MAKE_FLOPPIES)
871183626Ssimon	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
872183626Ssimon.endif
87376082Sbmah	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
87476082Sbmah	@for i in ${DISTRIBUTIONS} ; \
875183626Ssimon	do \
87676082Sbmah		if [ -d ${RD}/trees/$${i} ] ; then \
877183626Ssimon			chflags -R noschg ${RD}/trees/$${i} || true ; \
878183626Ssimon			( cd ${RD}/trees/$${i} && \
87976082Sbmah			    find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
880183626Ssimon		fi \
881183607Ssimon	done
882183632Ssimon	@rm -f ${CD_DISC2}/.profile
883183632Ssimon	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
884185241Sdelphij	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
885185241Sdelphij	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
886183626Ssimon.if !defined(NODOC)
88776082Sbmah	@for i in ${DIST_DOCS_ARCH_INDEP}; do \
888183626Ssimon	  cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \
88976082Sbmah	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
890183626Ssimon	  cp ${RND}/${RELNOTES_LANG}/$$i/article.html \
891157648Sbrueffer	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
892183626Ssimon	done
893183626Ssimon	@for i in ${DIST_DOCS_ARCH_DEP}; do \
89476082Sbmah	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \
895183626Ssimon	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \
896135144Sbrueffer	  cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \
897194248Smarius	      ${CD_DISC1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \
898194248Smarius	done
899183626Ssimon	@cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DISC1}
900150278Sbrueffer	@mv ${CD_DISC1}/INSTALLATION.TXT ${CD_DISC1}/INSTALL.TXT
901183626Ssimon	@mv ${CD_DISC1}/INSTALLATION.HTM ${CD_DISC1}/INSTALL.HTM
902183626Ssimon	@mv ${CD_DISC1}/EARLY-ADOPTER.TXT ${CD_DISC1}/EARLY.TXT
90376560Sbmah	@mv ${CD_DISC1}/EARLY-ADOPTER.HTM ${CD_DISC1}/EARLY.HTM
904183626Ssimon.endif
90576082Sbmah.if ${TARGET} != "pc98"
906183626Ssimon	@echo "Setting up boot area"
907172336Sbrueffer	@rm -f ${CD_DISC2}/boot/loader.conf
908183626Ssimon	@cp ${RD}/mfsroot/mfsroot.gz ${CD_DISC2}/boot/mfsroot.gz
90976082Sbmah	@echo 'mfsroot_load="YES"' > ${CD_DISC2}/boot/loader.conf
910183626Ssimon	@echo 'mfsroot_type="mfs_root"' >> ${CD_DISC2}/boot/loader.conf
91176082Sbmah	@echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DISC2}/boot/loader.conf
912183626Ssimon.if defined(CD_BOOT)
91376082Sbmah	@cp -Rp ${CD_DISC2}/boot ${CD_BOOT}
914183626Ssimon.if defined(MINIROOT)
91576082Sbmah	@mkdir -p ${FD}/miniroot
916183626Ssimon	@sh -e ${DOFS_SH} ${FD}/miniroot/miniroot.ufs \
91776498Sbmah	    ${RD} ${MNT} 0 ${CD_BOOT} 8192 auto
918208024Sbrueffer	@gzip -9v ${FD}/miniroot/miniroot.ufs
919208024Sbrueffer.endif
920207982Sbrueffer.endif
921183626Ssimon	@cp -Rp ${CD_DISC2}/boot ${CD_DISC1}
92276082Sbmah.endif
923183626Ssimon	touch ${.TARGET}
92476082Sbmah
925183626Ssimoniso.1:
92676082Sbmah.if exists(${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh)
927183626Ssimon	@echo "Creating ISO images..."
92876082Sbmah.if defined(CD_BOOT)
929183626Ssimon	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
93076082Sbmah	    fbsd_bootonly \
931183626Ssimon	    ${CD}/${BUILDNAME}-${TARGET}-bootonly.iso ${CD_BOOT}
932150242Sjoel.endif
933183655Ssimon	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
934183655Ssimon	    ${DISC1_LABEL} \
935183626Ssimon	    ${CD}/${BUILDNAME}-${TARGET}-${DISC1_NAME}.iso ${CD_DISC1}
93676082Sbmah	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
937185532Sbrueffer	    ${DISC2_LABEL} \
938185532Sbrueffer	    ${CD}/${BUILDNAME}-${TARGET}-${DISC2_NAME}.iso ${CD_DISC2}
939183647Ssimon.if defined(CD_EXTRA_BITS)
940183647Ssimon	@sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \
941183626Ssimon	    fbsd_boot \
94276082Sbmah	    ${CD}/${BUILDNAME}-${TARGET}-disc1.iso ${CD_DISC1} \
943183626Ssimon	    ${CD_EXTRA_BITS} \
944113884Sbmah	    && false
945183626Ssimon.endif
946165157Sbrueffer	@(cd ${CD} && md5 *.iso > ${BUILDNAME}-${TARGET}-iso.CHECKSUM.MD5)
947183626Ssimon	touch ${.TARGET}
948159606Sbrueffer.else
949183626Ssimon	@echo "Do not know how to create an ISO for ${TARGET_ARCH}."
950126363Sbmah.endif
951183626Ssimon
952171111Sbrueffer#
953183626Ssimon# --==## Documentation Project files such as the Handbook and FAQ ##==--
95476082Sbmah#
955183626Ssimondoc.1:
95676082Sbmah	@echo "Making docs..."
957183626Ssimon	@for i in ${DOCPORTS}; do \
958171111Sbrueffer	    cd /usr/ports/$$i && \
959231943Sbrueffer	    env -i FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \
960231943Sbrueffer		make all install clean BATCH=yes WITHOUT_X11=yes JADETEX=no \
961183626Ssimon		WITHOUT_PYTHON=yes FORCE_PKG_REGISTER=yes; \
96285666Sbmah	done
963227275Sbrueffer	@cd /usr/doc && make all install 'FORMATS=html html-split txt' \
964227275Sbrueffer	    INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/base/usr/share/doc \
965183626Ssimon	    URLS_ABSOLUTE=YES	
96685666Sbmah	touch ${.TARGET}
967183626Ssimon
96876082Sbmah#
969183626Ssimon# --==## RELNOTESng:  Next-generation replacements for *.TXT files ##==--
97085666Sbmah#
971183626Ssimondoc.2:
97285666Sbmah	@echo "Making release documentation..."
973227666Sbrueffer	@cd ${.CURDIR}/doc && make all install clean 'FORMATS=html txt' \
974227666Sbrueffer	    INSTALL_COMPRESSED='' DOCDIR=${RND}
975207982Sbrueffer	touch ${.TARGET}
976207982Sbrueffer
977183626Ssimon# Various "subroutine" and other supporting targets.
97885710Sbmah
979183626Ssimon# RD=
98076082Sbmah# SD=
981183626Ssimon# TD=
98276082Sbmah# ARG=
983183626SsimondoTARBALL:
98476082Sbmah.if !defined(SD)
985183626Ssimon	@echo "SD undefined in doTARBALL" && exit 1
98677590Sbmah.endif
987183626Ssimon.if !defined(TD)
988160659Sbrueffer	@echo "TD undefined in doTARBALL" && exit 1
989183626Ssimon.endif
99080242Sbmah.if !defined(ARG)
991183626Ssimon	@echo "ARG undefined in doTARBALL" && exit 1
99285163Sbmah.endif
993186208Smurray	@rm -rf ${RD}/dists/${TD}/${TN}*
994183626Ssimon	@mkdir -p ${RD}/dists/${TD}
99585163Sbmah	@( cd ${SD} && \
996183626Ssimon		tn=`echo ${TN} | tr 'A-Z' 'a-z' | cut -c1-8` && \
99791503Sbmah		echo rolling ${TD}/$$tn tarball &&\
998183626Ssimon		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
99995057Sbmah		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
1000183626Ssimon		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn \
100195057Sbmah		    > ${RD}/dists/${TD}/$$tn.inf && \
1002183626Ssimon		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
1003119991Sbmah			cp -p ${.CURDIR}/scripts/$${TD}-install.sh \
1004183626Ssimon			    ${RD}/dists/${TD}/install.sh; \
1005119991Sbmah		fi && \
1006225184Sbrueffer		if [ "${SD}" != "/usr/src" ]; then \
1007225184Sbrueffer			mtree -c -i -p ${SD}/${ARG} \
1008183626Ssimon			  -k gname,md5digest,mode,nlink,uname,size,link,type \
1009134219Sbrueffer			  > ${RD}/dists/${TD}/$$tn.mtree ; \
1010183626Ssimon		else \
1011135057Ssimon			true; \
1012183626Ssimon		fi; \
1013146397Sbrueffer		( cd ${RD}/dists/${TD}; \
1014183626Ssimon		rm -f CHECKSUM.MD5; \
101576082Sbmah		md5 * > CHECKSUM.MD5 ) \
1016183626Ssimon	)
1017183626Ssimon
101876082SbmahdoRELEASE: release.1 release.2 ${DOCREL} release.3 release.4 \
1019186208Smurray    release.5 release.6 release.7 release.8 ${EXTRAS}
1020183626Ssimon	@echo "Release done"
1021109739Sbmah
1022183626Ssimonfloppies:
1023183626Ssimon	@rm -f release.4 release.8 floppies.[123]
1024109739Sbmah	@cd ${.CURDIR} && ${MAKE} release.4 release.8 floppies.1 floppies.2 \
1025183626Ssimon	    floppies.3
1026183626Ssimon	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
1027109739Sbmah
1028186208SmurrayinstallCRUNCH:
1029183626Ssimon.if !defined(CRUNCH)
1030109739Sbmah	@echo "CRUNCH undefined in installCRUNCH" && exit 1
1031186208Smurray.endif
1032183626Ssimon.if !defined(DIR)
1033183626Ssimon	@echo "DIR undefined in installCRUNCH" && exit 1
1034118804Sbmah.endif
1035183626Ssimon.if !defined(ZIP)
1036183626Ssimon	@echo "ZIP undefined in installCRUNCH" && exit 1
1037118804Sbmah.endif
1038186208Smurray	@if ${ZIP} ; then \
1039183626Ssimon		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
1040183626Ssimon	else \
104176082Sbmah		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
1042183626Ssimon	fi
1043183626Ssimon	@chmod 555 ${DIR}/${CRUNCH}_crunch
1044183626Ssimon	@if [ -f ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf ] ; then \
104576560Sbmah		for i in `crunchgen -l ${.CURDIR}/${TARGET}/${CRUNCH}_crunch.conf` ; do \
1046183626Ssimon			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1047183626Ssimon		done \
1048172037Sbrueffer	else \
1049183626Ssimon		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
1050183626Ssimon			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
1051172117Sbrueffer		done \
1052183626Ssimon	fi
1053172117Sbrueffer
1054192196Sbrueffer#
1055192196Sbrueffer# --==## Build a floppy set for a splitfs file ##==--
1056183626Ssimon#
1057183626Ssimon# FLOPPYBASE - basename of floppy image files
1058172129Sbrueffer# FLOPPYDESC - description of floppy set
1059183626Ssimon# SPLITFILE - filename of the file to split
1060183626Ssimon# FDSIZE - if specified and "small", small floppy is created
1061183626Ssimon
1062172037Sbrueffer.if make(makeFloppySet)
1063183845SbruefferSPLITDIR=	${RD}/floppyset/${FLOPPYBASE}
1064183845Sbrueffer.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1065183845SbruefferFLPSPLITSIZE=	${SMALLFLOPPYSPLITSIZE}
1066183845SbruefferFLPSIZE=	${SMALLFLOPPYSIZE}
1067183845SbruefferFLPLABEL=	${SMALLFLOPPYLABEL}
1068183845Sbrueffer.else
1069183845SbruefferFLPSPLITSIZE=	${FLOPPYSPLITSIZE}
1070207982SbruefferFLPSIZE=	${FLOPPYSIZE}
1071207982SbruefferFLPLABEL=	${FLOPPYLABEL}
1072207982Sbrueffer.endif
1073183626Ssimon.endif
1074172079Sbrueffer
1075183626SsimonmakeFloppySet:
107676082Sbmah.if !defined(FLOPPYBASE)
1077207991Sbrueffer	@echo "FLOPPYBASE undefined in ${.TARGET}" && exit 1
1078207991Sbrueffer.endif
1079190825Sbrueffer.if !defined(FLOPPYDESC)
1080190825Sbrueffer	@echo "FLOPPYDESC undefined in ${.TARGET}" && exit 1
1081185532Sbrueffer.endif
1082185532Sbrueffer.if !defined(SPLITFILE)
1083183626Ssimon	@echo "SPLITFILE undefined in ${.TARGET}" && exit 1
108476082Sbmah.endif
1085192196Sbrueffer	sh ${.CURDIR}/scripts/split-file.sh ${SPLITFILE} \
1086192196Sbrueffer	    ${RD}/floppyset/${FLOPPYBASE} ${FLPSPLITSIZE} "${FLOPPYDESC}"
1087183626Ssimon	( splitfile=${SPLITDIR}/`basename ${SPLITFILE}`.split ; \
1088183626Ssimon	lines=`cat $${splitfile} | wc -l`; \
1089183626Ssimon	lines=$$((lines - 1)) ; \
1090183626Ssimon	for line in `jot $$lines`; do \
1091183626Ssimon		file=`head -n $$(($${line} + 1)) $${splitfile} | tail -1 | cut -f 1 -d ' '` ; \
1092173586Sbrueffer		sh -e ${DOFS_SH} ${RD}/floppies/${FLOPPYBASE}$${line}.flp \
1093183626Ssimon		${RD} ${MNT} ${FLPSIZE} ${SPLITDIR}/$${file} \
1094183626Ssimon		${BOOTINODE} ${FLPLABEL}; \
1095172036Sbrueffer	done )
1096183626Ssimon
1097183626Ssimon#
109876082Sbmah# --==## Build a boot floppy ##==--
1099183626Ssimon#
1100183626Ssimon# FSIMAGE - base floppy image name
110187100Sbmah# FDSIZE - if specified and "small", small floppy is created
1102183626Ssimon# KERNFILE - path to kernel split file
1103183626Ssimon# MFSROOTFILE - path to mfsroot split file
1104155296Sbrueffer
1105183626Ssimon.if make(buildBootFloppy)
1106123164SbmahIMAGEDIR=	${RD}/image.${FSIMAGE}
1107183626SsimonBOOTDIR=	${RD}/trees/base/boot
1108129375SrikHINTSFILE=	${BOOTDIR}/device.hints
1109183626SsimonACPI_KO=	${BOOTDIR}/kernel/acpi.ko
1110127755SrikIMAGEFILE=	${RD}/floppies/${FSIMAGE}.flp
1111183626Ssimon.if defined(FDSIZE) && ${FDSIZE} == "SMALL"
1112108922SbmahFLPSIZE=	${SMALLFLOPPYSIZE}
1113183626SsimonFLPLABEL=	${SMALLFLOPPYLABEL}
1114183626Ssimon.else
111587100SbmahFLPSIZE=	${FLOPPYSIZE}
1116183626SsimonFLPLABEL=	${FLOPPYLABEL}
1117183626Ssimon.endif
1118105426Sbmah.endif
1119186208Smurray
1120183626SsimonbuildBootFloppy:
1121183626Ssimon.if !defined(FSIMAGE)
1122157417Smarcel	@echo "FSIMAGE undefined in ${.TARGET}" && exit 1
1123183626Ssimon.endif
112476082Sbmah.if !defined(KERNFILE)
1125183626Ssimon	@echo "KERNFILE undefined in ${.TARGET}" && exit 1
1126183626Ssimon.endif
1127186208Smurray.if !defined(MFSROOTFILE)
1128183626Ssimon	@echo "MFSROOTFILE undefined in ${.TARGET}" && exit 1
1129183626Ssimon.endif
113076082Sbmah	@echo "Running ${.TARGET} for ${FSIMAGE}"
1131183626Ssimon	@rm -rf ${IMAGEDIR}
113276082Sbmah	@mkdir ${IMAGEDIR}
113376082Sbmah	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
1134183626Ssimon	@mkdir -p ${IMAGEDIR}/boot
1135183626Ssimon.if ${TARGET} == "i386"
1136183626Ssimon	@${WMAKEENV} kgzip -v -l ${RD}/trees/base/usr/lib/kgzldr.o -o \
1137183626Ssimon	    ${IMAGEDIR}/boot/loader ${BOOTDIR}/loader
113876082Sbmah.else
113976082Sbmah	@cp ${BOOTDIR}/loader ${IMAGEDIR}/boot
1140183626Ssimon.endif
1141183626Ssimon	@cp -Rp ${BOOTDIR}/*.4th ${BOOTDIR}/defaults ${BOOTDIR}/loader.help \
1142183626Ssimon	    ${BOOTDIR}/loader.rc ${IMAGEDIR}/boot
114376082Sbmah.if exists(${HINTSFILE})
1144183626Ssimon	@gzip -9nc ${HINTSFILE} > ${IMAGEDIR}/boot/device.hints.gz
114576082Sbmah.endif
1146183626Ssimon	@gzip -9n ${IMAGEDIR}/boot/*.4th ${IMAGEDIR}/boot/loader.help \
114776082Sbmah	    ${IMAGEDIR}/boot/defaults/loader.conf
1148183626Ssimon	@echo 'bootfile="/kernel"' > ${IMAGEDIR}/boot/loader.conf
1149183626Ssimon.if exists(${ACPI_KO})
1150183626Ssimon	@gzip -9nc ${ACPI_KO} > ${IMAGEDIR}/acpi.ko.gz
1151183626Ssimon	@echo 'acpi_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
115276082Sbmah	@echo 'acpi_name="/acpi.ko"' >> ${IMAGEDIR}/boot/loader.conf
1153183626Ssimon	@echo 'acpi_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1154183626Ssimon.endif
115576082Sbmah	@echo 'mfsroot_load="YES"' >> ${IMAGEDIR}/boot/loader.conf
1156183626Ssimon	@echo 'mfsroot_type="mfs_root"' >> ${IMAGEDIR}/boot/loader.conf
115776082Sbmah	@echo 'mfsroot_name="/mfsroot"' >> ${IMAGEDIR}/boot/loader.conf
1158183626Ssimon.if !exists(${ACPI_KO})
1159183626Ssimon	@echo 'mfsroot_before="read -p \"Insert boot floppy and press Enter\""' >> ${IMAGEDIR}/boot/loader.conf
1160183626Ssimon.endif
1161183626Ssimon.if ${TARGET_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
116276082Sbmah	@echo "-P" >> ${IMAGEDIR}/boot.config
116376082Sbmah.endif
116476082Sbmah	@rm -f ${IMAGEFILE}
1165183626Ssimon	@cp ${KERNFILE} ${MFSROOTFILE} ${IMAGEDIR}
1166183626Ssimon	sh -e ${DOFS_SH} ${IMAGEFILE} ${RD} ${MNT} ${FLPSIZE} ${IMAGEDIR} \
116776082Sbmah	    ${BOOTINODE} ${FLPLABEL}
1168183626Ssimon	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
1169183626Ssimon
117076082Sbmah.include <bsd.obj.mk>
1171183626Ssimon