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