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