Makefile revision 132870
1# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 132870 2004-07-30 04:27:20Z kan $
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
23CFLAGS=	-Os \
24	-fno-guess-branch-probability \
25	-fomit-frame-pointer \
26	-fno-unit-at-a-time \
27	-mno-align-long-strings \
28	-mrtd \
29	-D${BOOT2_UFS} \
30	-DFLAGS=${B1FLAGS} \
31	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
32	-DSIOFMT=${B2SIOFMT} \
33	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
34	-I${.CURDIR}/../../common \
35	-I${.CURDIR}/../btx/lib -I. \
36	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
37	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
38	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
39
40LDFLAGS=-static -N --gc-sections
41
42# Pick up ../Makefile.inc early.
43.include <bsd.init.mk>
44
45CLEANFILES=	boot
46
47boot: boot1 boot2
48	cat boot1 boot2 > boot
49
50CLEANFILES+=	boot1 boot1.out boot1.o
51
52boot1: boot1.out
53	objcopy -S -O binary boot1.out ${.TARGET}
54
55boot1.out: boot1.o
56	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
57
58CLEANFILES+=	boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
59		boot2.s boot2.s.tmp boot2.h sio.o
60
61boot2: boot2.ld
62	@set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
63	    echo "$$x bytes available"; test $$x -ge 0
64	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
65
66boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
67	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
68	    -o ${.TARGET} -P 1 boot2.bin
69
70boot2.ldr:
71	dd if=/dev/zero of=${.TARGET} bs=276 count=1
72
73boot2.bin: boot2.out
74	objcopy -S -O binary boot2.out ${.TARGET}
75
76boot2.out: ${BTXCRT} boot2.o sio.o
77	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
78
79boot2.o: boot2.s
80
81SRCS=	boot2.c boot2.h
82
83boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
84	${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
85	sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
86	rm -f boot2.s.tmp
87
88boot2.h: boot1.out
89	${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
90	    { x = $$1 - ORG1; \
91	    printf("#define XREADORG %#x\n", REL1 + x) }' \
92	    ORG1=`printf "%d" ${ORG1}` \
93	    REL1=`printf "%d" ${REL1}` > ${.TARGET}
94
95.if ${MACHINE_ARCH} == "amd64"
96beforedepend boot2.s: machine
97CLEANFILES+=	machine
98machine:
99	ln -sf ${.CURDIR}/../../../i386/include machine
100.endif
101
102.include <bsd.prog.mk>
103