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