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