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