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