Makefile revision 62004
1# $FreeBSD: head/release/Makefile 62004 2000-06-23 12:22:08Z nyan $
2#
3# make release CHROOTDIR=/some/dir BUILDNAME=somename [ RELEASETAG=tag ]
4#
5# Where "/some/dir" is the pathname of a directory on a some
6# filesystem with at least 1000MB of free space, "somename" is what
7# you want the release to call itself and, optionally, which CVS "tag"
8# name should be used when checking out the sources to build the release
9# (default is HEAD).
10#
11# Please note: the vn driver must also be compiled into your kernel,
12# otherwise the target 'release.8' and possibly others will fail.
13#
14# Set these, release builder!
15#
16# Fixed version:
17#BUILDNAME=5.0-RELEASE
18#
19# Automatic SNAP versioning:
20DATE != date +%Y%m%d
21BASE = 5.0
22BUILDNAME?=${BASE}-${DATE}-SNAP
23#
24#CHROOTDIR=/junk/release
25# If this is a -stable snapshot, then set
26#RELEASETAG=RELENG_3
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.if defined(RELEASETAG)
257	echo "export RELEASETAG=${RELEASETAG}"	>> ${CHROOTDIR}/mk
258.endif
259.if defined(NOPORTS)
260	echo "export NOPORTS=${NOPORTS}"	>> ${CHROOTDIR}/mk
261.endif
262.if defined(NODOC)
263	echo "export NODOC=${NODOC}"		>> ${CHROOTDIR}/mk
264.endif
265.if defined(ALLLANG) && ${ALLLANG} != "NO" && ${ALLLANG} != "no"
266	echo "export ALLLANG=${ALLLANG}"	>> ${CHROOTDIR}/mk
267.else
268	echo "export DOC_LANG=en_US.ISO_8859-1"	>> ${CHROOTDIR}/mk
269.endif
270.if defined(NOSRC)
271	echo "export NOSRC=${NOSRC}"		>> ${CHROOTDIR}/mk
272.endif
273.if defined(NOSHARED)
274	echo "export NOSHARED=${NOSHARED}"	>> ${CHROOTDIR}/mk
275.endif
276.if defined(USA_RESIDENT)
277	echo "export USA_RESIDENT=${USA_RESIDENT}" >> ${CHROOTDIR}/mk
278.endif
279.if defined(BOOT_CONFIG)
280	echo "export BOOT_CONFIG=\"${BOOT_CONFIG}\"">> ${CHROOTDIR}/mk
281.endif
282	# Don't remove this, or the build will fall over!
283	echo "export RELEASEDIR=${_R}"		>> ${CHROOTDIR}/mk
284	echo "export PATH=${BOOTSTRAPDIR}:$${PATH}:${LOCALDIR}" >> ${CHROOTDIR}/mk
285	echo "if [ ! -f /tmp/.world_done ]; then" >> ${CHROOTDIR}/mk
286	echo "	cd /usr/src"			>> ${CHROOTDIR}/mk
287.if make(release)
288	echo "	(cd etc; make distrib-dirs distribution)" >> ${CHROOTDIR}/mk
289	echo "	make world && \\"		>> ${CHROOTDIR}/mk
290.endif
291.if make(rerelease)
292	echo "	make all install && \\"		>> ${CHROOTDIR}/mk
293.endif
294	echo "	touch /tmp/.world_done"		>> ${CHROOTDIR}/mk
295	echo "fi"				>> ${CHROOTDIR}/mk
296	echo "cd /usr/src/release/sysinstall"	>> ${CHROOTDIR}/mk
297	echo "make obj"				>> ${CHROOTDIR}/mk
298	echo "cd /usr/src/release"		>> ${CHROOTDIR}/mk
299	echo "make \$${_RELTARGET}"		>> ${CHROOTDIR}/mk
300	echo "echo make ${.TARGET} Finished"	>> ${CHROOTDIR}/mk
301	chmod 755 ${CHROOTDIR}/mk
302	chroot ${CHROOTDIR} /mk
303
304clean:
305	rm -rf boot_crunch release.[0-9]
306	rm -rf ${.OBJDIR}/boot_crunch.conf ${.OBJDIR}/fixit_crunch.conf
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	ln -f ${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		sed -e "s:MACHINE:${MACHINE}:" \
380			${.CURDIR}/$${j}_crunch.conf > \
381			${.OBJDIR}/$${j}_crunch.conf && \
382		rm -rf $${j}_crunch && \
383		mkdir $${j}_crunch && \
384		( cd $${j}_crunch && \
385		  crunchgen ${.OBJDIR}/$${j}_crunch.conf && \
386		  ${MAKE} -DRELEASE_CRUNCH -f $${j}_crunch.mk subclean all \
387		    NOCRYPT=yes "CFLAGS=${CFLAGS} -DCRUNCHED_BINARY") && \
388		mv $${j}_crunch/$${j}_crunch ${RD}/crunch/$${j} && \
389		true || { rm -rf $${j}_crunch ; false ; } ; \
390	done
391	touch release.4
392
393#
394# --==## Fix up the distributions. ##==--
395#
396release.5:
397	# Handle some grief caused by the munition braindeadness.
398	for i in sbin/init bin/ed usr.sbin/ppp usr.sbin/pppd ; do \
399		( cd ${.CURDIR}/../$$i; \
400		  make -DNOCRYPT clean all distribute DISTDIR=${RD}/trees ) ; \
401	done
402
403	# Create any "synthetic dists" now.
404	@for i in ${DISTRIBUTIONS}; do \
405		if [ -f ${.CURDIR}/scripts/$${i}-make.sh ]; then \
406			echo -n "Running $$i dist creation script... "; \
407			env OBJFORMAT=${OBJFORMAT} RD=${RD} sh ${.CURDIR}/scripts/$${i}-make.sh || echo "$$i distribution script returned bad status."; \
408			echo "Done."; \
409		fi \
410	done \
411
412	# Create symlinks for the MD5-based crypt lib, too.  The
413	# automatically created links still point to the DES stuff,
414	# which went into its own distribution.
415	for i in ${RD}/trees/bin/usr/lib/libscrypt* ; do \
416		c=`echo $$i | sed -e 's/libscrypt/libcrypt/'` ; \
417		rm -f $$c ; \
418		ln -s `basename $$i` $$c ; \
419	done
420
421	# Remove all the directories we don't need.
422	-cd ${RD}/trees && \
423		find ${OTHER_DISTS} ${COMPAT_DISTS} ${CRYPTO_DISTS} -depth -type d -print | xargs rmdir
424	touch release.5
425
426#
427# --==## Package up the tarballs from assembled trees ##==--
428#
429release.6:
430	rm -rf ${RD}/dists
431	mkdir -p ${RD}/dists
432	@for i in ${DISTRIBUTIONS} ; \
433	do \
434		if [ -d ${RD}/trees/$${i} ] ; then \
435			cd ${.CURDIR} && $(MAKE) doTARBALL \
436				SD=${RD}/trees/$${i} \
437				TN=$$i TD=$$i ARG="." && \
438			echo "$${i} distribution is finished."; \
439		fi ; \
440	done
441	# More munition braindeadness.
442	( cd ${RD}/dists && \
443		if [ -f krb4/krb4.aa ] ; then mv krb4/* crypto && rmdir krb4 ; fi )
444	( cd ${RD}/dists && \
445		if [ -f krb5/krb5.aa ] ; then mv krb5/* crypto && rmdir krb5 ; fi )
446	touch release.6
447
448
449#
450# --==## Make source dists ##==--
451#
452release.7:
453.if !defined(NOSRC)
454	@cd ${.CURDIR} && $(MAKE) doTARBALL SD=/usr/src \
455		TD=src TN=sbase ARG="[A-Z]*"
456	@for i in `cd /usr/src && echo [a-z]*` ; do \
457		if [ -d /usr/src/$$i ] ; then \
458			cd ${.CURDIR} && $(MAKE) doTARBALL \
459				TN=`echo s$$i | tr -d '.' | \
460				    sed -e 's/usr/u/' \
461					-e 's/kerberosIV/krb4/' \
462					-e 's/kerberos5/krb5/'` \
463				SD=/usr/src TD=src ARG="$$i" ; \
464		fi ; \
465	done
466.if defined(EXTRA_SRC)
467	@set ${EXTRA_SRC} && \
468	while [ $$# -ge 2 ] ; do \
469		if [ -d /usr/src/$$1 ] ; then \
470			cd ${.CURDIR} && $(MAKE) doTARBALL \
471				SD=/usr/src TN="s$$2" TD=src ARG="$$1" ; \
472		fi && shift && shift ; \
473	done
474.endif
475	if [ -d ${RD}/dists/crypto ] ; then ( cd ${RD}/dists/src && \
476		if [ -f ssecure.aa ] ; then mv ssecure.* ../crypto ; fi && \
477		if [ -f scrypto.aa ] ; then mv scrypto.* ../crypto ; fi && \
478		if [ -f skrb4.aa ] ; then mv skrb4.* ../crypto ; fi && \
479		if [ -f skrb5.aa ] ; then mv skrb5.* ../crypto ; fi ; ) ; fi
480	@echo "src distribution is finished."
481.endif
482	touch release.7
483
484# Complete the bootfd
485#
486# Now, just to get this picture down once and for all:
487#
488# +------------------------------------------------------------------------+
489# |boot.flp                                                                |
490# +-----+-----+------------------------------------------------------------+
491# |boot1|boot2|floppy filesystem "bootfd"                                  |
492# +-----+-----+-+--------------------------------------------------------+-+
493#               |kernel                                                  |
494#               +------------+-----------------------------------------+-+
495#                            |mfs filesystem "mfsfd"                   |
496#                            +-----------------------------------------+
497#
498
499release.8: write_mfs_in_kernel
500	rm -rf ${RD}/mfsfd
501	mkdir ${RD}/mfsfd
502	cd ${RD}/mfsfd && \
503		mkdir -p etc/defaults dev mnt stand/help
504	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=boot \
505		DIR=${RD}/mfsfd/stand ZIP=false
506	( cd ${RD}/trees/bin/dev && \
507		ls console tty bpf0 ttyv0 ttyv1 ttyv2 ttyv3 null zero card0 card1 card2 card3 usb usb0 uhid0 ums0 ulpt0 ugen0 kbd0 | \
508	cpio -dump ${RD}/mfsfd/dev )
509	( cd ${RD}/mfsfd/dev && rm -f *[swo]d*[bdefgh] )
510	( cd ${RD}/mfsfd && mkdir -p bin sbin && ln -s /stand/sh bin/sh )
511	cp /sbin/dhclient-script ${RD}/mfsfd/sbin
512	cp ${.CURDIR}/../etc/defaults/pccard.conf ${RD}/mfsfd/etc/defaults/pccard.conf
513	cp ${.CURDIR}/../etc/usbd.conf ${RD}/mfsfd/etc/usbd.conf
514	cd ${RD}/trees/bin && ls ${BOOT1} | cpio -dump ${RD}/mfsfd/stand
515	echo "nameserver      42/tcp name"	> ${RD}/mfsfd/stand/etc/services
516	echo "ftp             21/tcp"		>> ${RD}/mfsfd/stand/etc/services
517	echo "domain          53/tcp          nameserver" >> ${RD}/mfsfd/stand/etc/services
518	echo "domain          53/udp          nameserver" >> ${RD}/mfsfd/stand/etc/services
519	echo "cmd             514/tcp    shell" >> ${RD}/mfsfd/stand/etc/services
520	gzip -9c ${.CURDIR}/../COPYRIGHT > ${RD}/mfsfd/stand/help/COPYRIGHT.hlp.gz
521	@for i in README.TXT RELNOTES.TXT INSTALL.TXT UPGRADE.TXT HARDWARE.TXT; do \
522	  if [ -f ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} ]; then \
523	     gzip -9c ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} > ${RD}/mfsfd/stand/help/$${i}.gz; \
524	  else \
525	     gzip -9c ${.CURDIR}/texts/$${i} > ${RD}/mfsfd/stand/help/$${i}.gz; \
526	  fi; \
527	done
528	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
529	@mkdir -p ${RD}/mfsfd/boot
530	@cp /boot/boot* ${RD}/mfsfd/boot
531	@cp /boot/loader.help ${RD}/mfsfd/boot
532	@echo "Making the regular boot floppy."
533	@tar --exclude CVS -cf - -C ${.CURDIR}/sysinstall help | \
534		tar xf - -C ${RD}/mfsfd/stand
535	@echo "Compressing doc files..."
536	@gzip -9 ${RD}/mfsfd/stand/help/*.hlp
537	sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \
538		${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL}
539	@gzip -9vc mfsroot > mfsroot.gz
540	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \
541		${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL}
542	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern
543.if ${MACHINE} != "pc98"
544	@cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot BIGBOOT=YES
545.endif
546	@rm mfsroot mfsroot.gz mfsroot.size
547	@echo "Regular and MFS boot floppies made."
548	touch release.8
549
550#
551# --==## Create a fixit floppy ##==--
552#
553release.9:
554	@echo "Making fixit floppy."
555	@rm -rf ${RD}/fixitfd
556	@mkdir ${RD}/fixitfd
557	@cd ${RD}/fixitfd && \
558		mkdir -p dev stand bin sbin etc mnt mnt1 mnt2 mnt3 mnt4 tmp \
559		usr/share/misc
560	@cd ${.CURDIR} && $(MAKE) installCRUNCH CRUNCH=fixit \
561		DIR=${RD}/fixitfd/stand ZIP=false
562	@( cd ${RD}/fixitfd/dev && \
563		sed -e '/^PATH/s/^/#/' ${RD}/trees/bin/dev/MAKEDEV > MAKEDEV && \
564		chmod 755 MAKEDEV && \
565		sh MAKEDEV fixit )
566	@cp ${RD}/trees/bin/etc/spwd.db ${RD}/trees/bin/etc/group \
567		${RD}/trees/bin/etc/protocols ${RD}/fixitfd/etc
568	@cp ${RD}/trees/bin/usr/share/misc/scsi_modes \
569		${RD}/fixitfd/usr/share/misc
570	@cp ${.CURDIR}/fixit.profile ${RD}/fixitfd/.profile
571	@cp ${.CURDIR}/fixit.services ${RD}/fixitfd/etc/services
572	@cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar
573	@chmod 555 ${RD}/fixitfd/stand/tar
574	@sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \
575		${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL}
576# Do our last minute floppies directory setup in a convenient place.
577	@cp ${.CURDIR}/texts/FLOPPIES.TXT ${RD}/floppies/README.TXT
578	@(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5)
579	touch release.9
580
581#
582# --==## Setup a suitable ftp-area ##==--
583#
584ftp.1:
585	@echo "Setting up FTP distribution area"
586	@mkdir -p ${FD}
587	-@ln -s . ${FD}/${BUILDNAME}
588	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
589	@cd ${RD}/dists && find . -print | cpio -dumpl ${FD}
590	@for i in ${DIST_DOCS}; do \
591	  if [ -f ${.CURDIR}/texts/$${i} ]; then \
592	     cp ${.CURDIR}/texts/$${i} ${FD}; \
593	  fi; \
594	  if [ -f ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} ]; then \
595	     echo "=== Platform specifics for ${MACHINE_ARCH}" >> ${FD}/$${i}; \
596	     cat ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} >> ${FD}/$${i}; \
597	  fi; \
598	done
599	@echo "CD_VERSION = ${BUILDNAME}" > ${FD}/cdrom.inf
600.if !defined(NOPORTS)
601	@tar --exclude CVS -cBf - -C ${CD_DISC1} ports | tar -xBf - -C ${FD}
602.endif
603
604#
605# --==## Setup a suitable cdrom-area ##==--
606#
607cdrom.1:
608	@echo "Setting up CDROM distribution area"
609	@mkdir -p ${CD_DISC1} ${CD_DISC2}
610	@cd ${RD} && find floppies -print | cpio -dumpl ${CD_DISC1}
611	@cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DISC1}
612	@ln -f ${RD}/kernels/MFSKERNEL.boot ${CD_DISC1}/kernel
613	@for i in ${DISTRIBUTIONS} ; \
614	do \
615		if [ -d ${RD}/trees/$${i} ] ; then \
616			chflags -R noschg ${RD}/trees/$${i} || true ; \
617			( cd ${RD}/trees/$${i} && \
618			find . -depth -print | cpio -dumpl ${CD_DISC2} ) ; \
619		fi \
620	done
621	@rm -f ${CD_DISC2}/.profile
622	@cp ${.CURDIR}/fixit.profile ${CD_DISC2}/.profile
623	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC1}/cdrom.inf
624	@echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf
625	@for i in ${DIST_DOCS}; do \
626	  if [ -f ${.CURDIR}/texts/$${i} ]; then \
627	     cp ${.CURDIR}/texts/$${i} ${CD_DISC1}; \
628	  fi; \
629	  if [ -f ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} ]; then \
630	     echo "=== Platform specifics for ${MACHINE_ARCH}" >> ${CD_DISC1}/$${i}; \
631	     cat ${.CURDIR}/texts/${MACHINE_ARCH}/$${i} >> ${CD_DISC1}/$${i}; \
632	  fi; \
633        done
634.if ${MACHINE_ARCH} == "alpha"
635	@echo "Setting up Alpha CD disc1 for booting"
636	@cp -Rp ${RD}/image.boot/boot ${CD_DISC1}
637	@ln -f ${CD_DISC2}/boot/cdboot ${CD_DISC1}/boot
638	@ln -f ${CD_DISC1}/boot/loader.rc ${CD_DISC2}/boot
639	@ln -f ${CD_DISC1}/kernel ${CD_DISC2}/kernel
640.endif
641.if !defined(NOPORTS)
642	@-rm -rf /usr/ports/distfiles/*
643	@mkdir -p ${CD_DISC1}/ports && \
644	  tar --exclude CVS -czf ${CD_DISC1}/ports/ports.tgz -C /usr ports && \
645	  cp ${.CURDIR}/scripts/ports-install.sh ${CD_DISC1}/ports/install.sh \
646	  && (cd ${CD_DISC1}/ports; md5 * > CHECKSUM.MD5)
647.endif
648
649doc.1:
650	@echo "Making docs..."
651	@for i in ${DOCPORTS}; do \
652	  cd /usr/ports/$$i && make all install clean JADETEX=no FORCE_PKG_REGISTER=yes; \
653	done
654	@cd /usr/doc && make all install 'FORMATS=html html-split txt' INSTALL_COMPRESSED='' DOCDIR=${RD}/trees/bin/usr/share/doc
655	touch doc.1
656
657# Various "subroutine" and other supporting targets.
658
659# RD=
660# SD=
661# TD=
662# ARG=
663doTARBALL:
664.if !defined(SD)
665	@echo "SD undefined in doTARBALL" && exit 1
666.endif
667.if !defined(TD)
668	@echo "TB undefined in doTARBALL" && exit 1
669.endif
670.if !defined(ARG)
671	@echo "ARG undefined in doTARBALL" && exit 1
672.endif
673	@rm -rf ${RD}/dists/${TD}/${TN}*
674	@mkdir -p ${RD}/dists/${TD}
675	@( cd ${SD} && \
676		tn=`echo ${TN} | tr '[A-Z]' '[a-z]' | cut -c1-8` && \
677		echo rolling ${TD}/$$tn tarball &&\
678		tar --exclude CVS --exclude obj --exclude BOOTMFS -cf - ${ARG} | \
679		${ZIPNSPLIT} ${RD}/dists/${TD}/$$tn. && \
680		sh ${.CURDIR}/scripts/info.sh ${RD}/dists/${TD}/$$tn > \
681		   ${RD}/dists/${TD}/$$tn.inf && \
682		if [ -f ${.CURDIR}/scripts/$${TD}-install.sh ]; then \
683		  cp -p ${.CURDIR}/scripts/$${TD}-install.sh ${RD}/dists/${TD}/install.sh; \
684		fi && \
685		if [ "${SD}" != "/usr/src" ]; then \
686			mtree -c -i -p ${SD}/${ARG} \
687			  -k gname,md5digest,mode,nlink,uname,size,link,type \
688			  > ${RD}/dists/${TD}/$$tn.mtree ; \
689		else \
690			true; \
691		fi; \
692		(cd ${RD}/dists/${TD}; \
693		   rm -f CHECKSUM.MD5; \
694		   md5 * > CHECKSUM.MD5) \
695	)
696
697doRELEASE:  release.1 release.2 ${DOCREL} release.3 release.4 release.5 \
698		release.6 release.7 release.8 release.9
699	@cd ${.CURDIR} && ${MAKE} ${EXTRAS}
700	@echo "Release done"
701
702floppies:
703	@cd ${.CURDIR} && ${MAKE} boot.flp
704	@cd ${.CURDIR} && ${MAKE} fixit.flp
705	@cd ${RD} && find floppies -print | cpio -dumpl ${FD}
706
707boot.flp:
708	@rm -f release.4 release.8
709	@cd ${.CURDIR} && ${MAKE} release.4 release.8 CRUNCH_TARGETS=boot
710
711fixit.flp:
712	@rm -f release.4 release.9
713	@cd ${.CURDIR} && ${MAKE} release.4 release.9 CRUNCH_TARGETS=fixit
714
715write_mfs_in_kernel:	${.CURDIR}/write_mfs_in_kernel.c
716	${CC} ${CFLAGS} -o write_mfs_in_kernel ${.CURDIR}/write_mfs_in_kernel.c
717
718installCRUNCH:
719.if !defined(CRUNCH)
720	@echo "CRUNCH undefined in installCRUNCH" && exit 1
721.endif
722.if !defined(DIR)
723	@echo "DIR undefined in installCRUNCH" && exit 1
724.endif
725.if !defined(ZIP)
726	@echo "ZIP undefined in installCRUNCH" && exit 1
727.endif
728	@if ${ZIP} ; then \
729		gzip -9 < ${RD}/crunch/${CRUNCH} > ${DIR}/${CRUNCH}_crunch ; \
730	else \
731		ln -f ${RD}/crunch/${CRUNCH} ${DIR}/${CRUNCH}_crunch ; \
732	fi
733	@chmod 555 ${DIR}/${CRUNCH}_crunch
734	@for i in `crunchgen -l ${.OBJDIR}/${CRUNCH}_crunch.conf` ; do \
735		ln -f ${DIR}/${CRUNCH}_crunch ${DIR}/$$i ; \
736	done
737
738#
739# --==## Compile a kernel by name ${KERNEL} ##==--
740#
741# We don't erase the sys/compile/${KERNEL} directory, since somebody
742# may want to reuse it (release.8 presently)
743#
744doKERNEL:
745	@rm -f ${RD}/kernels/${KERNEL}
746	@cd ${.CURDIR}/../sys/${MACHINE}/conf && config ${KERNEL}
747	@cd ${.CURDIR}/../sys/compile/${KERNEL} && \
748			make  depend && \
749			make  ${KERNEL} && \
750			strip --strip-debug ${KERNEL} && \
751			cp ${KERNEL} ${RD}/kernels/${KERNEL}
752
753#
754# --==## Put a filesystem into a BOOTMFS kernel ##==--
755#
756doMFSKERN:
757	@echo "Running doMFSKERN for ${FSIMAGE}"
758	@rm -f ${RD}/kernels/BOOTMFS.${FSIMAGE}
759	@cd ${.CURDIR}/../sys/${MACHINE}/conf && \
760	  sh ${.CURDIR}/scripts/dokern.sh ${BIGBOOT} < ${KERNCONF} > BOOTMFS
761.if ${MACHINE_ARCH} == "i386"
762	@echo "options  INTRO_USERCONFIG" >> \
763	  ${.CURDIR}/../sys/${MACHINE}/conf/BOOTMFS
764.endif
765.if defined(BIGBOOT)
766	@echo "options \"MD_ROOT_SIZE=`cat mfsroot.size`\"" >> \
767	  ${.CURDIR}/../sys/${MACHINE}/conf/BOOTMFS
768.endif
769	@cd ${.CURDIR} && ${MAKE} doKERNEL KERNEL=BOOTMFS
770	@rm -rf ${RD}/image.${FSIMAGE}
771	@mkdir  ${RD}/image.${FSIMAGE}
772	@strip ${RD}/kernels/BOOTMFS
773	@cp ${RD}/kernels/BOOTMFS ${RD}/kernels/BOOTMFS.${FSIMAGE}
774	mv ${RD}/kernels/BOOTMFS ${RD}/image.${FSIMAGE}/kernel
775	@echo "Setting up /boot directory for ${FSIMAGE} floppy"
776	@mkdir -p ${RD}/image.${FSIMAGE}/boot
777	@cp /boot/boot[12] /boot/loader ${RD}/image.${FSIMAGE}/boot
778.if !defined(BIGBOOT)
779	@echo "load /kernel" > ${RD}/image.${FSIMAGE}/boot/loader.rc
780	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
781	@echo "echo Please insert MFS root floppy and press enter:" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
782	@echo "read" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
783	@echo "load -t mfs_root /mfsroot" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
784.endif
785	@echo "echo \\007\\007" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
786	@echo "autoboot 10" >> ${RD}/image.${FSIMAGE}/boot/loader.rc
787	@touch ${RD}/image.${FSIMAGE}/boot/loader.config
788.if ${MACHINE_ARCH} == "i386" && ${AUTO_KEYBOARD_DETECT}
789	@echo "-P" >> ${RD}/image.${FSIMAGE}/boot.config
790.endif
791.if defined(BIGBOOT)
792	@echo "Writing MFS image into kernel for ${FSIMAGE} floppy"
793	@./write_mfs_in_kernel ${RD}/image.${FSIMAGE}/kernel mfsroot
794	@cp ${RD}/image.${FSIMAGE}/kernel ${RD}/kernels/MFSKERNEL.${FSIMAGE}
795.endif
796	@gzip -9v ${RD}/image.${FSIMAGE}/kernel
797	@touch ${RD}/image.${FSIMAGE}/kernel.config
798	@rm -f ${RD}/floppies/${FSIMAGE}.flp
799.if defined(BIGBOOT)
800	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
801		${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \
802		${BOOTINODE} ${BIGBOOTLABEL}
803.else
804	sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \
805		${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \
806		${BOOTINODE} ${BOOTLABEL}
807.endif
808	@echo "Created ${RD}/floppies/${FSIMAGE}.flp"
809
810.include <bsd.prog.mk>
811