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