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