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