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