Makefile revision 45061
1#	$Id: Makefile,v 1.474 1999/03/14 20:41:12 markm Exp $
2#
3# make release CHROOTDIR=/some/dir BUILDNAME=somename [ RELEASETAG=tag ]
4#
5# Where "/some/dir" is the pathname of a directory on a some
6# filesystem with at least 1000MB of free space, "somename" is what
7# you want the release to call itself and, optionally, which CVS "tag"
8# name should be used when checking out the sources to build the release
9# (default is HEAD).
10#
11# Please note: the vn driver must also be compiled into your kernel,
12# otherwise the target 'release.8' and possibly others will fail.
13#
14# Set these, release builder!
15#
16# Fixed version:
17#BUILDNAME=4.0-RELEASE
18#
19# Automatic SNAP versioning:
20DATE != date +%Y%m%d
21BASE = 4.0
22BUILDNAME?=${BASE}-${DATE}-SNAP
23#
24#CHROOTDIR=/junk/release
25# If this is a RELEASE, then set
26#RELEASETAG=RELENG_2_2
27
28# If you are using a local CVS repository with components stored in 
29# non-standard modules, override these on the make commandline or
30# in the environment.
31RELEASESRCMODULE?=	src
32RELEASEDOCMODULE?=	doc
33RELEASEPORTSMODULE?=	ports
34
35# Unless set elsewhere, indicate the object format we'll be using.
36OBJFORMAT?=		elf
37
38# Uncomment this to disable the doc.1 target.  It is also an ERROR
39# to set NOPORTS and not set NODOC since docs depend on ports.
40#NODOC=  YES
41#NOPORTS=  YES
42# Comment the following if you want the release documentation to be
43# in English only.
44ALLLANG=	yes
45DOCPORTS=	textproc/docproj
46# Set this to wherever the distfiles required by ${DOCPORTS} live.
47DISTFILES?=	${.CURDIR}/../../ports/distfiles
48
49DIST_DOCS= ABOUT.TXT ERRATA.TXT LAYOUT.TXT README.TXT HARDWARE.TXT \
50           INSTALL.TXT RELNOTES.TXT TROUBLE.TXT UPGRADE.TXT
51
52# Things which without too much trouble can be considered variables
53# BIN_DISTS are special in that they get full /etc installation sets.
54#
55COMPAT_DISTS?=	compat1x compat20 compat21
56OTHER_DISTS?=	manpages catpages games proflibs dict info doc
57CRYPTO_DISTS?=	krb des
58BIN_DISTS?=	bin
59DISTRIBUTIONS?=	${BIN_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS}
60KERNELS?=	GENERIC
61
62# Extra source tarballs; each argument is a pair of source dir and
63# distribution name.  The dist name should not exceed 7 characters
64# (another "s" for "source" will be prepended).
65EXTRA_SRC+=	usr.sbin/sendmail/cf smailcf
66
67BOOT1=	etc/protocols etc/defaults/rc.conf
68
69# mountpoint for filesystems.
70MNT=			/mnt
71
72# Various floppy image parameters.
73#
74BOOTSIZE=		1440
75FIXITSIZE=		1440
76MFSSIZE=		2880
77BIGBOOTSIZE=		2880
78BOOTINODE=		80000
79MFSINODE=		8000
80FIXITINODE=		2000
81BOOTLABEL=		fd1440
82FIXITLABEL=		fd1440
83BIGBOOTLABEL=		minimum2
84MFSLABEL=		minimum2
85
86# overrides.
87.if ${MACHINE_ARCH} == "alpha"
88FIXITSIZE=		2880
89FIXITLABEL=		minimum2
90.endif
91
92ZIPNSPLIT=		gzip --no-name -9 -c | split -b 240640 -
93
94
95VNDEVICE?=		vn0
96
97# Things which may get you into trouble if you change them
98MTREEFILES=		${.CURDIR}/../etc/mtree
99RD=			/R/stage
100FD=			/R/ftp
101CD=			/R/cdrom
102CD_DISC1=		${CD}/disc1
103CD_DISC2=		${CD}/disc2
104
105# Where the bootstrap ports (see DOCPORTS) get installed.
106LOCALDIR=		/usr/local/bin
107
108# ${BOOTSTRAPDIR} is for those utilities that refer to the hosting
109# environment, rather than the target environment.  This is specifically
110# intended for kernel-dependent utilities that are used during the build.
111#
112# ${BOOTSTRAPDIR} is actually being used by prepending it to the normal
113# ${PATH}.  Thus, it's also available to outside utilities like doFS.sh.
114BOOTSTRAPDIR=	/bootstrap
115#
116# The mount subsystem has been changed between 2.2 and 3.0 by the
117# Lite2 import.
118BOOTSTRAPUTILS=	/sbin/mount /sbin/umount
119#
120# 3.0 cpio tries to reference lchown(2) which is not available in 2.2
121BOOTSTRAPUTILS+= /usr/bin/cpio
122
123.if !defined(CRUNCH_TARGETS)
124CRUNCH_TARGETS=	boot fixit
125.endif
126
127EXTRAS= cdrom.1 ftp.1
128
129.if !defined(NODOC)
130DOCREL= doc.1
131.endif
132
133rerelease release:
134.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
135	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
136.endif
137.if make(release)
138.if exists(${CHROOTDIR})
139# The first command will fail on a handful of files that have their schg
140# flags set.  But it greatly speeds up the next two commands.
141	-rm -rf ${CHROOTDIR}
142	-chflags -R noschg ${CHROOTDIR}/.
143	-rm -rf ${CHROOTDIR}
144.endif
145	-mkdir -p ${CHROOTDIR}
146	cd ${.CURDIR}/../etc && ${MAKE} distrib-dirs DESTDIR=${CHROOTDIR}
147	cd ${.CURDIR}/../etc && ${MAKE} distribution DESTDIR=${CHROOTDIR}
148	[ -f /etc/resolv.conf ] && cp -p /etc/resolv.conf ${CHROOTDIR}/etc
149	cd ${.CURDIR}/.. && ${MAKE} installworld DESTDIR=${CHROOTDIR} NOMAN=1
150	mkdir ${CHROOTDIR}/${BOOTSTRAPDIR}
151	for i in ${BOOTSTRAPUTILS} ; do \
152		cp -p ${CHROOTDIR}$$i ${CHROOTDIR}/${BOOTSTRAPDIR} ; \
153	done
154.if !defined(RELEASETAG)
155	cd ${CHROOTDIR}/usr && rm -rf src && \
156		cvs -R -d ${CVSROOT} co -P ${RELEASESRCMODULE}
157.else
158	cd ${CHROOTDIR}/usr && rm -rf src && \
159		cvs -R -d ${CVSROOT} co -P -r ${RELEASETAG} ${RELEASESRCMODULE}
160.endif
161.if defined(LOCAL_PATCHES) && exists(${LOCAL_PATCHES})
162	cd ${CHROOTDIR}/usr/src && patch --silent < ${LOCAL_PATCHES}
163.endif
164.if defined(LOCAL_SCRIPT) && exists(${LOCAL_SCRIPT})
165	cd ${CHROOTDIR} && env CHROOTDIR=${CHROOTDIR} BUILDNAME=${BUILDNAME} RELEASETAG=${RELEASETAG} ${LOCAL_SCRIPT}
166.endif
167.if !defined(NOPORTS)
168	cd ${CHROOTDIR}/usr && rm -rf ports && cvs -R -d ${CVSROOT} co -P ${RELEASEPORTSMODULE} && cd ports && make readmes PORTSDIR=${CHROOTDIR}/usr/ports
169.endif
170.if !defined(NODOC)
171	cd ${CHROOTDIR}/usr && rm -rf doc && cvs -R -d ${CVSROOT} co -P ${RELEASEDOCMODULE}
172	[ -d ${DISTFILES}/ ] && cp -rp ${DISTFILES} ${CHROOTDIR}/usr/ports/distfiles
173.endif
174.endif
175.if make(rerelease)
176.if !defined(RELEASENOUPDATE)
177.if !defined(RELEASETAG)
178	cd ${CHROOTDIR}/usr/src && cvs -R -q update -P -d
179.else
180	cd ${CHROOTDIR}/usr/src && cvs -R -q update -P -d -r ${RELEASETAG}
181.endif
182.if !defined(NOPORTS)
183	cd ${CHROOTDIR}/usr/ports && cvs -R -q update -P -d
184.endif
185.if !defined(NODOC)
186	cd ${CHROOTDIR}/usr/doc && cvs -R -q update -P -d
187.endif
188.endif
189.endif
190	# Add version information to those things that need it.
191	( cd ${CHROOTDIR}/usr/src/sys/conf && \
192	  mv newvers.sh foo && \
193	  sed "s/^RELEASE=.*/RELEASE=${BUILDNAME}/" foo > newvers.sh && rm foo )
194	echo OBJFORMAT=${OBJFORMAT} > ${CHROOTDIR}/etc/objformat
195	-test -f install.cfg && cp install.cfg ${CHROOTDIR}/usr/src/release
196	echo "#!/bin/sh"			> ${CHROOTDIR}/mk
197	echo "set -ex"				>> ${CHROOTDIR}/mk
198	echo "_RELTARGET=\$${1:-doRELEASE}"	>> ${CHROOTDIR}/mk
199	echo "export CFLAGS='-O -pipe'"	>> ${CHROOTDIR}/mk
200	echo "export DISTRIBUTIONS=\"${DISTRIBUTIONS}\"" >> ${CHROOTDIR}/mk
201	echo "export BUILDNAME=${BUILDNAME}"	>> ${CHROOTDIR}/mk
202	echo "export VNDEVICE=${VNDEVICE}"	>> ${CHROOTDIR}/mk
203	echo "export OBJFORMAT=${OBJFORMAT}"	>> ${CHROOTDIR}/mk
204.if defined(RELEASETAG)
205	echo "export RELEASETAG=${RELEASETAG}"	>> ${CHROOTDIR}/mk
206.endif
207.if defined(NOPORTS)
208	echo "export NOPORTS=${NOPORTS}"	>> ${CHROOTDIR}/mk
209.endif
210.if defined(NODOC)
211	echo "export NODOC=${NODOC}"		>> ${CHROOTDIR}/mk
212.endif
213.if defined(ALLLANG)
214	echo "export ALLLANG=${ALLLANG}"	>> ${CHROOTDIR}/mk
215.else
216	echo "export DOC_LANG=en"		>> ${CHROOTDIR}/mk
217.endif
218.if defined(NOSRC)
219	echo "export NOSRC=${NOSRC}"		>> ${CHROOTDIR}/mk
220.endif
221.if defined(NOSHARED)
222	echo "export NOSHARED=${NOSHARED}"	>> ${CHROOTDIR}/mk
223.endif
224.if defined(BOOT_CONFIG)
225	echo "export BOOT_CONFIG=\"${BOOT_CONFIG}\"">> ${CHROOTDIR}/mk
226.endif
227	# Don't remove this, or the build will fall over!
228	echo "export RELEASEDIR=/R"		>> ${CHROOTDIR}/mk
229	echo "export PATH=${BOOTSTRAPDIR}:$${PATH}:${LOCALDIR}" >> ${CHROOTDIR}/mk
230	echo "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
231	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
232.if make(release)
233	echo "	(cd etc; make distrib-dirs distribution)" >> ${CHROOTDIR}/mk
234	echo "	make world"			>> ${CHROOTDIR}/mk
235.endif
236.if make(rerelease)
237	echo "	make all install"		>> ${CHROOTDIR}/mk
238.endif
239	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
240	echo "fi"				>> ${CHROOTDIR}/mk
241	echo "cd /usr/src/release/sysinstall"	>> ${CHROOTDIR}/mk
242	echo "make obj"				>> ${CHROOTDIR}/mk
243	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
244	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
245	echo "echo make ${.TARGET} Finished"	>> ${CHROOTDIR}/mk
246	chmod 755 ${CHROOTDIR}/mk
247	chroot ${CHROOTDIR} /mk
248
249clean:
250	rm -rf boot_crunch release.[0-9]
251
252# Clean out /R and make the directory structure.
253release.1:
254	-mkdir /R
255	-chflags -R noschg /R/.
256	rm -rf /R/*
257	mkdir ${RD}
258	mkdir ${RD}/floppies
259	mkdir ${RD}/trees
260	mkdir ${RD}/dists
261	mkdir ${RD}/kernels
262	for i in ${DISTRIBUTIONS} ; do \
263		mkdir ${RD}/trees/$$i && \
264		mkdir ${RD}/dists/$$i && \
265		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
266		    -p ${RD}/trees/$$i > /dev/null && \
267		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
268		    -p ${RD}/trees/$$i/usr > /dev/null && \
269		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
270		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
271		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
272		    -p ${RD}/trees/$$i/var > /dev/null ; \
273	done
274	touch release.1
275
276# Install the system into the various distributions.
277release.2:
278	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/bin
279	cd ${.CURDIR}/.. && make distribute DISTDIR=${RD}/trees
280.if exists(${.CURDIR}/../kerberosIV) && !defined(NOKERBEROS)
281	cd ${.CURDIR}/../kerberosIV && ( \
282		make bootstrap &&\
283		make obj all help-distribute DISTDIR=${RD}/trees &&\
284		make kprog \
285	)
286.endif
287	-chflags -R noschg ${RD}/trees
288	touch release.2
289
290# Make and install the generic kernel(s).
291release.3:
292.for kernel in ${KERNELS}
293	rm -f ${RD}/kernels/${kernel}
294	rm -rf ${.CURDIR}/../sys/compile/${kernel}
295	cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=${kernel}
296	rm -rf ${.CURDIR}/../sys/compile/${kernel}
297	ln -f ${RD}/kernels/${kernel} ${RD}/trees/bin/kernel.${kernel}
298.endfor
299	touch release.3
300
301# Make and install the three crunched binaries which live on the floppies.
302# You are not supposed to like this :-)
303#
304# NB: the "RELEASE_BUILD_FIXIT" magic prevents vi from including the
305# Tcl and Perl APIs.  See also /usr/src/usr.bin/vi/Makefile.
306release.4:
307	@mkdir -p /stand
308	cd ${.CURDIR}/sysinstall && make obj depend all install
309	rm -rf ${RD}/crunch
310	mkdir -p ${RD}/crunch
311	export RELEASE_BUILD_FIXIT=noway ; \
312	for j in ${CRUNCH_TARGETS} ; do \
313		rm -rf $${j}_crunch && \
314		mkdir $${j}_crunch && \
315		( cd $${j}_crunch && \
316		  crunchgen ${.CURDIR}/$${j}_crunch.conf && \
317		  ${MAKE} -DRELEASE_CRUNCH -f $${j}_crunch.mk subclean all \
318		    NOCRYPT=yes "CFLAGS=${CFLAGS} -DCRUNCHED_BINARY") && \
319		mv $${j}_crunch/$${j}_crunch ${RD}/crunch/$${j} && \
320		true || { rm -rf $${j}_crunch ; false ; } ; \
321	done
322	touch release.4
323
324#
325# --==## Fix up the distributions. ##==--
326#
327release.5:
328	# Handle some grief caused by the munition braindeadness.
329	for i in sbin/init bin/ed usr.sbin/ppp ; do \
330		( cd ${.CURDIR}/../$$i; \
331		  make -DNOCRYPT clean all distribute DISTDIR=${RD}/trees ) ; \
332	done
333
334	# Create any "synthetic dists" now.
335	@for i in ${DISTRIBUTIONS}; do \
336		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
337			echo -n "Running $$i dist creation script... "; \
338			env OBJFORMAT=${OBJFORMAT} RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
339			echo "Done."; \
340		fi \
341	done \
342
343	# Create symlinks for the MD5-based crypt lib, too.  The
344	# automatically created links still point to the DES stuff,
345	# which went into its own distribution.
346	for i in ${RD}/trees/bin/usr/lib/libscrypt* ; do \
347		c=`echo $$i | sed -e 's/libscrypt/libcrypt/'` ; \
348		rm -f $$c ; \
349		ln -s `basename $$i` $$c ; \
350	done
351
352	# Remove all the directories we don't need.
353	-cd ${RD}/trees && \
354		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
355	touch release.5
356
357#
358# --==## Package up the tarballs from assembled trees ##==--
359#
360release.6:
361	rm -rf ${RD}/dists
362	mkdir -p ${RD}/dists
363	@for i in ${DISTRIBUTIONS} ; \
364	do \
365		if [ -d ${RD}/trees/$${i} ] ; then \
366			cd ${.CURDIR} && $(MAKE) doTARBALL \
367				SD=${RD}/trees/$${i} \
368				TN=$$i TD=$$i ARG="." && \
369			echo "$${i} distribution is finished."; \
370		fi ; \
371	done
372	# More munition braindeadness.
373	( cd ${RD}/dists && \
374		if [ -f krb/krb.aa ] ; then mv krb/* des && rmdir krb ; fi )
375	touch release.6
376
377
378#
379# --==## Make source dists ##==--
380#
381release.7:
382.if !defined(NOSRC)
383	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
384		TD=src TN=sbase ARG="[A-Z]*"
385	@for i in `cd /usr/src && echo [a-z]*` ; do \
386		if [ -d /usr/src/$$i ] ; then \
387			cd ${.CURDIR} && $(MAKE) doTARBALL \
388				TN=`echo s$$i | tr -d '.' | sed 's/usr/u/'` \
389				SD=/usr/src TD=src ARG="$$i" ; \
390		fi ; \
391	done
392.if defined(EXTRA_SRC)
393	@set ${EXTRA_SRC} && \
394	while [ $$# -ge 2 ] ; do \
395		if [ -d /usr/src/$$1 ] ; then \
396			cd ${.CURDIR} && $(MAKE) doTARBALL \
397				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
398		fi && shift && shift ; \
399	done
400.endif
401	( cd ${RD}/dists/src && \
402		if [ -f ssecure.aa ] ; then mv ssecure.* ../des ; fi && \
403		if [ -f scrypto.aa ] ; then mv scrypto.* ../des ; fi && \
404		if [ -f skerbero.aa ] ; then mv skerbero.* ../des ; fi ; )
405	@echo "src distribution is finished."
406.endif
407	touch release.7
408
409# Complete the bootfd
410#
411# Now, just to get this picture down once and for all:
412#
413# +------------------------------------------------------------------------+
414# |boot.flp                                                                |
415# +-----+-----+------------------------------------------------------------+
416# |boot1|boot2|floppy filesystem "bootfd"                                  |
417# +-----+-----+-+--------------------------------------------------------+-+
418#               |kernel                                                  |
419#               +------------+-----------------------------------------+-+
420#                            |mfs filesystem "mfsfd"                   |
421#                            +-----------------------------------------+
422#
423
424release.8: write_mfs_in_kernel
425	rm -rf ${RD}/mfsfd
426	mkdir ${RD}/mfsfd
427	cd ${RD}/mfsfd && \
428		mkdir -p etc dev mnt stand/help
429	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
430		DIR=${RD}/mfsfd/stand ZIP=false
431	( cd ${RD}/trees/bin/dev && \
432		ls console tty ttyv0 ttyv1 ttyv2 ttyv3 null zero | \
433	cpio -dump ${RD}/mfsfd/dev )
434	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
435	cd ${RD}/trees/bin && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
436	echo "nameserver      42/tcp name"	> ${RD}/mfsfd/stand/etc/services
437	echo "ftp             21/tcp"		>> ${RD}/mfsfd/stand/etc/services
438	echo "domain          53/tcp          nameserver" >> ${RD}/mfsfd/stand/etc/services
439	echo "domain          53/udp          nameserver" >> ${RD}/mfsfd/stand/etc/services
440	echo "cmd             514/tcp    shell" >> ${RD}/mfsfd/stand/etc/services
441	gzip -9c ${.CURDIR}/../COPYRIGHT > ${RD}/mfsfd/stand/help/COPYRIGHT.hlp.gz
442	for i in README.TXT RELNOTES.TXT INSTALL.TXT UPGRADE.TXT HARDWARE.TXT; do \
443	   gzip -9c ${.CURDIR}/texts/$${i} > ${RD}/mfsfd/stand/help/$${i}.gz; done
444	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
445	@mkdir -p ${RD}/mfsfd/boot
446	@cp /boot/boot* ${RD}/mfsfd/boot
447	@echo "Making the regular boot floppy."
448	@tar --exclude CVS -cf - -C ${.CURDIR}/sysinstall help | \
449		tar xf - -C ${RD}/mfsfd/stand
450	@echo "Compressing doc files..."
451	@gzip -9 ${RD}/mfsfd/stand/help/*.hlp
452	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
453		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
454	@gzip -9vc mfsroot > mfsroot.gz
455	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
456		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
457	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
458	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot BIGBOOT=YES
459	@rm mfsroot mfsroot.gz mfsroot.size
460	@echo "Regular and MFS boot floppies made."
461	touch release.8
462
463#
464# --==## Create a fixit floppy ##==--
465#
466release.9:
467	@echo "Making fixit floppy."
468	@rm -rf ${RD}/fixitfd
469	@mkdir ${RD}/fixitfd
470	@cd ${RD}/fixitfd && \
471		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
472		usr/share/misc
473	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
474		DIR=${RD}/fixitfd/stand ZIP=false
475	@( cd ${RD}/fixitfd/dev && \
476		sed -e '/^PATH/s/^/#/' ${RD}/trees/bin/dev/MAKEDEV > MAKEDEV && \
477		chmod 755 MAKEDEV && \
478		sh MAKEDEV all )
479	@cp ${RD}/trees/bin/etc/spwd.db ${RD}/trees/bin/etc/group \
480		${RD}/trees/bin/etc/protocols ${RD}/fixitfd/etc
481	@cp ${RD}/trees/bin/usr/share/misc/scsi_modes \
482		${RD}/fixitfd/usr/share/misc
483	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
484	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
485	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
486	@chmod 555 ${RD}/fixitfd/stand/tar
487	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
488		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
489# Do our last minute floppies directory setup in a convenient place.
490	@cp ${.CURDIR}/texts/FLOPPIES.TXT ${RD}/floppies/README.TXT
491	@(cd ${RD}/floppies; md5 * > CHECKSUM.MD5)
492	touch release.9
493
494#
495# --==## Setup a suitable ftp-area ##==--
496#
497ftp.1:
498	@echo "Setting up FTP distribution area"
499	@mkdir -p ${FD}
500	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
501	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
502	@for i in ${DIST_DOCS}; do cp ${.CURDIR}/texts/$${i} ${FD}; done
503	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
504.if !defined(NOPORTS)
505	@tar -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
506.endif
507
508#
509# --==## Setup a suitable cdrom-area ##==--
510#
511cdrom.1:
512	@echo "Setting up CDROM distribution area"
513	@mkdir -p ${CD_DISC1} ${CD_DISC2}
514	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
515	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
516	@ln -f ${RD}/kernels/MFSKERNEL.boot ${CD_DISC1}/kernel
517	@for i in ${DISTRIBUTIONS} ; \
518	do \
519		if [ -d ${RD}/trees/$${i} ] ; then \
520			chflags -R noschg ${RD}/trees/$${i} || true ; \
521			( cd ${RD}/trees/$${i} && \
522			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
523		fi \
524	done
525	@rm -f ${CD_DISC2}/.profile
526	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
527	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
528	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
529	@for i in ${DIST_DOCS}; do cp ${.CURDIR}/texts/$${i} ${CD_DISC1}; done
530.if !defined(NOPORTS)
531	@-rm -rf /usr/ports/distfiles/*
532	@mkdir -p ${CD_DISC1}/ports && \
533	  tar -czf ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
534	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
535	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
536.endif
537
538doc.1:
539	@echo "Making docs..."
540	@for i in ${DOCPORTS}; do \
541	  cd /usr/ports/$$i && make all install clean JADETEX=no FORCE_PKG_REGISTER=yes; \
542	done
543	@cd /usr/doc && make all distribute DISTDIR=${RD}/trees
544	touch doc.1
545
546# Various "subroutine" and other supporting targets.
547
548doTARBALL:
549.if !defined(SD)
550	@echo "SD undefined in doTARBALL" && exit 1
551.endif
552.if !defined(TD)
553	@echo "TB undefined in doTARBALL" && exit 1
554.endif
555.if !defined(ARG)
556	@echo "ARG undefined in doTARBALL" && exit 1
557.endif
558	@rm -rf ${RD}/dists/${TD}/${TN}*
559	@mkdir -p ${RD}/dists/${TD}
560	@( cd ${SD} && \
561		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
562		echo rolling ${TD}/$$tn tarball &&\
563		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
564		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
565		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
566		   ${RD}/dists/${TD}/$$tn.inf && \
567		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
568		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
569		fi && \
570		if [ "${SD}" != "/usr/src" ]; then \
571			mtree -c -i -p ${SD}/${ARG} \
572			  -k gname,md5digest,mode,nlink,uname,size,link,type \
573			  > ${RD}/dists/${TD}/$$tn.mtree ; \
574		else \
575			true; \
576		fi; \
577		(cd ${RD}/dists/${TD}; \
578		   rm -f CHECKSUM.MD5; \
579		   md5 * > CHECKSUM.MD5) \
580	)
581
582doRELEASE:  release.1 release.2 ${DOCREL} release.3 release.4 release.5 \
583		release.6 release.7 release.8 release.9
584	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
585	@echo "Release done"
586
587floppies:
588	@cd ${.CURDIR} && ${MAKE} boot.flp
589	@cd ${.CURDIR} && ${MAKE} fixit.flp
590	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
591
592boot.flp:
593	@rm -f release.4 release.8
594	@cd ${.CURDIR} && ${MAKE} release.4 release.8 CRUNCH_TARGETS=boot
595
596fixit.flp:
597	@rm -f release.4 release.9
598	@cd ${.CURDIR} && ${MAKE} release.4 release.9 CRUNCH_TARGETS=fixit
599
600write_mfs_in_kernel:	${.CURDIR}/write_mfs_in_kernel.c
601	${CC} ${CFLAGS} -o write_mfs_in_kernel ${.CURDIR}/write_mfs_in_kernel.c
602
603installCRUNCH:
604.if !defined(CRUNCH)
605	@echo "CRUNCH undefined in installCRUNCH" && exit 1
606.endif
607.if !defined(DIR)
608	@echo "DIR undefined in installCRUNCH" && exit 1
609.endif
610.if !defined(ZIP)
611	@echo "ZIP undefined in installCRUNCH" && exit 1
612.endif
613	@if ${ZIP} ; then \
614		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
615	else \
616		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
617	fi
618	@chmod 555 ${DIR}/${CRUNCH}_crunch
619	@for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
620		ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
621	done
622
623#
624# --==## Compile a kernel by name ${KERNEL} ##==--
625#
626# We don't erase the sys/compile/${KERNEL} directory, since somebody
627# may want to reuse it (release.8 presently)
628#
629doKERNEL:
630	@rm -f ${RD}/kernels/${KERNEL}
631	@cd ${.CURDIR}/../sys/${MACHINE_ARCH}/conf && config ${KERNEL}
632	@cd ${.CURDIR}/../sys/compile/${KERNEL} && \
633			make  depend && \
634			make  kernel && \
635			cp kernel ${RD}/kernels/${KERNEL}
636
637#
638# --==## Put a filesystem into a BOOTMFS kernel ##==--
639#
640doMFSKERN:
641	@echo "Running doMFSKERN for ${FSIMAGE}"
642	@rm -f ${RD}/kernels/BOOTMFS.${FSIMAGE}
643	@cd ${.CURDIR}/../sys/${MACHINE_ARCH}/conf && \
644	  sh ${.CURDIR}/scripts/dokern.sh ${BIGBOOT} < GENERIC > BOOTMFS
645.if ${MACHINE_ARCH} == "i386"
646	@echo "options  INTRO_USERCONFIG" >> ${.CURDIR}/../sys/i386/conf/BOOTMFS
647.endif
648.if defined(BIGBOOT)
649	@echo "options \"MFS_ROOT_SIZE=`cat mfsroot.size`\"" >> \
650	  ${.CURDIR}/../sys/${MACHINE_ARCH}/conf/BOOTMFS
651.endif
652	@cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=BOOTMFS
653	@rm -rf ${RD}/image.${FSIMAGE}
654	@mkdir  ${RD}/image.${FSIMAGE}
655	@cp ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
656	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
657	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
658	@mkdir -p ${RD}/image.${FSIMAGE}/boot
659	@cp /boot/boot[12] /boot/loader ${RD}/image.${FSIMAGE}/boot
660.if !defined(BIGBOOT) || ${MACHINE_ARCH} == "alpha"
661	@echo "load /kernel" > ${RD}/image.${FSIMAGE}/boot/loader.rc
662	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
663	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
664	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
665	@echo "boot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
666	@touch ${RD}/image.${FSIMAGE}/boot/loader.config
667.endif
668.if defined(BIGBOOT)
669	@echo "Writing MFS image into kernel for ${FSIMAGE} floppy"
670	@./write_mfs_in_kernel ${RD}/image.${FSIMAGE}/kernel mfsroot
671	@cp ${RD}/image.${FSIMAGE}/kernel ${RD}/kernels/MFSKERNEL.${FSIMAGE}
672.endif
673	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
674	@touch ${RD}/image.${FSIMAGE}/kernel.config
675	@rm -f ${RD}/floppies/${FSIMAGE}.flp
676.if defined(BIGBOOT)
677	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
678		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
679		${BOOTINODE} ${BIGBOOTLABEL}
680.else
681	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
682		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
683		${BOOTINODE} ${BOOTLABEL}
684.endif
685	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
686
687.include <bsd.prog.mk>
688