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