Makefile revision 43994
1#	$Id: Makefile,v 1.471 1999/02/10 09:15:27 jkh 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.endif
216.if defined(NOSRC)
217	echo "export NOSRC=${NOSRC}"		>> ${CHROOTDIR}/mk
218.endif
219.if defined(NOSHARED)
220	echo "export NOSHARED=${NOSHARED}"	>> ${CHROOTDIR}/mk
221.endif
222.if defined(BOOT_CONFIG)
223	echo "export BOOT_CONFIG=\"${BOOT_CONFIG}\"">> ${CHROOTDIR}/mk
224.endif
225	# Don't remove this, or the build will fall over!
226	echo "export RELEASEDIR=/R"		>> ${CHROOTDIR}/mk
227	echo "export PATH=${BOOTSTRAPDIR}:$${PATH}:${LOCALDIR}" >> ${CHROOTDIR}/mk
228	echo "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
229	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
230.if make(release)
231	echo "	(cd etc; make distrib-dirs distribution)" >> ${CHROOTDIR}/mk
232	echo "	make world"			>> ${CHROOTDIR}/mk
233.endif
234.if make(rerelease)
235	echo "	make all install"		>> ${CHROOTDIR}/mk
236.endif
237	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
238	echo "fi"				>> ${CHROOTDIR}/mk
239	echo "cd /usr/src/release/sysinstall"	>> ${CHROOTDIR}/mk
240	echo "make obj"				>> ${CHROOTDIR}/mk
241	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
242	echo "make objlink"			>> ${CHROOTDIR}/mk
243	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
244	echo "echo make ${.TARGET} Finished"	>> ${CHROOTDIR}/mk
245	chmod 755 ${CHROOTDIR}/mk
246	chroot ${CHROOTDIR} /mk
247
248clean:
249	rm -rf boot_crunch release.[0-9]
250
251# Clean out /R and make the directory structure.
252release.1:
253	-mkdir /R
254	-chflags -R noschg /R/.
255	rm -rf /R/*
256	mkdir ${RD}
257	mkdir ${RD}/floppies
258	mkdir ${RD}/trees
259	mkdir ${RD}/dists
260	mkdir ${RD}/kernels
261	for i in ${DISTRIBUTIONS} ; do \
262		mkdir ${RD}/trees/$$i && \
263		mkdir ${RD}/dists/$$i && \
264		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
265		    -p ${RD}/trees/$$i > /dev/null && \
266		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
267		    -p ${RD}/trees/$$i/usr > /dev/null && \
268		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
269		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
270		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
271		    -p ${RD}/trees/$$i/var > /dev/null ; \
272	done
273	touch release.1
274
275# Install the system into the various distributions.
276release.2:
277	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/bin
278	cd ${.CURDIR}/.. && make distribute DISTDIR=${RD}/trees
279.if exists(${.CURDIR}/../kerberosIV) && !defined(NOKERBEROS)
280	cd ${.CURDIR}/../kerberosIV && ( \
281		make bootstrap &&\
282		make obj all help-distribute DISTDIR=${RD}/trees &&\
283		make kprog \
284	)
285.endif
286	-chflags -R noschg ${RD}/trees
287	touch release.2
288
289# Make and install the generic kernel(s).
290release.3:
291.for kernel in ${KERNELS}
292	rm -f ${RD}/kernels/${kernel}
293	rm -rf ${.CURDIR}/../sys/compile/${kernel}
294	cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=${kernel}
295	rm -rf ${.CURDIR}/../sys/compile/${kernel}
296	ln -f ${RD}/kernels/${kernel} ${RD}/trees/bin/kernel.${kernel}
297.endfor
298	touch release.3
299
300# Make and install the three crunched binaries which live on the floppies.
301# You are not supposed to like this :-)
302#
303# NB: the "RELEASE_BUILD_FIXIT" magic prevents vi from including the
304# Tcl and Perl APIs.  See also /usr/src/usr.bin/vi/Makefile.
305release.4:
306	@mkdir -p /stand
307	cd ${.CURDIR}/sysinstall && make obj depend all install
308	rm -rf ${RD}/crunch
309	mkdir -p ${RD}/crunch
310	export RELEASE_BUILD_FIXIT=noway ; \
311	for j in ${CRUNCH_TARGETS} ; do \
312		rm -rf $${j}_crunch && \
313		mkdir $${j}_crunch && \
314		( cd $${j}_crunch && \
315		  crunchgen ${.CURDIR}/$${j}_crunch.conf && \
316		  ${MAKE} -DRELEASE_CRUNCH -f $${j}_crunch.mk subclean all \
317		    NOCRYPT=yes "CFLAGS=${CFLAGS} -DCRUNCHED_BINARY") && \
318		mv $${j}_crunch/$${j}_crunch ${RD}/crunch/$${j} && \
319		true || { rm -rf $${j}_crunch ; false ; } ; \
320	done
321	touch release.4
322
323#
324# --==## Fix up the distributions. ##==--
325#
326release.5:
327	# Handle some grief caused by the munition braindeadness.
328	for i in sbin/init bin/ed usr.sbin/ppp ; do \
329		( cd ${.CURDIR}/../$$i; \
330		  make -DNOCRYPT clean all distribute DISTDIR=${RD}/trees ) ; \
331	done
332
333	# Create any "synthetic dists" now.
334	@for i in ${DISTRIBUTIONS}; do \
335		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
336			echo -n "Running $$i dist creation script... "; \
337			env OBJFORMAT=${OBJFORMAT} RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
338			echo "Done."; \
339		fi \
340	done \
341
342	# Create symlinks for the MD5-based crypt lib, too.  The
343	# automatically created links still point to the DES stuff,
344	# which went into its own distribution.
345	for i in ${RD}/trees/bin/usr/lib/libscrypt* ; do \
346		c=`echo $$i | sed -e 's/libscrypt/libcrypt/'` ; \
347		rm -f $$c ; \
348		ln -s `basename $$i` $$c ; \
349	done
350
351	# Remove all the directories we don't need.
352	-cd ${RD}/trees && \
353		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
354	touch release.5
355
356#
357# --==## Package up the tarballs from assembled trees ##==--
358#
359release.6:
360	rm -rf ${RD}/dists
361	mkdir -p ${RD}/dists
362	@for i in ${DISTRIBUTIONS} ; \
363	do \
364		if [ -d ${RD}/trees/$${i} ] ; then \
365			cd ${.CURDIR} && $(MAKE) doTARBALL \
366				SD=${RD}/trees/$${i} \
367				TN=$$i TD=$$i ARG="." && \
368			echo "$${i} distribution is finished."; \
369		fi ; \
370	done
371	# More munition braindeadness.
372	( cd ${RD}/dists && \
373		if [ -f krb/krb.aa ] ; then mv krb/* des && rmdir krb ; fi )
374	touch release.6
375
376
377#
378# --==## Make source dists ##==--
379#
380release.7:
381.if !defined(NOSRC)
382	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
383		TD=src TN=sbase ARG="[A-Z]*"
384	@for i in `cd /usr/src && echo [a-z]*` ; do \
385		if [ -d /usr/src/$$i ] ; then \
386			cd ${.CURDIR} && $(MAKE) doTARBALL \
387				TN=`echo s$$i | tr -d '.' | sed 's/usr/u/'` \
388				SD=/usr/src TD=src ARG="$$i" ; \
389		fi ; \
390	done
391.if defined(EXTRA_SRC)
392	@set ${EXTRA_SRC} && \
393	while [ $$# -ge 2 ] ; do \
394		if [ -d /usr/src/$$1 ] ; then \
395			cd ${.CURDIR} && $(MAKE) doTARBALL \
396				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
397		fi && shift && shift ; \
398	done
399.endif
400	( cd ${RD}/dists/src && \
401		if [ -f ssecure.aa ] ; then mv ssecure.* ../des ; fi && \
402		if [ -f scrypto.aa ] ; then mv scrypto.* ../des ; fi && \
403		if [ -f skerbero.aa ] ; then mv skerbero.* ../des ; fi ; )
404	@echo "src distribution is finished."
405.endif
406	touch release.7
407
408# Complete the bootfd
409#
410# Now, just to get this picture down once and for all:
411#
412# +------------------------------------------------------------------------+
413# |boot.flp                                                                |
414# +-----+-----+------------------------------------------------------------+
415# |boot1|boot2|floppy filesystem "bootfd"                                  |
416# +-----+-----+-+--------------------------------------------------------+-+
417#               |kernel                                                  |
418#               +------------+-----------------------------------------+-+
419#                            |mfs filesystem "mfsfd"                   |
420#                            +-----------------------------------------+
421#
422
423release.8: write_mfs_in_kernel dumpnlist
424	rm -rf ${RD}/mfsfd
425	mkdir ${RD}/mfsfd
426	cd ${RD}/mfsfd && \
427		mkdir -p etc dev mnt stand/help
428	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
429		DIR=${RD}/mfsfd/stand ZIP=false
430	( cd ${RD}/trees/bin/dev && \
431		ls console tty ttyv0 ttyv1 ttyv2 ttyv3 null zero | \
432	cpio -dump ${RD}/mfsfd/dev )
433	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
434	cd ${RD}/trees/bin && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
435	echo "nameserver      42/tcp name"	> ${RD}/mfsfd/stand/etc/services
436	echo "ftp             21/tcp"		>> ${RD}/mfsfd/stand/etc/services
437	echo "domain          53/tcp          nameserver" >> ${RD}/mfsfd/stand/etc/services
438	echo "domain          53/udp          nameserver" >> ${RD}/mfsfd/stand/etc/services
439	echo "cmd             514/tcp    shell" >> ${RD}/mfsfd/stand/etc/services
440	gzip -9c ${.CURDIR}/../COPYRIGHT > ${RD}/mfsfd/stand/help/COPYRIGHT.hlp.gz
441	for i in README.TXT RELNOTES.TXT INSTALL.TXT UPGRADE.TXT HARDWARE.TXT; do \
442	   gzip -9c ${.CURDIR}/texts/$${i} > ${RD}/mfsfd/stand/help/$${i}.gz; done
443	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
444	@mkdir -p ${RD}/mfsfd/boot
445	@cp /boot/boot* ${RD}/mfsfd/boot
446	@echo "Making the regular boot floppy."
447	@tar --exclude CVS -cf - -C ${.CURDIR}/sysinstall help | \
448		tar xf - -C ${RD}/mfsfd/stand
449	@echo "Compressing doc files..."
450	@gzip -9 ${RD}/mfsfd/stand/help/*.hlp
451	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
452		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
453	@gzip -9vc mfsroot > mfsroot.gz
454	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
455		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
456	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
457	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot BIGBOOT=YES
458	@rm mfsroot mfsroot.gz mfsroot.size
459	@echo "Regular and MFS boot floppies made."
460	touch release.8
461
462#
463# --==## Create a fixit floppy ##==--
464#
465release.9:
466	@echo "Making fixit floppy."
467	@rm -rf ${RD}/fixitfd
468	@mkdir ${RD}/fixitfd
469	@cd ${RD}/fixitfd && \
470		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
471		usr/share/misc
472	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
473		DIR=${RD}/fixitfd/stand ZIP=false
474	@( cd ${RD}/fixitfd/dev && \
475		sed -e '/^PATH/s/^/#/' ${RD}/trees/bin/dev/MAKEDEV > MAKEDEV && \
476		chmod 755 MAKEDEV && \
477		sh MAKEDEV all )
478	@cp ${RD}/trees/bin/etc/spwd.db ${RD}/trees/bin/etc/group \
479		${RD}/trees/bin/etc/protocols ${RD}/fixitfd/etc
480	@cp ${RD}/trees/bin/usr/share/misc/scsi_modes \
481		${RD}/fixitfd/usr/share/misc
482	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
483	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
484	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
485	@chmod 555 ${RD}/fixitfd/stand/tar
486	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
487		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
488# Do our last minute floppies directory setup in a convenient place.
489	@cp ${.CURDIR}/texts/FLOPPIES.TXT ${RD}/floppies/README.TXT
490	@(cd ${RD}/floppies; md5 * > CHECKSUM.MD5)
491	touch release.9
492
493#
494# --==## Setup a suitable ftp-area ##==--
495#
496ftp.1:
497	@echo "Setting up FTP distribution area"
498	@mkdir -p ${FD}
499	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
500	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
501	@for i in ${DIST_DOCS}; do cp ${.CURDIR}/texts/$${i} ${FD}; done
502	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
503.if !defined(NOPORTS)
504	@tar -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
505.endif
506
507#
508# --==## Setup a suitable cdrom-area ##==--
509#
510cdrom.1:
511	@echo "Setting up CDROM distribution area"
512	@mkdir -p ${CD_DISC1} ${CD_DISC2}
513	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
514	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
515	@ln -f ${RD}/kernels/MFSKERNEL.boot ${CD_DISC1}/kernel
516	@for i in ${DISTRIBUTIONS} ; \
517	do \
518		if [ -d ${RD}/trees/$${i} ] ; then \
519			chflags -R noschg ${RD}/trees/$${i} || true ; \
520			( cd ${RD}/trees/$${i} && \
521			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
522		fi \
523	done
524	@rm -f ${CD_DISC2}/.profile
525	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
526	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
527	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
528	@for i in ${DIST_DOCS}; do cp ${.CURDIR}/texts/$${i} ${CD_DISC1}; done
529.if !defined(NOPORTS)
530	@-rm -rf /usr/ports/distfiles/*
531	@mkdir -p ${CD_DISC1}/ports && \
532	  tar -czf ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
533	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
534	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
535.endif
536
537doc.1:
538	@echo "Making docs..."
539	@for i in ${DOCPORTS}; do \
540	  cd /usr/ports/$$i && make all install clean JADETEX=no FORCE_PKG_REGISTER=yes; \
541	done
542	@cd /usr/doc && make all distribute DISTDIR=${RD}/trees
543	touch doc.1
544
545# Various "subroutine" and other supporting targets.
546
547doTARBALL:
548.if !defined(SD)
549	@echo "SD undefined in doTARBALL" && exit 1
550.endif
551.if !defined(TD)
552	@echo "TB undefined in doTARBALL" && exit 1
553.endif
554.if !defined(ARG)
555	@echo "ARG undefined in doTARBALL" && exit 1
556.endif
557	@rm -rf ${RD}/dists/${TD}/${TN}*
558	@mkdir -p ${RD}/dists/${TD}
559	@( cd ${SD} && \
560		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
561		echo rolling ${TD}/$$tn tarball &&\
562		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
563		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
564		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
565		   ${RD}/dists/${TD}/$$tn.inf && \
566		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
567		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
568		fi && \
569		if [ "${SD}" != "/usr/src" ]; then \
570			mtree -c -i -p ${SD}/${ARG} \
571			  -k gname,md5digest,mode,nlink,uname,size,link,type \
572			  > ${RD}/dists/${TD}/$$tn.mtree ; \
573		else \
574			true; \
575		fi; \
576		(cd ${RD}/dists/${TD}; \
577		   rm -f CHECKSUM.MD5; \
578		   md5 * > CHECKSUM.MD5) \
579	)
580
581doRELEASE:  release.1 release.2 ${DOCREL} release.3 release.4 release.5 \
582		release.6 release.7 release.8 release.9
583	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
584	@echo "Release done"
585
586floppies:
587	@cd ${.CURDIR} && ${MAKE} boot.flp
588	@cd ${.CURDIR} && ${MAKE} fixit.flp
589	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
590
591boot.flp:
592	@rm -f release.4 release.8
593	@cd ${.CURDIR} && ${MAKE} release.4 release.8 CRUNCH_TARGETS=boot
594
595fixit.flp:
596	@rm -f release.4 release.9
597	@cd ${.CURDIR} && ${MAKE} release.4 release.9 CRUNCH_TARGETS=fixit
598
599write_mfs_in_kernel:	${.CURDIR}/write_mfs_in_kernel.c
600	${CC} ${CFLAGS} -o write_mfs_in_kernel ${.CURDIR}/write_mfs_in_kernel.c
601
602# Add -DDO_SCSI to CFLAGS to enable scsi frobbing support.
603dumpnlist:	${.CURDIR}/dumpnlist.c
604	${CC} ${CFLAGS} -o dumpnlist ${.CURDIR}/dumpnlist.c
605
606installCRUNCH:
607.if !defined(CRUNCH)
608	@echo "CRUNCH undefined in installCRUNCH" && exit 1
609.endif
610.if !defined(DIR)
611	@echo "DIR undefined in installCRUNCH" && exit 1
612.endif
613.if !defined(ZIP)
614	@echo "ZIP undefined in installCRUNCH" && exit 1
615.endif
616	@if ${ZIP} ; then \
617		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
618	else \
619		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
620	fi
621	@chmod 555 ${DIR}/${CRUNCH}_crunch
622	@for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
623		ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
624	done
625
626#
627# --==## Compile a kernel by name ${KERNEL} ##==--
628#
629# We don't erase the sys/compile/${KERNEL} directory, since somebody
630# may want to reuse it (release.8 presently)
631#
632doKERNEL:
633	@rm -f ${RD}/kernels/${KERNEL}
634	@cd ${.CURDIR}/../sys/${MACHINE_ARCH}/conf && config ${KERNEL}
635	@cd ${.CURDIR}/../sys/compile/${KERNEL} && \
636			make  depend && \
637			make  kernel && \
638			cp kernel ${RD}/kernels/${KERNEL}
639
640#
641# --==## Put a filesystem into a BOOTMFS kernel ##==--
642#
643doMFSKERN:
644	@echo "Running doMFSKERN for ${FSIMAGE}"
645	@rm -f ${RD}/kernels/BOOTMFS.${FSIMAGE}
646	@cd ${.CURDIR}/../sys/${MACHINE_ARCH}/conf && \
647	  sh ${.CURDIR}/scripts/dokern.sh ${BIGBOOT} < GENERIC > BOOTMFS
648.if ${MACHINE_ARCH} == "i386"
649	@echo "options  INTRO_USERCONFIG" >> ${.CURDIR}/../sys/i386/conf/BOOTMFS
650.endif
651.if defined(BIGBOOT)
652	@echo "options \"MFS_ROOT_SIZE=`cat mfsroot.size`\"" >> \
653	  ${.CURDIR}/../sys/${MACHINE_ARCH}/conf/BOOTMFS
654.endif
655	@cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=BOOTMFS
656	@rm -rf ${RD}/image.${FSIMAGE}
657	@mkdir  ${RD}/image.${FSIMAGE}
658	@cp ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
659	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
660	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
661	@mkdir -p ${RD}/image.${FSIMAGE}/boot
662	@cp /boot/boot[12] /boot/loader ${RD}/image.${FSIMAGE}/boot
663.if !defined(BIGBOOT) || ${MACHINE_ARCH} == "alpha"
664	@echo "load /kernel" > ${RD}/image.${FSIMAGE}/boot/loader.rc
665	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
666	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
667	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
668	@echo "boot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
669	@touch ${RD}/image.${FSIMAGE}/boot/loader.config
670.endif
671.if defined(BIGBOOT)
672	@echo "Writing MFS image into kernel for ${FSIMAGE} floppy"
673	@./write_mfs_in_kernel ${RD}/image.${FSIMAGE}/kernel mfsroot
674	@cp ${RD}/image.${FSIMAGE}/kernel ${RD}/kernels/MFSKERNEL.${FSIMAGE}
675.endif
676	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
677	@touch ${RD}/image.${FSIMAGE}/kernel.config
678	@rm -f ${RD}/floppies/${FSIMAGE}.flp
679.if defined(BIGBOOT)
680	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
681		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
682		${BOOTINODE} ${BIGBOOTLABEL}
683.else
684	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
685		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
686		${BOOTINODE} ${BOOTLABEL}
687.endif
688	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
689
690.include <bsd.prog.mk>
691