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