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