Makefile revision 32965
1#	$Id: Makefile,v 1.339 1998/01/28 04:05:10 jkh Exp $
2#
3# make release CHROOTDIR=/some/dir BUILDNAME=somename [ RELEASETAG=tag ]
4#
5# Where "/some/dir" is the pathname of a directory on a some
6# filesystem with at least 600MB of free space, "somename" is what
7# you want the release to call itself and, optionally, which CVS "tag"
8# name should be used when checking out the sources to build the release
9# (default is HEAD).
10#
11# Please note: the vn driver must also be compiled into your kernel,
12# otherwise the target 'release.8' and possibly others will fail.
13#
14# Set these, release builder!
15#
16# Fixed version:
17#BUILDNAME=2.2-RELEASE
18#
19# Automatic SNAP versioning:
20DATE != date +%y%m%d
21BASE = 3.0
22BUILDNAME?=${BASE}-${DATE}-SNAP
23#
24#CHROOTDIR=/junk/release
25# If this is a RELEASE, then set
26#RELEASETAG=RELENG_2_2
27
28# Uncomment this to disable the doc.1 target.  It is also an ERROR
29# to set NOPORTS and not set NODOC since docs depend on ports.
30#NODOC=  YES
31DOCPORTS= archivers/unzip lang/perl5 textproc/jade textproc/iso8879 \
32          textproc/linuxdoc textproc/docbook textproc/sgmlformat
33
34# Things which without too much trouble can be considered variables
35# BIN_DISTS are special in that they get full /etc installation sets.
36#
37COMPAT_DISTS?=	compat1x compat20 compat21
38OTHER_DISTS?=	manpages catpages games proflibs dict info doc
39CRYPTO_DISTS?=	krb des
40BIN_DISTS?=	bin
41DISTRIBUTIONS?=	${BIN_DISTS} ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS}
42KERNELS?=	GENERIC
43
44# Extra source tarballs; each argument is a pair of source dir and
45# distribution name.  The dist name should not exceed 7 characters
46# (another "s" for "source" will be prepended).
47EXTRA_SRC+=	usr.sbin/sendmail/cf smailcf
48
49BOOT1=	etc/protocols etc/rc.conf
50
51# mountpoint for filesystems.
52MNT=			/mnt
53
54# other floppy parameters.
55FDSIZE=			1440
56FDLABEL=		fd1440
57
58ZIPNSPLIT=		gzip --no-name -9 -c | split -b 240640 -
59
60# Upper size for the mfs in the boot.flp kernel.
61# These are adjusted down to the minimum needed by doFS.sh.
62BOOTMFSSIZE=		1440
63MFSINODE=		7000
64FIXITINODE=		2000
65BOOTINODE=		100000
66
67# Things which may get you into trouble if you change them
68MTREEFILES=		${.CURDIR}/../etc/mtree
69RD=			/R/stage
70FD=			/R/ftp
71CD=			/R/cdrom
72CD_DISC1=		${CD}/disc1
73CD_DISC2=		${CD}/disc2
74
75# Where the bootstrap ports (see DOCPORTS) get installed.
76LOCALDIR=		/usr/local/bin
77
78# ${BOOTSTRAPDIR} is for those utilities that refer to the hosting
79# environment, rather than the target environment.  This is specifically
80# intended for kernel-dependent utilities that are used during the build.
81#
82# ${BOOTSTRAPDIR} is actually being used by prepending it to the normal
83# ${PATH}.  Thus, it's also available to outside utilities like doFS.sh.
84BOOTSTRAPDIR=	/bootstrap
85#
86# The mount subsystem has been changed between 2.2 and 3.0 by the
87# Lite2 import.
88BOOTSTRAPUTILS=	/sbin/mount /sbin/umount
89#
90# 3.0 cpio tries to reference lchown(2) which is not available in 2.2
91BOOTSTRAPUTILS+= /usr/bin/cpio
92
93.if !defined(CRUNCH_TARGETS)
94CRUNCH_TARGETS=	boot fixit
95.endif
96
97EXTRAS= cdrom.1 ftp.1
98
99.if !defined(NODOC)
100DOCREL= doc.1
101.endif
102
103REDO?=		sysinstall
104REDOSED=	sed -e 's/dirs/release.1/' -e 's/trees/release.2/' \
105		    -e 's/kerns/release.3/' -e 's/sysinstall/release.4/' \
106		    -e 's/fixup/release.5/' -e 's/tarbin/release.6/' \
107		    -e 's/tarsrc/release.7/' -e 's/boot\.flp/release.8/' \
108		    -e 's/fixit\.flp/release.9/' -e 's/ftp/ftp.1/' \
109		    -e 's/cdrom/cdrom.1/'
110
111REDOREDO!=	echo ${REDO} | ${REDOSED}
112
113rerelease release:
114.if !defined(CHROOTDIR) || !defined(BUILDNAME) || !defined(CVSROOT)
115	@echo "To make a release you must set CHROOTDIR, BUILDNAME and CVSROOT" && false
116.endif
117.if make(release)
118.if exists(${CHROOTDIR})
119	chflags -R noschg ${CHROOTDIR}/.
120	-rm -rf ${CHROOTDIR}
121.endif
122	-mkdir -p ${CHROOTDIR}
123	cd ${.CURDIR}/../etc && ${MAKE} distrib-dirs DESTDIR=${CHROOTDIR}
124	cd ${.CURDIR}/../etc && ${MAKE} distribution DESTDIR=${CHROOTDIR}
125	cd ${.CURDIR}/.. && ${MAKE} install DESTDIR=${CHROOTDIR} NOMAN=1
126	mkdir ${CHROOTDIR}/${BOOTSTRAPDIR}
127	for i in ${BOOTSTRAPUTILS} ; do \
128		cp -p ${CHROOTDIR}$$i ${CHROOTDIR}/${BOOTSTRAPDIR} ; \
129	done
130.if !defined(RELEASETAG)
131	cd ${CHROOTDIR}/usr && rm -rf src && \
132		cvs -d ${CVSROOT} co -P src
133.else
134	cd ${CHROOTDIR}/usr && rm -rf src && \
135		cvs -d ${CVSROOT} co -P -r ${RELEASETAG} src
136.endif
137.if defined(LOCAL_PATCHES) && exists(${LOCAL_PATCHES})
138	cd ${CHROOTDIR}/usr/src && patch --silent < ${LOCAL_PATCHES}
139.endif
140.if !defined(NOPORTS)
141	cd ${CHROOTDIR}/usr && rm -rf ports && cvs -d ${CVSROOT} co -P ports && cd ports && make readmes
142.endif
143.if !defined(NODOC)
144	cd ${CHROOTDIR}/usr && rm -rf doc && cvs -d ${CVSROOT} co -P doc
145	cd ${CHROOTDIR}/usr/ports && for i in ${DOCPORTS}; do \
146	  (cd $$i; make fetch DISTDIR=${CHROOTDIR}/usr/ports/distfiles ); \
147        done
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}:${LOCALDIR}" >> ${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	for i in ${DOCPORTS}; do \
530	  cd /usr/ports/$$i && make all install clean FORCE_PKG_REGISTER=yes; \
531	done
532	cd /usr/doc && make all distribute DISTDIR=${RD}/trees
533
534# Various "subroutine" and other supporting targets.
535
536doTARBALL:
537.if !defined(SD)
538	@echo "SD undefined in doTARBALL" && exit 1
539.endif
540.if !defined(TD)
541	@echo "TB undefined in doTARBALL" && exit 1
542.endif
543.if !defined(ARG)
544	@echo "ARG undefined in doTARBALL" && exit 1
545.endif
546	rm -rf ${RD}/dists/${TD}/${TN}*
547	mkdir -p ${RD}/dists/${TD}
548	( cd ${SD} && \
549		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
550		echo rolling ${TD}/$$tn tarball &&\
551		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
552		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
553		sh ${.CURDIR}/info.sh ${RD}/dists/${TD}/$$tn > \
554		   ${RD}/dists/${TD}/$$tn.inf && \
555		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
556		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
557		fi && \
558		if [ "${SD}" != "/usr/src" ]; then \
559			mtree -c -i -p ${SD}/${ARG} \
560			  -k gname,md5digest,mode,nlink,uname,size,link,type \
561			  > ${RD}/dists/${TD}/$$tn.mtree ; \
562		else \
563			true; \
564		fi; \
565		(cd ${RD}/dists/${TD}; \
566		   rm -f CHECKSUM.MD5; \
567		   md5 * > CHECKSUM.MD5) \
568	)
569
570doRELEASE:  release.1 release.2 ${DOCREL} release.3 release.4 release.5 \
571		release.6 release.7 release.8 release.9
572	cd ${.CURDIR} && ${MAKE} ${EXTRAS}
573	@echo "Release done"
574
575floppies:
576	cd ${.CURDIR} && ${MAKE} boot.flp
577	cd ${.CURDIR} && ${MAKE} fixit.flp
578	cd ${RD} && find floppies -print | cpio -dumpl ${FD}
579
580boot.flp:
581	rm -f release.4 release.8
582	cd ${.CURDIR} && ${MAKE} release.4 release.8 CRUNCH_TARGETS=boot
583
584fixit.flp:
585	rm -f release.4 release.9
586	cd ${.CURDIR} && ${MAKE} release.4 release.9 CRUNCH_TARGETS=fixit
587
588write_mfs_in_kernel:	${.CURDIR}/write_mfs_in_kernel.c
589	${CC} ${CFLAGS} -o write_mfs_in_kernel ${.CURDIR}/write_mfs_in_kernel.c
590
591dumpnlist:	${.CURDIR}/dumpnlist.c
592	${CC} ${CFLAGS} -o dumpnlist ${.CURDIR}/dumpnlist.c
593
594installCRUNCH:
595.if !defined(CRUNCH)
596	@echo "CRUNCH undefined in installCRUNCH" && exit 1
597.endif
598.if !defined(DIR)
599	@echo "DIR undefined in installCRUNCH" && exit 1
600.endif
601.if !defined(ZIP)
602	@echo "ZIP undefined in installCRUNCH" && exit 1
603.endif
604	if ${ZIP} ; then \
605		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
606	else \
607		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
608	fi
609	chmod 555 ${DIR}/${CRUNCH}_crunch
610	for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
611		ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
612	done
613
614#
615# --==## Compile a kernel by name ${KERNEL} ##==--
616#
617# We don't erase the sys/compile/${KERNEL} directory, since somebody
618# may want to reuse it (release.8 presently)
619#
620doKERNEL:
621	rm -f ${RD}/kernels/${KERNEL}
622	cd ${.CURDIR}/../sys/i386/conf && config -n ${KERNEL}
623	cd ${.CURDIR}/../sys/compile/${KERNEL} && \
624			make  depend && \
625			make  kernel && \
626			cp kernel ${RD}/kernels/${KERNEL}
627
628#
629# --==## Put a filesystem into a BOOTMFS kernel ##==--
630#
631doMFSKERN:
632	@rm -f ${RD}/kernels/BOOTMFS.${FSIMAGE}
633	@rm -f /sys/compile/BOOTMFS/mfs_vfsops.o
634	@cd ${.CURDIR}/../sys/i386/conf && \
635	  sed	-e '/SYSV/d' \
636		-e '/pty/d' \
637		-e '/PROCFS/d' \
638		-e '/KTRACE/d' \
639		-e 's/GENERIC/BOOTMFS/g' \
640		-e '/maxusers/s/10/4/' < GENERIC > BOOTMFS && \
641	  echo "options  MFS" >> BOOTMFS && \
642	  echo "options  NFS_NOSERVER" >> BOOTMFS && \
643	  echo 'options  "MAXCONS=4"' >> BOOTMFS && \
644	  echo "options  USERCONFIG_BOOT" >> BOOTMFS
645	@echo "options \"MFS_ROOT=`cat fs-image.${FSIMAGE}.size`\"" >> \
646	  ${.CURDIR}/../sys/i386/conf/BOOTMFS
647	cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=BOOTMFS
648	@rm -rf ${RD}/boot.${FSIMAGE}
649	@mkdir  ${RD}/boot.${FSIMAGE}
650	@mv ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
651	@cp ${RD}/kernels/BOOTMFS.${FSIMAGE} ${RD}/boot.${FSIMAGE}/kernel
652.if defined(BOOT_CONFIG)
653	@echo "${BOOT_CONFIG}" >${RD}/boot.${FSIMAGE}/boot.config
654.endif
655	@vnconfig /dev/vn0 fs-image.${FSIMAGE}
656	@mkdir -p /tmp/mnt_xx
657	@mount /dev/vn0 /tmp/mnt_xx
658	./dumpnlist ${RD}/boot.${FSIMAGE}/kernel > /tmp/mnt_xx/stand/symbols
659	@umount /tmp/mnt_xx
660	@vnconfig -u /dev/vn0
661	@rmdir /tmp/mnt_xx
662	./write_mfs_in_kernel ${RD}/boot.${FSIMAGE}/kernel \
663		fs-image.${FSIMAGE}
664	kzip -v ${RD}/boot.${FSIMAGE}/kernel
665	@mv ${RD}/boot.${FSIMAGE}/kernel ${RD}/kernels/MFSKERNEL.${FSIMAGE}
666	@mv ${RD}/boot.${FSIMAGE}/kernel.kz ${RD}/boot.${FSIMAGE}/kernel
667	@cp ${.CURDIR}/../sys/i386/boot/biosboot/boot.help ${RD}/boot.${FSIMAGE}
668	@touch ${RD}/boot.${FSIMAGE}/boot.config
669	@touch ${RD}/boot.${FSIMAGE}/kernel.config
670	@rm -f ${RD}/floppies/boot${FSIMAGE}.flp
671	sh -e ${.CURDIR}/doFS.sh ${RD} ${MNT} ${FDSIZE} ${RD}/boot.${FSIMAGE} \
672		${BOOTINODE} ${FDLABEL}
673	mv fs-image ${RD}/floppies/boot${FSIMAGE}.flp
674
675.include <bsd.prog.mk>
676