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