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