Makefile revision 53134
1# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 53134 1999-11-13 23:08:46Z obrien $
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
14# A value of 0x80 enables LBA support.
15B1FLAGS=	0
16
17BOOT_COMCONSOLE_PORT?= 0x3f8
18BOOT_COMCONSOLE_SPEED?= 9600
19B2SIOFMT?=	0x3
20
21.if exists(${.OBJDIR}/../btx)
22BTX=	${.OBJDIR}/../btx
23.else
24BTX=	${.CURDIR}/../btx
25.endif
26
27ORG1=	0x7c00
28ORG2=	0x1000
29
30CFLAGS=	-elf -I${.CURDIR}/../btx/lib -I. \
31	-Os -fno-builtin -fforce-addr -fschedule-insns \
32	-malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
33	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
34	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
35	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
36
37LDFLAGS=-nostdlib -static -N
38
39all: boot1 boot2
40
41boot1: boot1.out
42	objcopy -S -O binary boot1.out ${.TARGET}
43
44boot1.out: boot1.o
45	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
46
47boot1.o: boot1.m4 boot1.s
48	(cd ${.CURDIR}; ${M4} -DFLAGS=${B1FLAGS} boot1.m4 boot1.s) | \
49		${AS} ${AFLAGS} -o ${.TARGET}
50
51boot2: boot2.ldr boot2.bin
52	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
53		-o boot2.ld -P 1 boot2.bin
54	@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
55		print x " bytes available"; if (x < 0) exit 1 }'
56	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
57
58boot2.ldr:
59	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
60
61boot2.bin: boot2.out
62	objcopy -S -O binary boot2.out ${.TARGET}
63
64boot2.out: boot2.o sio.o
65	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
66		${BTX}/lib/crt0.o boot2.o sio.o
67
68sio.o: sio.s
69	(cd ${.CURDIR}; ${M4} -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
70		-DSIOFMT=${B2SIOFMT} \
71		-DSIOSPD=${BOOT_COMCONSOLE_SPEED} sio.s) | \
72		${AS} ${AFLAGS} -o ${.TARGET}
73
74install:
75	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
76		boot1 ${DESTDIR}${BINDIR}/boot1
77	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
78		boot2 ${DESTDIR}${BINDIR}/boot2
79
80.include <bsd.prog.mk>
81