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