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