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