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