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