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