Makefile.bootfloppy revision 1.5
11.5Slukem#	$NetBSD: Makefile.bootfloppy,v 1.5 2002/04/11 12:17:15 lukem Exp $
21.1Slukem
31.5Slukem.include <bsd.own.mk>
41.5Slukem.include "${_SRC_TOP_}/distrib/Makefile.inc"
51.5Slukem
61.5Slukem# needs the following set:
71.5Slukem#	IMAGE		image name
81.5Slukem#	KERNELDIR	where kernel is grabbed from
91.5Slukem#	KERNEL		kernel name
101.5Slukem#	DISKSIZE	size of image in 0.5K blocks
111.1Slukem
121.1SlukemFSTMP=		ustar.tmp
131.1SlukemMDEC=		${DESTDIR}/usr/mdec
141.1SlukemBOOTCODE?=	${MDEC}/biosboot.sym
151.1Slukem#BOOTCODE=	${MDEC}/biosboot_com0.sym	# Serial output
161.1Slukem
171.5SlukemCLEANFILES+=	netbsd boot ustar.tmp ${METAFILE} ${IMAGE} ${IMAGE}.tmp
181.1Slukem
191.5Slukemrealall:	${IMAGE}
201.1Slukem
211.5Slukem${IMAGE}:	netbsd boot
221.1Slukem	if test "${METAFILE}" != ""; then \
231.1Slukem		touch ${METAFILE}; \
241.1Slukem	fi
251.1Slukem	${PAX} -wvf ${FSTMP} boot ${METAFILE} netbsd
261.1Slukem	@echo
271.1Slukem	@echo Making disk number one
281.1Slukem	rm -rf empty
291.1Slukem	mkdir -m 755 empty
301.1Slukem	${MAKEFS} -s ${DISKSIZE}b ${IMAGE}.tmp empty
311.1Slukem	dd bs=8k seek=1 count=$$((${DISKSIZE} / 16 - 1)) \
321.1Slukem	    if=${FSTMP} of=${IMAGE}.tmp
331.1Slukem	@echo "installing new bootblocks"
341.1Slukem	${MDEC}/installboot -b 17 -v -f ${BOOTCODE} ${IMAGE}.tmp
351.5Slukem		# XXXDISTRIB
361.1Slukem	@ls -l ${FSTMP} | (read mode links uid gid size junk; \
371.1Slukem		dksize=$$((${DISKSIZE} * 512 - 8 * 1024)); \
381.1Slukem		disks=$$(($$size / $$dksize + 1)); \
391.1Slukem		if test $$size -gt $$dksize; then \
401.1Slukem                	bytes=$$(($$size - $$dksize));    \
411.1Slukem			echo "Image is $$bytes ($$(($$bytes / 1024))K) too big\
421.1Slukem				to fit on one disk."; \
431.1Slukem			exit 1; \
441.1Slukem		else \
451.1Slukem			dd seek=$$(($${size} / 512 + 15)) count=1 \
461.1Slukem				if=/dev/zero of=${IMAGE}.tmp; \
471.1Slukem		fi; \
481.1Slukem		echo; \
491.1Slukem                bytes=$$(($$dksize * $$disks - $$size));    \
501.1Slukem		if test "${PAD}" = "yes"; then \
511.1Slukem			size=$$(($$size + 8 * 1024)); \
521.1Slukem			echo "Padding image with $$bytes bytes from $$size"; \
531.1Slukem			sectors=$$(($$bytes / 512)); \
541.1Slukem			ssize=$$(($$size / 512)); \
551.1Slukem			dd if=/dev/zero bs=512 seek=$${ssize} of=${IMAGE}.tmp \
561.1Slukem				count=$${sectors}; \
571.1Slukem                else \
581.1Slukem			echo "There are $$bytes ($$(($$bytes / 1024))K) bytes\
591.1Slukem				free on disk $$disks."; \
601.1Slukem		fi; \
611.1Slukem	)
621.1Slukem	mv -f ${IMAGE}.tmp ${IMAGE}
631.1Slukem
641.1Slukem# Let the kernel on the diskette be called "netbsd" although
651.1Slukem# it is compressed.  This is because the boot code will search
661.3Slukem# for "netbsd" first, and calling it "netbsd" instead of "netbsd.gz"
671.1Slukem# we avoid scanning all the diskettes before reading the file.
681.1Slukem
691.5SlukemKERNELOBJDIR!=	cd ${.CURDIR}/../${KERNELDIR} && ${PRINTOBJDIR}
701.5Slukem
711.5Slukemnetbsd: ${KERNELOBJDIR}/${KERNEL}
721.1Slukem	rm -f netbsd
731.5Slukem	cp ${KERNELOBJDIR}/${KERNEL} netbsd
741.1Slukem
751.1Slukem# This is "cheating", just so that we have the available
761.1Slukem# space at the start of the tar file.  Installboot will overwrite
771.3Slukem# the start of the bootcode with the tail end of the "real", aligned
781.1Slukem# second-stage boot loader when it is run (which is quite a bit shorter
791.1Slukem# than the entire ${BOOTCODE} file, even when symbols are removed.
801.1Slukem# (the first 15*512 bytes are put into the first 8K filesystem block,
811.1Slukem# around the disklabel)
821.1Slukem
831.1Slukemboot: ${BOOTCODE}
841.1Slukem	rm -f boot
851.1Slukem	cp ${BOOTCODE} boot
861.1Slukem	${STRIP} boot
871.1Slukem
881.2Slukemrelease: check_RELEASEDIR
891.1Slukem	-mkdir -p ${RELEASEDIR}/installation/floppy
901.1Slukem	cp -p ${IMAGE} ${RELEASEDIR}/installation/floppy
911.3Slukem
921.1Slukemclean cleandir distclean:
931.1Slukem	rm -rf empty
941.1Slukem
951.5Slukem.include <bsd.prog.mk>
96