Makefile revision 40940
1#	$Id: Makefile,v 1.8 1998/10/20 20:20:48 rnordier Exp $
2
3PROG=		boot2
4NOMAN=
5STRIP=
6BINDIR?=	/boot
7BINMODE=	444
8CLEANFILES+=	boot1 boot1.out boot1.o \
9		boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
10		sio.o
11
12M4?=	m4
13
14B1INT13X?=	0
15B2SIOPRT?=	0x3f8
16B2SIOFMT?=	0x3
17B2SIODIV?=	0xc
18
19.if exists(${.OBJDIR}/../btx)
20BTX=	${.OBJDIR}/../btx
21.else
22BTX=	${.CURDIR}/../btx
23.endif
24
25ORG1=	0x7c00
26ORG2=	0x1000
27
28CFLAGS=	-elf -I${.CURDIR}/../btx/lib -I. -fno-builtin \
29	-O2 -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
30	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
31	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
32	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
33
34LDFLAGS=-nostdlib -static -N
35
36all: boot1 boot2
37
38boot1: boot1.out
39	objcopy -S -O binary boot1.out ${.TARGET}
40
41boot1.out: boot1.o
42	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
43
44boot1.o: boot1.m4 boot1.s
45	(cd ${.CURDIR}; ${M4} -DFLAGS=${B1INT13X} boot1.m4 boot1.s) | \
46		${AS} ${AFLAGS} -o ${.TARGET}
47
48boot2: boot2.ldr boot2.bin
49	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
50		-o boot2.ld -P 1 boot2.bin
51	@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
52		print x " bytes available"; if (x < 0) exit 1 }'
53	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
54
55boot2.ldr:
56	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
57
58boot2.bin: boot2.out
59	objcopy -S -O binary boot2.out ${.TARGET}
60
61boot2.out: boot2.o sio.o
62	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
63		${BTX}/lib/crt0.o boot2.o sio.o
64
65sio.o: sio.s
66	(cd ${.CURDIR}; ${M4} -DSIOPRT=${B2SIOPRT} \
67		-DSIOFMT=${B2SIOFMT} -DSIODIV=${B2SIODIV} sio.s) | \
68		${AS} ${AFLAGS} -o ${.TARGET}
69
70install:
71	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
72		boot1 ${DESTDIR}${BINDIR}/boot1
73	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
74		boot2 ${DESTDIR}${BINDIR}/boot2
75
76.include <bsd.prog.mk>
77