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