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