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