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