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