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