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