Makefile revision 125537
1# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 125537 2004-02-06 21:58:32Z ru $
2
3FILES=		boot boot1 boot2
4
5NM?=		nm
6
7# A value of 0x80 enables LBA support.
8B1FLAGS=	0x80
9
10BOOT_COMCONSOLE_PORT?= 0x3f8
11BOOT_COMCONSOLE_SPEED?= 9600
12B2SIOFMT?=	0x3
13
14REL1=	0x700
15ORG1=	0x7c00
16ORG2=	0x2000
17
18# Decide level of UFS support.
19BOOT2_UFS?=	UFS1_AND_UFS2
20#BOOT2_UFS?=	UFS2_ONLY
21#BOOT2_UFS?=	UFS1_ONLY
22
23AFLAGS+=--defsym FLAGS=${B1FLAGS} \
24	--defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
25	--defsym SIOFMT=${B2SIOFMT} \
26	--defsym SIOSPD=${BOOT_COMCONSOLE_SPEED}
27
28CFLAGS=	-elf -ffreestanding -Os -fno-builtin \
29	-fno-guess-branch-probability -fomit-frame-pointer\
30	-mno-align-long-strings \
31	-mrtd \
32	-D${BOOT2_UFS} \
33	-I${.CURDIR}/../../common \
34	-I${.CURDIR}/../btx/lib -I. \
35	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
36	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
37	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
38
39LDFLAGS=-nostdlib -static -N --gc-sections
40
41# Pick up ../Makefile.inc early.
42.include <bsd.init.mk>
43
44CLEANFILES=	boot
45
46boot: boot1 boot2
47	cat boot1 boot2 > boot
48
49CLEANFILES+=	boot1 boot1.out boot1.o
50
51boot1: boot1.out
52	objcopy -S -O binary boot1.out ${.TARGET}
53
54boot1.out: boot1.o
55	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
56
57boot1.o: boot1.s
58	${CPP} ${CFLAGS} ${.CURDIR}/boot1.s | \
59	    ${AS} ${AFLAGS} -o ${.TARGET}
60
61CLEANFILES+=	boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
62		boot2.s boot2.s.tmp boot2.h sio.o
63
64boot2: boot2.ld
65	@set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
66	    echo "$$x bytes available"; test $$x -ge 0
67	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
68
69boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
70	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
71	    -o ${.TARGET} -P 1 boot2.bin
72
73boot2.ldr:
74	dd if=/dev/zero of=${.TARGET} bs=276 count=1
75
76boot2.bin: boot2.out
77	objcopy -S -O binary boot2.out ${.TARGET}
78
79boot2.out: ${BTXCRT} boot2.o sio.o
80	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
81
82boot2.o: boot2.s
83
84boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
85	${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
86	sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
87	rm -f boot2.s.tmp
88
89boot2.h: boot1.out
90	${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
91	    { x = $$1 - ORG1; \
92	    printf("#define XREADORG %#x\n", REL1 + x) }' \
93	    ORG1=`printf "%d" ${ORG1}` \
94	    REL1=`printf "%d" ${REL1}` > ${.TARGET}
95
96.if defined(REALLY_AMD64)
97boot2.s: machine
98
99machine:
100	ln -sf ${.CURDIR}/../../../i386/include machine
101
102CLEANFILES+=	machine
103.endif
104
105.include <bsd.prog.mk>
106