Makefile revision 1.17
1#	$NetBSD: Makefile,v 1.17 2002/03/31 02:15:42 tsutsui Exp $
2
3.include <bsd.own.mk>
4.include <bsd.kernobj.mk>
5
6.include "${.CURDIR}/../../../Makefile.inc"
7
8IMAGE=		boot.fs
9DISKSIZE=	2880
10FSTMP=		ustar.tmp
11MDEC=		${DESTDIR}/usr/mdec
12BOOT=		ofwboot
13
14KERNDIR!=	cd ${.CURDIR}/../md-kernel && ${PRINTOBJDIR}
15KERN=		${KERNDIR}/netbsd.INSTALL.gz
16
17CLEANFILES+=	netbsd ${BOOT} ${FSTMP}
18
19
20DISKTYPE=	floppy
21
22realall: netbsd ${BOOT}
23	${PAX} -wvf ${FSTMP} ${BOOT} netbsd
24	@echo
25	@echo Making disk number one
26	rm -rf empty
27	mkdir -m 755 empty
28	${MAKEFS} -s ${DISKSIZE}b ${IMAGE}.tmp empty
29	dd bs=8k seek=1 count=$$((${DISKSIZE} / 16 - 1)) \
30	    if=${FSTMP} of=${IMAGE}.tmp
31	@echo "installing new bootblocks"
32	${MDEC}/installboot -v -b 17 ${BOOT} ${MDEC}/bootxx ${IMAGE}.tmp
33	@ls -l ${FSTMP} | (read mode links uid gid size junk; \
34		dksize=$$((${DISKSIZE} * 512 - 8 * 1024)); \
35		disks=$$(($$size / $$dksize + 1)); \
36		if test $$size -gt $$dksize; then \
37			bytes=$$(($$size - $$dksize)); \
38			echo "Image is $$bytes ($$(($$bytes / 1024))K) too big\
39				to fit on one disk."; \
40			exit 1; \
41		else \
42			dd seek=$$(($${size} / 512 + 15)) count=1 \
43				if=/dev/zero of=${IMAGE}.tmp; \
44		fi; \
45		echo; \
46		bytes=$$(($$dksize * $$disks - $$size)); \
47		if test "${PAD}" = "yes"; then \
48			size=$$(($$size + 8 * 1024)); \
49			echo "Padding image with $$bytes bytes from $$size"; \
50			sectors=$$(($$bytes / 512)); \
51			ssize=$$(($$size / 512)); \
52			dd if=/dev/zero bs=512 seek=$${ssize} of=${IMAGE}.tmp \
53				count=$${sectors}; \
54		else \
55			echo "There are $$bytes ($$(($$bytes / 1024))K) bytes\
56				free on disk $$disks."; \
57		fi; \
58	)
59	mv -f ${IMAGE}.tmp ${IMAGE}
60
61# Let the kernel on the diskette be called "netbsd" although
62# it is compressed.  This is because the boot code will search
63# for "netbsd" first, and calling it "netbsd" instead of "netbsd.gz"
64# we avoid scanning all the diskettes before reading the file.
65
66netbsd: ${KERN}
67	rm -f netbsd
68	cp ${KERN} netbsd
69
70# This is "cheating", just so that we have the available
71# space at the start of the tar file.  Installboot will overwrite
72# the start of the bootcode with the tail end of the "real", aligned
73# second-stage boot loader when it is run (which is quite a bit shorter
74# than the entire ${BOOTCODE} file, even when symbols are removed.
75# (the first 15*512 bytes are put into the first 8K filesystem block,
76# around the disklabel)
77
78${BOOT}: ${MDEC}/${BOOT}
79	rm -f ${BOOT}
80	cp ${MDEC}/${BOOT} ${BOOT}
81
82release: check_RELEASEDIR
83	-mkdir -p ${RELEASEDIR}/installation/floppy
84	cp -p ${IMAGE} ${RELEASEDIR}/installation/floppy
85
86clean cleandir distclean:
87	rm -f *.core ${CLEANFILES} ${IMAGE} ${IMAGE}.tmp
88	rm -rf empty
89
90.include <bsd.obj.mk>
91.include <bsd.subdir.mk>
92