Makefile revision 36471
1#	$Id: Makefile,v 1.352 1998/05/29 19:36:12 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# 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 240640 -
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.if exists(/usr/lib/aout/)
215	echo "mkdir -p /usr/lib/compat/aout"	>> ${CHROOTDIR}/mk
216	echo "chflags noschg /usr/lib/aout/lib*.so.*" >> ${CHROOTDIR}/mk
217	echo "mv /usr/lib/aout/lib*.so.* /usr/lib/compat/aout" >> ${CHROOTDIR}/mk
218	echo "ldconfig /usr/lib/compat/aout" 	>> ${CHROOTDIR}/mk
219.else
220	echo "mkdir -p /usr/lib/compat"		>> ${CHROOTDIR}/mk
221	echo "chflags noschg /usr/lib/lib*.so.*" >> ${CHROOTDIR}/mk
222	echo "mv /usr/lib/lib*.so.* /usr/lib/compat" >> ${CHROOTDIR}/mk
223	echo "ldconfig /usr/lib /usr/lib/compat" >> ${CHROOTDIR}/mk
224.endif
225	echo "(cd include; make all install)"   >> ${CHROOTDIR}/mk
226	echo "(cd etc; make distrib-dirs distribution)" >> ${CHROOTDIR}/mk
227	echo "make world"			>> ${CHROOTDIR}/mk
228	echo "(cd etc; make distribution)"	>> ${CHROOTDIR}/mk
229	# Now we've got our own shared libs, remove the bootstrapping
230	# libs again.
231.if !exists(/usr/lib/aout/)
232	echo "rm -f /usr/lib/compat/*"		>> ${CHROOTDIR}/mk
233	echo "ldconfig /usr/lib"		>> ${CHROOTDIR}/mk
234.endif
235.endif
236.if make(rerelease)
237	echo "make all install"			>> ${CHROOTDIR}/mk
238.endif
239	echo "cd /usr/src/release/sysinstall"	>> ${CHROOTDIR}/mk
240	echo "make obj"				>> ${CHROOTDIR}/mk
241	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
242	echo "make objlink"			>> ${CHROOTDIR}/mk
243	echo "(cd obj; rm -f ${REDOREDO})"	>> ${CHROOTDIR}/mk
244	echo "make doRELEASE"			>> ${CHROOTDIR}/mk
245	echo "echo make ${.TARGET} Finished"	>> ${CHROOTDIR}/mk
246	chmod 755 ${CHROOTDIR}/mk
247	chroot ${CHROOTDIR} /mk
248
249clean:
250	rm -rf boot_crunch release.[0-9]
251
252# Clean out /R and make the directory structure.
253release.1:
254	-mkdir /R
255	chflags -R noschg /R/.
256	rm -rf /R/*
257	mkdir ${RD}
258	mkdir ${RD}/floppies
259	mkdir ${RD}/trees
260	mkdir ${RD}/dists
261	mkdir ${RD}/kernels
262	for i in ${DISTRIBUTIONS} ; do \
263		mkdir ${RD}/trees/$$i && \
264		mkdir ${RD}/dists/$$i && \
265		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
266		    -p ${RD}/trees/$$i > /dev/null && \
267		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
268		    -p ${RD}/trees/$$i/usr > /dev/null && \
269		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
270		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
271		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
272		    -p ${RD}/trees/$$i/var > /dev/null ; \
273	done
274	touch release.1
275
276# Install the system into the various distributions.
277release.2:
278	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/bin
279	cd ${.CURDIR}/.. && make distribute DISTDIR=${RD}/trees
280.if exists(${.CURDIR}/../kerberosIV) && !defined(NOKERBEROS)
281	cd ${.CURDIR}/../kerberosIV && ( \
282		make bootstrap &&\
283		make obj all help-distribute DISTDIR=${RD}/trees &&\
284		make kprog \
285	)
286.endif
287	chflags -R noschg ${RD}/trees
288	touch release.2
289
290# Make and install the generic kernel(s).
291release.3:
292.for kernel in ${KERNELS}
293	rm -f ${RD}/kernels/${kernel}
294	rm -rf ${.CURDIR}/../sys/compile/${kernel}
295	cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=${kernel}
296	rm -rf ${.CURDIR}/../sys/compile/${kernel}
297	ln -f ${RD}/kernels/${kernel} ${RD}/trees/bin/kernel.${kernel}
298.endfor
299	touch release.3
300
301# Make and install the three crunched binaries which live on the floppies.
302# You are not supposed to like this :-)
303#
304# NB: the "RELEASE_BUILD_FIXIT" magic prevents vi from including the
305# Tcl and Perl APIs.  See also /usr/src/usr.bin/vi/Makefile.
306release.4:
307	@mkdir -p /stand
308	cd ${.CURDIR}/sysinstall && make obj depend all install
309	rm -rf ${RD}/crunch
310	mkdir -p ${RD}/crunch
311	export RELEASE_BUILD_FIXIT=noway ; \
312	for j in ${CRUNCH_TARGETS} ; do \
313		rm -rf $${j}_crunch && \
314		mkdir $${j}_crunch && \
315		( cd $${j}_crunch && \
316		crunchgen ${.CURDIR}/$${j}_crunch.conf && \
317		${MAKE} -DRELEASE_CRUNCH -f $${j}_crunch.mk subclean all \
318		    NOCRYPT=yes "CFLAGS=${CFLAGS} -DCRUNCHED_BINARY") && \
319		mv $${j}_crunch/$${j}_crunch ${RD}/crunch/$${j} && \
320		true || { rm -rf $${j}_crunch ; false ; } ; \
321	done
322	touch release.4
323
324#
325# --==## Fix up the distributions. ##==--
326#
327release.5:
328	# Handle some grief caused by the munition braindeadness.
329	for i in sbin/init bin/ed ; do \
330		( cd ${.CURDIR}/../$$i; \
331		  make -DNOCRYPT clean all distribute DISTDIR=${RD}/trees ) ; \
332	done
333
334	# Create any "synthetic dists" now.
335	@for i in ${DISTRIBUTIONS}; do \
336		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
337			echo -n "Running $$i dist creation script... "; \
338			env RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
339			echo "Done."; \
340		fi \
341	done \
342
343	# Create symlinks for the MD5-based crypt lib, too.  The
344	# automatically created links still point to the DES stuff,
345	# which went into its own distribution.
346	for i in ${RD}/trees/bin/usr/lib/libscrypt* ; do \
347		c=`echo $$i | sed -e 's/libscrypt/libcrypt/'` ; \
348		rm -f $$c ; \
349		ln -s `basename $$i` $$c ; \
350	done
351
352	# Remove all the directories we don't need.
353	-cd ${RD}/trees && \
354		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
355	touch release.5
356
357#
358# --==## Package up the tarballs from assembled trees ##==--
359#
360release.6:
361	rm -rf ${RD}/dists
362	mkdir -p ${RD}/dists
363	@for i in ${DISTRIBUTIONS} ; \
364	do \
365		if [ -d ${RD}/trees/$${i} ] ; then \
366			cd ${.CURDIR} && $(MAKE) doTARBALL \
367				SD=${RD}/trees/$${i} \
368				TN=$$i TD=$$i ARG="." && \
369			echo "$${i} distribution is finished."; \
370		fi ; \
371	done
372	# More munition braindeadness.
373	( cd ${RD}/dists && \
374		if [ -f krb/krb.aa ] ; then mv krb/* des && rmdir krb ; fi )
375	touch release.6
376
377
378#
379# --==## Make source dists ##==--
380#
381release.7:
382.if !defined(NOSRC)
383	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
384		TD=src TN=sbase ARG="[A-Z]*"
385	@for i in `cd /usr/src && echo [a-z]*` ; do \
386		if [ -d /usr/src/$$i ] ; then \
387			cd ${.CURDIR} && $(MAKE) doTARBALL \
388				TN=`echo s$$i | tr -d '.' | sed 's/usr/u/'` \
389				SD=/usr/src TD=src ARG="$$i" ; \
390		fi ; \
391	done
392.if defined(EXTRA_SRC)
393	@set ${EXTRA_SRC} && \
394	while [ $$# -ge 2 ] ; do \
395		if [ -d /usr/src/$$1 ] ; then \
396			cd ${.CURDIR} && $(MAKE) doTARBALL \
397				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
398		fi && shift && shift ; \
399	done
400.endif
401	( cd ${RD}/dists/src && \
402		if [ -f ssecure.aa ] ; then mv ssecure.* ../des ; fi && \
403		if [ -f scrypto.aa ] ; then mv scrypto.* ../des ; fi && \
404		if [ -f skerbero.aa ] ; then mv skerbero.* ../des ; fi ; )
405	@echo "src distribution is finished."
406.endif
407	touch release.7
408
409# Complete the bootfd
410#
411# Now, just to get this picture down once and for all:
412#
413# +------------------------------------------------------------------------+
414# |boot.flp                                                                |
415# +-----+-----+------------------------------------------------------------+
416# |boot1|boot2|floppy filesystem "bootfd"                                  |
417# +-----+-----+-+--------------------------------------------------------+-+
418#               |kernel                                                  |
419#               +------------+-----------------------------------------+-+
420#                            |mfs filesystem "mfsfd"                   |
421#                            +-----------------------------------------+
422#
423
424release.8: write_mfs_in_kernel dumpnlist
425	rm -rf ${RD}/mfsfd
426	mkdir ${RD}/mfsfd
427	cd ${RD}/mfsfd && \
428		mkdir -p etc dev mnt stand/help
429	@cp ${.CURDIR}/../sys/i386/boot/biosboot/boot.help ${RD}/mfsfd/stand
430	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
431		DIR=${RD}/mfsfd/stand ZIP=false
432	( cd ${RD}/trees/bin/dev && \
433		ls console tty ttyv0 ttyv1 ttyv2 ttyv3 null zero | \
434	cpio -dump ${RD}/mfsfd/dev )
435	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
436	cd ${RD}/trees/bin && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
437	echo "nameserver      42/tcp name"	> ${RD}/mfsfd/stand/etc/services
438	echo "ftp             21/tcp"		>> ${RD}/mfsfd/stand/etc/services
439	echo "domain          53/tcp          nameserver" >> ${RD}/mfsfd/stand/etc/services
440	echo "domain          53/udp          nameserver" >> ${RD}/mfsfd/stand/etc/services
441	echo "cmd             514/tcp    shell" >> ${RD}/mfsfd/stand/etc/services
442	gzip -c ${.CURDIR}/../COPYRIGHT > ${RD}/mfsfd/stand/help/COPYRIGHT.hlp.gz
443	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
444	@echo "Making the regular boot floppy."
445	tar --exclude CVS -cf - -C ${.CURDIR}/sysinstall help | \
446		tar xvf - -C ${RD}/mfsfd/stand
447	@echo "Compressing doc files..."
448	@gzip -9 ${RD}/mfsfd/stand/help/*.hlp
449	sh -e ${.CURDIR}/doFS.sh ${RD} ${MNT} ${BOOTMFSSIZE} ${RD}/mfsfd \
450		${MFSINODE} minimum
451	mv fs-image fs-image.std
452	mv fs-image.size fs-image.std.size
453	cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=std
454	mv ${RD}/floppies/bootstd.flp ${RD}/floppies/boot.flp
455	@echo "Regular boot floppy made."
456	touch release.8
457
458#
459# --==## Create a fixit floppy ##==--
460#
461release.9:
462	rm -rf ${RD}/fixitfd
463	mkdir ${RD}/fixitfd
464	cd ${RD}/fixitfd && \
465		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
466		usr/share/misc usr/mdec
467	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
468		DIR=${RD}/fixitfd/stand ZIP=false
469	( cd ${RD}/fixitfd/dev && \
470		sed -e '/^PATH/s/^/#/' ${RD}/trees/bin/dev/MAKEDEV > MAKEDEV && \
471		chmod 755 MAKEDEV && \
472		sh MAKEDEV all )
473	cp ${RD}/trees/bin/etc/spwd.db ${RD}/trees/bin/etc/group \
474		${RD}/trees/bin/etc/protocols ${RD}/fixitfd/etc
475	cp ${RD}/trees/bin/usr/share/misc/scsi_modes \
476		${RD}/fixitfd/usr/share/misc
477	cp ${RD}/trees/bin/usr/mdec/boot[12] ${RD}/fixitfd/usr/mdec
478	for type in fd od sd wd ; do \
479		( cd ${RD}/fixitfd/usr/mdec && ln -s boot1 $${type}boot && \
480			ln -s boot2 boot$${type} ) ; \
481	done
482	cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
483	cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
484	cp ${.CURDIR}/tar.sh ${RD}/fixitfd/stand/tar
485	chmod 555 ${RD}/fixitfd/stand/tar
486	sh -e ${.CURDIR}/doFS.sh ${RD} ${MNT} ${FDSIZE} ${RD}/fixitfd \
487		${FIXITINODE} ${FDLABEL}
488	mv fs-image ${RD}/floppies/fixit.flp
489# Do our last minute floppies directory setup in a convenient place.
490	cp ${.CURDIR}/README.TXT ${RD}/floppies/README.TXT
491	@(cd ${RD}/floppies; md5 * > CHECKSUM.MD5)
492	touch release.9
493
494#
495# --==## Setup a suitable ftp-area ##==--
496#
497ftp.1:
498	mkdir -p ${FD}
499	cd ${RD} && find floppies -print | cpio -dumpl ${FD}
500	cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
501	cp ${.CURDIR}/ABOUT.TXT ${FD}/ABOUT.TXT
502	cp ${.CURDIR}/sysinstall/help/readme.hlp ${FD}/README.TXT
503	cp ${.CURDIR}/sysinstall/help/hardware.hlp ${FD}/HARDWARE.TXT
504	cp ${.CURDIR}/sysinstall/help/install.hlp ${FD}/INSTALL.TXT
505	cp ${.CURDIR}/sysinstall/help/relnotes.hlp ${FD}/RELNOTES.TXT
506	echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
507.if !defined(NOPORTS)
508	tar -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
509.endif
510
511#
512# --==## Setup a suitable cdrom-area ##==--
513#
514cdrom.1:
515	mkdir -p ${CD_DISC1} ${CD_DISC2}
516	cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
517	cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
518	ln -f ${RD}/kernels/MFSKERNEL.std ${CD_DISC1}/kernel
519	ln -f ${RD}/trees/bin/usr/mdec/fbsdboot.exe ${CD_DISC1}
520	for i in ${DISTRIBUTIONS} ; \
521	do \
522		if [ -d ${RD}/trees/$${i} ] ; then \
523			chflags -R noschg ${RD}/trees/$${i} ; \
524			( cd ${RD}/trees/$${i} && \
525			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
526		fi \
527	done
528	rm -f ${CD_DISC2}/.profile
529	cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
530	echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
531	echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
532	cp ${.CURDIR}/ABOUT.TXT ${CD_DISC1}/ABOUT.TXT
533	cp ${.CURDIR}/sysinstall/help/readme.hlp ${CD_DISC1}/README.TXT
534	cp ${.CURDIR}/sysinstall/help/hardware.hlp ${CD_DISC1}/HARDWARE.TXT
535	cp ${.CURDIR}/sysinstall/help/install.hlp ${CD_DISC1}/INSTALL.TXT
536	cp ${.CURDIR}/sysinstall/help/relnotes.hlp ${CD_DISC1}/RELNOTES.TXT
537.if !defined(NOPORTS)
538	-rm -rf /usr/ports/distfiles/*
539	tar -cBf - -C /usr ports | tar xBpf - -C ${CD_DISC2} && \
540	  mkdir -p ${CD_DISC1}/ports && \
541	  tar -czf ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
542	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh && \
543		(cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
544	ln -s ../ports ${CD_DISC2}/usr/ports
545.endif
546
547doc.1:
548	for i in ${DOCPORTS}; do \
549	  cd /usr/ports/$$i && make all install clean FORCE_PKG_REGISTER=yes; \
550	done
551	cd /usr/doc && make all distribute DISTDIR=${RD}/trees
552
553# Various "subroutine" and other supporting targets.
554
555doTARBALL:
556.if !defined(SD)
557	@echo "SD undefined in doTARBALL" && exit 1
558.endif
559.if !defined(TD)
560	@echo "TB undefined in doTARBALL" && exit 1
561.endif
562.if !defined(ARG)
563	@echo "ARG undefined in doTARBALL" && exit 1
564.endif
565	rm -rf ${RD}/dists/${TD}/${TN}*
566	mkdir -p ${RD}/dists/${TD}
567	( cd ${SD} && \
568		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
569		echo rolling ${TD}/$$tn tarball &&\
570		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
571		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
572		sh ${.CURDIR}/info.sh ${RD}/dists/${TD}/$$tn > \
573		   ${RD}/dists/${TD}/$$tn.inf && \
574		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
575		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
576		fi && \
577		if [ "${SD}" != "/usr/src" ]; then \
578			mtree -c -i -p ${SD}/${ARG} \
579			  -k gname,md5digest,mode,nlink,uname,size,link,type \
580			  > ${RD}/dists/${TD}/$$tn.mtree ; \
581		else \
582			true; \
583		fi; \
584		(cd ${RD}/dists/${TD}; \
585		   rm -f CHECKSUM.MD5; \
586		   md5 * > CHECKSUM.MD5) \
587	)
588
589doRELEASE:  release.1 release.2 ${DOCREL} release.3 release.4 release.5 \
590		release.6 release.7 release.8 release.9
591	cd ${.CURDIR} && ${MAKE} ${EXTRAS}
592	@echo "Release done"
593
594floppies:
595	cd ${.CURDIR} && ${MAKE} boot.flp
596	cd ${.CURDIR} && ${MAKE} fixit.flp
597	cd ${RD} && find floppies -print | cpio -dumpl ${FD}
598
599boot.flp:
600	rm -f release.4 release.8
601	cd ${.CURDIR} && ${MAKE} release.4 release.8 CRUNCH_TARGETS=boot
602
603fixit.flp:
604	rm -f release.4 release.9
605	cd ${.CURDIR} && ${MAKE} release.4 release.9 CRUNCH_TARGETS=fixit
606
607write_mfs_in_kernel:	${.CURDIR}/write_mfs_in_kernel.c
608	${CC} ${CFLAGS} -o write_mfs_in_kernel ${.CURDIR}/write_mfs_in_kernel.c
609
610dumpnlist:	${.CURDIR}/dumpnlist.c
611	${CC} ${CFLAGS} -o dumpnlist ${.CURDIR}/dumpnlist.c
612
613installCRUNCH:
614.if !defined(CRUNCH)
615	@echo "CRUNCH undefined in installCRUNCH" && exit 1
616.endif
617.if !defined(DIR)
618	@echo "DIR undefined in installCRUNCH" && exit 1
619.endif
620.if !defined(ZIP)
621	@echo "ZIP undefined in installCRUNCH" && exit 1
622.endif
623	if ${ZIP} ; then \
624		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
625	else \
626		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
627	fi
628	chmod 555 ${DIR}/${CRUNCH}_crunch
629	for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
630		ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
631	done
632
633#
634# --==## Compile a kernel by name ${KERNEL} ##==--
635#
636# We don't erase the sys/compile/${KERNEL} directory, since somebody
637# may want to reuse it (release.8 presently)
638#
639doKERNEL:
640	rm -f ${RD}/kernels/${KERNEL}
641	cd ${.CURDIR}/../sys/i386/conf && config ${KERNEL}
642	cd ${.CURDIR}/../sys/compile/${KERNEL} && \
643			make  depend && \
644			make  kernel && \
645			cp kernel ${RD}/kernels/${KERNEL}
646
647#
648# --==## Put a filesystem into a BOOTMFS kernel ##==--
649#
650doMFSKERN:
651	@rm -f ${RD}/kernels/BOOTMFS.${FSIMAGE}
652	@rm -f /sys/compile/BOOTMFS/mfs_vfsops.o
653	@cd ${.CURDIR}/../sys/i386/conf && \
654	  sed	-e '/pty/d' \
655		-e '/PROCFS/d' \
656		-e '/KTRACE/d' \
657		-e 's/GENERIC/BOOTMFS/g' \
658		-e '/maxusers/s/10/4/' < GENERIC > BOOTMFS && \
659	  echo "options  MFS" >> BOOTMFS && \
660	  echo "options  NFS_NOSERVER" >> BOOTMFS && \
661	  echo 'options  "MAXCONS=4"' >> BOOTMFS && \
662	  echo "options  USERCONFIG_BOOT" >> BOOTMFS
663	@echo "options \"MFS_ROOT=`cat fs-image.${FSIMAGE}.size`\"" >> \
664	  ${.CURDIR}/../sys/i386/conf/BOOTMFS
665	cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=BOOTMFS
666	@rm -rf ${RD}/boot.${FSIMAGE}
667	@mkdir  ${RD}/boot.${FSIMAGE}
668	@mv ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
669	@cp ${RD}/kernels/BOOTMFS.${FSIMAGE} ${RD}/boot.${FSIMAGE}/kernel
670.if defined(BOOT_CONFIG)
671	@echo "${BOOT_CONFIG}" >${RD}/boot.${FSIMAGE}/boot.config
672.endif
673	@vnconfig /dev/${VNDEVICE} fs-image.${FSIMAGE}
674	@mkdir -p /tmp/mnt_xx
675	@mount /dev/${VNDEVICE} /tmp/mnt_xx
676	./dumpnlist ${RD}/boot.${FSIMAGE}/kernel > /tmp/mnt_xx/stand/symbols
677	@umount /tmp/mnt_xx
678	@vnconfig -u /dev/${VNDEVICE}
679	@rmdir /tmp/mnt_xx
680	./write_mfs_in_kernel ${RD}/boot.${FSIMAGE}/kernel \
681		fs-image.${FSIMAGE}
682	kzip -v ${RD}/boot.${FSIMAGE}/kernel
683	@mv ${RD}/boot.${FSIMAGE}/kernel ${RD}/kernels/MFSKERNEL.${FSIMAGE}
684	@mv ${RD}/boot.${FSIMAGE}/kernel.kz ${RD}/boot.${FSIMAGE}/kernel
685	@cp ${.CURDIR}/../sys/i386/boot/biosboot/boot.help ${RD}/boot.${FSIMAGE}
686	@touch ${RD}/boot.${FSIMAGE}/boot.config
687	@touch ${RD}/boot.${FSIMAGE}/kernel.config
688	@rm -f ${RD}/floppies/boot${FSIMAGE}.flp
689	sh -e ${.CURDIR}/doFS.sh ${RD} ${MNT} ${FDSIZE} ${RD}/boot.${FSIMAGE} \
690		${BOOTINODE} ${FDLABEL}
691	mv fs-image ${RD}/floppies/boot${FSIMAGE}.flp
692
693.include <bsd.prog.mk>
694