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