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