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