Makefile revision 64556
1# $FreeBSD: head/release/Makefile 64556 2000-08-12 14:21:33Z nyan $
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 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	echo "export MODULES_WITH_WORLD=YES"	>> ${CHROOTDIR}/mk
271.if defined(RELEASETAG)
272	echo "export RELEASETAG=${RELEASETAG}"	>> ${CHROOTDIR}/mk
273.endif
274.if defined(NOPORTS)
275	echo "export NOPORTS=${NOPORTS}"	>> ${CHROOTDIR}/mk
276.endif
277.if defined(NODOC)
278	echo "export NODOC=${NODOC}"		>> ${CHROOTDIR}/mk
279.endif
280.if defined(ALLLANG) && ${ALLLANG} != "NO" && ${ALLLANG} != "no"
281	echo "export ALLLANG=${ALLLANG}"	>> ${CHROOTDIR}/mk
282.else
283	echo "export DOC_LANG=en_US.ISO_8859-1"	>> ${CHROOTDIR}/mk
284.endif
285.if defined(NOSRC)
286	echo "export NOSRC=${NOSRC}"		>> ${CHROOTDIR}/mk
287.endif
288.if defined(NOSHARED)
289	echo "export NOSHARED=${NOSHARED}"	>> ${CHROOTDIR}/mk
290.endif
291.if defined(USA_RESIDENT)
292	echo "export USA_RESIDENT=${USA_RESIDENT}" >> ${CHROOTDIR}/mk
293.endif
294.if defined(BOOT_CONFIG)
295	echo "export BOOT_CONFIG=\"${BOOT_CONFIG}\"">> ${CHROOTDIR}/mk
296.endif
297.if defined(KERNEL_FLAGS)
298	echo "export KERNEL_FLAGS=\"${KERNEL_FLAGS}\"" >> ${CHROOTDIR}/mk
299.endif
300	# Don't remove this, or the build will fall over!
301	echo "export RELEASEDIR=${_R}"		>> ${CHROOTDIR}/mk
302	echo "export PATH=${BOOTSTRAPDIR}:$${PATH}:${LOCALDIR}" >> ${CHROOTDIR}/mk
303	echo "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
304	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
305.if make(release)
306	echo "	(cd etc; make distrib-dirs distribution)" >> ${CHROOTDIR}/mk
307	echo "	make ${WORLD_FLAGS} world && \\"	>> ${CHROOTDIR}/mk
308.endif
309.if make(rerelease)
310	echo "	make ${WORLD_FLAGS} all install && \\" >> ${CHROOTDIR}/mk
311.endif
312	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
313	echo "fi"				>> ${CHROOTDIR}/mk
314	echo "cd /usr/src/release/sysinstall"	>> ${CHROOTDIR}/mk
315	echo "make obj"				>> ${CHROOTDIR}/mk
316	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
317	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
318	echo "echo \" >>> make ${.TARGET} Finished on \`LC_TIME=C date\`\"" >> ${CHROOTDIR}/mk
319	chmod 755 ${CHROOTDIR}/mk
320	chroot ${CHROOTDIR} /mk
321
322clean:
323	rm -rf boot_crunch release.[0-9]
324
325# Clean out ${_R} and make the directory structure.
326release.1:
327	mkdir -p ${_R}
328	-rm -rf ${_R}/* 2> /dev/null
329	-chflags -R noschg ${_R}/.
330	rm -rf ${_R}/*
331	mkdir ${RD}
332	mkdir ${RD}/floppies
333	mkdir ${RD}/trees
334	mkdir ${RD}/dists
335	mkdir ${RD}/kernels
336	for i in ${DISTRIBUTIONS} ; do \
337		mkdir ${RD}/trees/$$i && \
338		mkdir ${RD}/dists/$$i && \
339		mtree -deU -f ${MTREEFILES}/BSD.root.dist \
340		    -p ${RD}/trees/$$i > /dev/null && \
341		mtree -deU -f ${MTREEFILES}/BSD.usr.dist \
342		    -p ${RD}/trees/$$i/usr > /dev/null && \
343		mtree -deU -f ${MTREEFILES}/BSD.include.dist \
344		    -p ${RD}/trees/$$i/usr/include > /dev/null && \
345		mtree -deU -f ${MTREEFILES}/BSD.var.dist \
346		    -p ${RD}/trees/$$i/var > /dev/null ; \
347	done
348	touch release.1
349
350# Install the system into the various distributions.
351release.2:
352	cd ${.CURDIR}/../etc && make distrib-dirs DESTDIR=${RD}/trees/bin
353	cd ${.CURDIR}/.. && make distribute DISTDIR=${RD}/trees
354.if exists(${.CURDIR}/../kerberosIV) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
355	cd ${.CURDIR}/../kerberosIV && ( \
356		make bootstrap &&\
357		make obj all help-distribute DISTDIR=${RD}/trees &&\
358		make kprog \
359	)
360.endif
361.if exists(${.CURDIR}/../kerberos5) && exists(${.CURDIR}/../crypto) && !defined(NOKERBEROS)
362	cd ${.CURDIR}/../kerberos5 && ( \
363		make bootstrap &&\
364		make obj all help-distribute DISTDIR=${RD}/trees &&\
365		make kprog \
366	)
367.endif
368	-chflags -R noschg ${RD}/trees
369	touch release.2
370
371# Make and install the generic kernel(s).
372release.3:
373.for kernel in ${KERNELS}
374	rm -f ${RD}/kernels/${kernel}
375	rm -rf ${.CURDIR}/../sys/compile/${kernel}
376	cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=${kernel}
377	rm -rf ${.CURDIR}/../sys/compile/${kernel}
378	cp ${RD}/kernels/${kernel} ${RD}/trees/bin/kernel.${kernel}
379.endfor
380	touch release.3
381
382# Make and install the three crunched binaries which live on the floppies.
383# You are not supposed to like this :-)
384#
385# NB: the "RELEASE_BUILD_FIXIT" magic prevents vi from including the
386# Tcl and Perl APIs.  See also /usr/src/usr.bin/vi/Makefile.
387# It also prevents ls linking against termcap by disabling color support.
388# See /usr/src/bin/ls/Makefile.
389release.4:
390	@mkdir -p /stand
391	cd ${.CURDIR}/sysinstall && make obj depend all install
392	rm -rf ${RD}/crunch
393	mkdir -p ${RD}/crunch
394	export RELEASE_BUILD_FIXIT=noway ; \
395	for j in ${CRUNCH_TARGETS} ; do \
396		rm -rf $${j}_crunch && \
397		mkdir $${j}_crunch && \
398		( cd $${j}_crunch && \
399		  ( ( [ -f ${.CURDIR}/${MACHINE}/$${j}_crunch.conf ] && \
400		    crunchgen ${.CURDIR}/${MACHINE}/$${j}_crunch.conf ) || \
401		    ( crunchgen ${.CURDIR}/$${j}_crunch.conf ) ) && \
402		  ${MAKE} -DRELEASE_CRUNCH -f $${j}_crunch.mk subclean all \
403		    NOCRYPT=yes "CFLAGS=${CFLAGS} -DCRUNCHED_BINARY") && \
404		mv $${j}_crunch/$${j}_crunch ${RD}/crunch/$${j} && \
405		true || { rm -rf $${j}_crunch ; false ; } ; \
406	done
407	touch release.4
408
409#
410# --==## Fix up the distributions. ##==--
411#
412release.5:
413	# Handle some grief caused by the munition braindeadness.
414	for i in sbin/init bin/ed usr.sbin/ppp usr.sbin/pppd usr.sbin/tcpdump/tcpdump ; do \
415		( cd ${.CURDIR}/../$$i; \
416		  make -DNOCRYPT clean all distribute DISTDIR=${RD}/trees ) ; \
417	done
418
419	# Create any "synthetic dists" now.
420	@for i in ${DISTRIBUTIONS}; do \
421		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
422			echo -n "Running $$i dist creation script... "; \
423			env OBJFORMAT=${OBJFORMAT} RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
424			echo "Done."; \
425		fi \
426	done \
427
428	# Create symlinks for the MD5-based crypt lib, too.  The
429	# automatically created links still point to the DES stuff,
430	# which went into its own distribution.
431	for i in ${RD}/trees/bin/usr/lib/libscrypt* ; do \
432		c=`echo $$i | sed -e 's/libscrypt/libcrypt/'` ; \
433		rm -f $$c ; \
434		ln -s `basename $$i` $$c ; \
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 mv krb4/* crypto && rmdir krb4 ; fi )
460	( cd ${RD}/dists && \
461		if [ -f krb5/krb5.aa ] ; then mv krb5/* crypto && rmdir krb5 ; fi )
462	touch release.6
463
464
465#
466# --==## Make source dists ##==--
467#
468release.7:
469.if !defined(NOSRC)
470	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
471		TD=src TN=sbase ARG="[A-Z]*"
472	@for i in `cd /usr/src && echo [a-z]*` ; do \
473		if [ -d /usr/src/$$i ] ; then \
474			cd ${.CURDIR} && $(MAKE) doTARBALL \
475				TN=`echo s$$i | tr -d '.' | \
476				    sed -e 's/usr/u/' \
477					-e 's/kerberosIV/krb4/' \
478					-e 's/kerberos5/krb5/'` \
479				SD=/usr/src TD=src ARG="$$i" ; \
480		fi ; \
481	done
482.if defined(EXTRA_SRC)
483	@set ${EXTRA_SRC} && \
484	while [ $$# -ge 2 ] ; do \
485		if [ -d /usr/src/$$1 ] ; then \
486			cd ${.CURDIR} && $(MAKE) doTARBALL \
487				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
488		fi && shift && shift ; \
489	done
490.endif
491	if [ -d ${RD}/dists/crypto ] ; then ( cd ${RD}/dists/src && \
492		if [ -f ssecure.aa ] ; then mv ssecure.* ../crypto ; fi && \
493		if [ -f scrypto.aa ] ; then mv scrypto.* ../crypto ; fi && \
494		if [ -f skrb4.aa ] ; then mv skrb4.* ../crypto ; fi && \
495		if [ -f skrb5.aa ] ; then mv skrb5.* ../crypto ; fi ; ) ; fi
496	@echo "src distribution is finished."
497.endif
498	touch release.7
499
500# Complete the bootfd
501#
502# Now, just to get this picture down once and for all:
503#
504# +------------------------------------------------------------------------+
505# |boot.flp                                                                |
506# +-----+-----+------------------------------------------------------------+
507# |boot1|boot2|floppy filesystem "bootfd"                                  |
508# +-----+-----+-+--------------------------------------------------------+-+
509#               |kernel                                                  |
510#               +------------+-----------------------------------------+-+
511#                            |mfs filesystem "mfsfd"                   |
512#                            +-----------------------------------------+
513#
514
515release.8: write_mfs_in_kernel
516	rm -rf ${RD}/mfsfd
517	mkdir ${RD}/mfsfd
518	cd ${RD}/mfsfd && \
519		mkdir -p etc/defaults dev mnt stand/help
520	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
521		DIR=${RD}/mfsfd/stand ZIP=false
522	( cd ${RD}/trees/bin/dev && \
523		ls console tty bpf0 ttyv0 ttyv1 ttyv2 ttyv3 null zero card0 card1 card2 card3 usb usb0 uhid0 ums0 ulpt0 ugen0 kbd0 kmem mem | \
524	cpio -dump ${RD}/mfsfd/dev )
525	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
526	( cd ${RD}/mfsfd && \
527	  for dir in bin sbin ; do \
528		ln -sf /stand $$dir; \
529	  done )
530	cp /sbin/dhclient-script ${RD}/mfsfd/stand
531	cp ${.CURDIR}/../etc/defaults/pccard.conf ${RD}/mfsfd/etc/defaults/pccard.conf
532	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
533	cd ${RD}/trees/bin && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
534	echo "nameserver      42/tcp name"	> ${RD}/mfsfd/stand/etc/services
535	echo "ftp             21/tcp"		>> ${RD}/mfsfd/stand/etc/services
536	echo "domain          53/tcp          nameserver" >> ${RD}/mfsfd/stand/etc/services
537	echo "domain          53/udp          nameserver" >> ${RD}/mfsfd/stand/etc/services
538	echo "cmd             514/tcp    shell" >> ${RD}/mfsfd/stand/etc/services
539	gzip -9c ${.CURDIR}/../COPYRIGHT > ${RD}/mfsfd/stand/help/COPYRIGHT.hlp.gz
540	@for i in README.TXT RELNOTES.TXT INSTALL.TXT UPGRADE.TXT HARDWARE.TXT; do \
541	  if [ -f ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} ]; then \
542	     gzip -9c ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} > ${RD}/mfsfd/stand/help/$${i}.gz; \
543	  else \
544	     gzip -9c ${.CURDIR}/texts/$${i} > ${RD}/mfsfd/stand/help/$${i}.gz; \
545	  fi; \
546	done
547	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
548	@mkdir -p ${RD}/mfsfd/boot
549	@cp /boot/boot* ${RD}/mfsfd/boot
550	@cp /boot/loader.help ${RD}/mfsfd/boot
551	@echo "Making the regular boot floppy."
552	@tar --exclude CVS -cf - -C ${.CURDIR}/sysinstall help | \
553		tar xf - -C ${RD}/mfsfd/stand
554	@echo "Compressing doc files..."
555	@gzip -9 ${RD}/mfsfd/stand/help/*.hlp
556	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
557		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
558	@gzip -9vc mfsroot > mfsroot.gz
559	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
560		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
561.if ${MACHINE} == "pc98"
562	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern-small FDSIZE=SMALL
563	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
564.else
565	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
566	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot FDSIZE=BIG
567.endif
568	@rm mfsroot mfsroot.gz mfsroot.size
569	@echo "Regular and MFS boot floppies made."
570	touch release.8
571
572#
573# --==## Create a fixit floppy ##==--
574#
575release.9:
576	@echo "Making fixit floppy."
577	@rm -rf ${RD}/fixitfd
578	@mkdir ${RD}/fixitfd
579	@cd ${RD}/fixitfd && \
580		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
581		usr/share/misc
582	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
583		DIR=${RD}/fixitfd/stand ZIP=false
584	@( cd ${RD}/fixitfd/dev && \
585		sed -e '/^PATH/s/^/#/' ${RD}/trees/bin/dev/MAKEDEV > MAKEDEV && \
586		chmod 755 MAKEDEV && \
587		sh MAKEDEV fixit )
588	@cp ${RD}/trees/bin/etc/spwd.db ${RD}/trees/bin/etc/group \
589		${RD}/trees/bin/etc/protocols ${RD}/fixitfd/etc
590	@cp ${RD}/trees/bin/usr/share/misc/scsi_modes \
591		${RD}/fixitfd/usr/share/misc
592	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
593	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
594	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
595	@chmod 555 ${RD}/fixitfd/stand/tar
596	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
597		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
598# Do our last minute floppies directory setup in a convenient place.
599	@cp ${.CURDIR}/texts/FLOPPIES.TXT ${RD}/floppies/README.TXT
600	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
601	touch release.9
602
603#
604# --==## Setup a suitable ftp-area ##==--
605#
606ftp.1:
607	@echo "Setting up FTP distribution area"
608	@mkdir -p ${FD}
609	-@ln -s . ${FD}/${BUILDNAME}
610	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
611	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
612	@for i in ${DIST_DOCS}; do \
613	  if [ -f ${.CURDIR}/texts/$${i} ]; then \
614	     cp ${.CURDIR}/texts/$${i} ${FD}; \
615	  fi; \
616	  if [ -f ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} ]; then \
617	     echo "=== Platform specifics for ${MACHINE_ARCH}" >> ${FD}/$${i}; \
618	     cat ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} >> ${FD}/$${i}; \
619	  fi; \
620	done
621	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
622.if !defined(NOPORTS)
623	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
624.endif
625
626#
627# --==## Setup a suitable cdrom-area ##==--
628#
629cdrom.1:
630	@echo "Setting up CDROM distribution area"
631	@mkdir -p ${CD_DISC1} ${CD_DISC2}
632	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
633	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
634	@ln -f ${RD}/kernels/MFSKERNEL.boot ${CD_DISC1}/kernel
635	@for i in ${DISTRIBUTIONS} ; \
636	do \
637		if [ -d ${RD}/trees/$${i} ] ; then \
638			chflags -R noschg ${RD}/trees/$${i} || true ; \
639			( cd ${RD}/trees/$${i} && \
640			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
641		fi \
642	done
643	@rm -f ${CD_DISC2}/.profile
644	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
645	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
646	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
647	@for i in ${DIST_DOCS}; do \
648	  if [ -f ${.CURDIR}/texts/$${i} ]; then \
649	     cp ${.CURDIR}/texts/$${i} ${CD_DISC1}; \
650	  fi; \
651	  if [ -f ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} ]; then \
652	     echo "=== Platform specifics for ${MACHINE_ARCH}" >> ${CD_DISC1}/$${i}; \
653	     cat ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} >> ${CD_DISC1}/$${i}; \
654	  fi; \
655        done
656.if ${MACHINE_ARCH} == "alpha"
657	@echo "Setting up Alpha CD disc1 for booting"
658	@cp -Rp ${RD}/image.boot/boot ${CD_DISC1}
659	@ln -f ${CD_DISC2}/boot/cdboot ${CD_DISC1}/boot
660	@ln -f ${CD_DISC1}/boot/loader.rc ${CD_DISC2}/boot
661	@ln -f ${CD_DISC1}/kernel ${CD_DISC2}/kernel
662.endif
663.if !defined(NOPORTS)
664	@-rm -rf /usr/ports/distfiles/*
665	@mkdir -p ${CD_DISC1}/ports && \
666	  tar --exclude CVS -czf ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
667	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
668	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
669.endif
670
671doc.1:
672	@echo "Making docs..."
673	@for i in ${DOCPORTS}; do \
674	  cd /usr/ports/$$i && make all install clean JADETEX=no FORCE_PKG_REGISTER=yes; \
675	done
676	@cd /usr/doc && make all install 'FORMATS=html html-split txt' INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/bin/usr/share/doc
677	touch doc.1
678
679# Various "subroutine" and other supporting targets.
680
681# RD=
682# SD=
683# TD=
684# ARG=
685doTARBALL:
686.if !defined(SD)
687	@echo "SD undefined in doTARBALL" && exit 1
688.endif
689.if !defined(TD)
690	@echo "TB undefined in doTARBALL" && exit 1
691.endif
692.if !defined(ARG)
693	@echo "ARG undefined in doTARBALL" && exit 1
694.endif
695	@rm -rf ${RD}/dists/${TD}/${TN}*
696	@mkdir -p ${RD}/dists/${TD}
697	@( cd ${SD} && \
698		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
699		echo rolling ${TD}/$$tn tarball &&\
700		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
701		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
702		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
703		   ${RD}/dists/${TD}/$$tn.inf && \
704		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
705		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
706		fi && \
707		if [ "${SD}" != "/usr/src" ]; then \
708			mtree -c -i -p ${SD}/${ARG} \
709			  -k gname,md5digest,mode,nlink,uname,size,link,type \
710			  > ${RD}/dists/${TD}/$$tn.mtree ; \
711		else \
712			true; \
713		fi; \
714		(cd ${RD}/dists/${TD}; \
715		   rm -f CHECKSUM.MD5; \
716		   md5 * > CHECKSUM.MD5) \
717	)
718
719doRELEASE:  release.1 release.2 ${DOCREL} release.3 release.4 release.5 \
720		release.6 release.7 release.8 release.9
721	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
722	@echo "Release done"
723
724floppies:
725	@cd ${.CURDIR} && ${MAKE} boot.flp
726	@cd ${.CURDIR} && ${MAKE} fixit.flp
727	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
728
729boot.flp:
730	@rm -f release.4 release.8
731	@cd ${.CURDIR} && ${MAKE} release.4 release.8 CRUNCH_TARGETS=boot
732
733fixit.flp:
734	@rm -f release.4 release.9
735	@cd ${.CURDIR} && ${MAKE} release.4 release.9 CRUNCH_TARGETS=fixit
736
737write_mfs_in_kernel:	${.CURDIR}/write_mfs_in_kernel.c
738	${CC} ${CFLAGS} -o write_mfs_in_kernel ${.CURDIR}/write_mfs_in_kernel.c
739
740installCRUNCH:
741.if !defined(CRUNCH)
742	@echo "CRUNCH undefined in installCRUNCH" && exit 1
743.endif
744.if !defined(DIR)
745	@echo "DIR undefined in installCRUNCH" && exit 1
746.endif
747.if !defined(ZIP)
748	@echo "ZIP undefined in installCRUNCH" && exit 1
749.endif
750	@if ${ZIP} ; then \
751		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
752	else \
753		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
754	fi
755	@chmod 555 ${DIR}/${CRUNCH}_crunch
756	@if [ -f ${.CURDIR}/${MACHINE}/${CRUNCH}_crunch.conf ] ; then \
757		for i in `crunchgen -l ${.CURDIR}/${MACHINE}/${CRUNCH}_crunch.conf` ; do \
758			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
759		done \
760	else \
761		for i in `crunchgen -l ${.CURDIR}/${CRUNCH}_crunch.conf` ; do \
762			ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
763		done \
764	fi
765
766#
767# --==## Compile a kernel by name ${KERNEL} ##==--
768#
769# We don't erase the sys/compile/${KERNEL} directory, since somebody
770# may want to reuse it (release.8 presently)
771#
772doKERNEL:
773	@rm -f ${RD}/kernels/${KERNEL}
774	@cd ${.CURDIR}/../sys/${MACHINE}/conf && config ${KERNEL}
775	@cd ${.CURDIR}/../sys/compile/${KERNEL} && \
776			make kernel-depend && \
777			make ${KERNEL_FLAGS} ${KERNEL} && \
778			make kernel-reinstall DESTDIR=${RD}/kernels && \
779			[ -r ${.CURDIR}/../sys/${MACHINE}/conf/${KERNEL}.hints ] && \
780			cp ${.CURDIR}/../sys/${MACHINE}/conf/${KERNEL}.hints ${RD}/kernels
781
782#
783# --==## Put a filesystem into a BOOTMFS kernel ##==--
784#
785doMFSKERN:
786	@echo "Running doMFSKERN for ${FSIMAGE}"
787	@rm -f ${RD}/kernels/BOOTMFS.${FSIMAGE}
788	@cd ${.CURDIR}/../sys/${MACHINE}/conf && \
789	  sh ${.CURDIR}/scripts/dokern.sh ${FDSIZE} < ${KERNCONF} > BOOTMFS && \
790	  [ -r ${KERNCONF}.hints ] && cp ${KERNCONF}.hints BOOTMFS.hints
791.if ${MACHINE_ARCH} == "i386"
792	@echo "options  INTRO_USERCONFIG" >> \
793	  ${.CURDIR}/../sys/${MACHINE}/conf/BOOTMFS
794.endif
795.if defined(FDSIZE) && ${FDSIZE} == "BIG"
796	@echo "options MD_ROOT_SIZE=`cat mfsroot.size`" >> \
797	  ${.CURDIR}/../sys/${MACHINE}/conf/BOOTMFS
798.endif
799	@cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=BOOTMFS
800	@rm -rf ${RD}/image.${FSIMAGE}
801	@mkdir  ${RD}/image.${FSIMAGE}
802	@cd ${RD}/kernels && \
803	  chflags noschg BOOTMFS && \
804	  strip BOOTMFS && \
805	  cp BOOTMFS BOOTMFS.${FSIMAGE} && \
806	  [ -r BOOTMFS.hints ] && mv BOOTMFS.hints BOOTMFS.${FSIMAGE}.hints
807	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
808	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
809	@mkdir -p ${RD}/image.${FSIMAGE}/boot
810	@cp /boot/boot[12] /boot/loader ${RD}/image.${FSIMAGE}/boot
811	@[ -r ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints ] && \
812	  sed -e '/^hint/s/^/set /' -e '/^#/d' \
813	    ${RD}/kernels/BOOTMFS.${FSIMAGE}.hints > \
814	    ${RD}/image.${FSIMAGE}/boot/device.hints && \
815	  echo "include /boot/device.hints" > ${RD}/image.${FSIMAGE}/boot/loader.rc
816.if !defined(FDSIZE) || ${FDSIZE} != "BIG"
817	@echo "load /kernel" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
818	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
819	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
820	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
821	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
822.endif
823	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
824	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
825.if ${MACHINE_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
826	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
827.endif
828.if defined(FDSIZE) && ${FDSIZE} == "BIG"
829	@echo "Writing MFS image into kernel for ${FSIMAGE} floppy"
830	@./write_mfs_in_kernel ${RD}/image.${FSIMAGE}/kernel mfsroot
831	@cp ${RD}/image.${FSIMAGE}/kernel ${RD}/kernels/MFSKERNEL.${FSIMAGE}
832.endif
833	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
834	@rm -f ${RD}/floppies/${FSIMAGE}.flp
835.if defined(FDSIZE) && ${FDSIZE} == "BIG"
836	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
837		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
838		${BOOTINODE} ${BIGBOOTLABEL}
839.elif defined(FDSIZE) && ${FDSIZE} == "SMALL"
840	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
841		${RD} ${MNT} ${SMALLBOOTSIZE} ${RD}/image.${FSIMAGE} \
842		${BOOTINODE} ${SMALLBOOTLABEL}
843.else
844	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
845		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
846		${BOOTINODE} ${BOOTLABEL}
847.endif
848	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
849
850.include <bsd.prog.mk>
851