Makefile revision 169732
150477Speter# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 169732 2007-05-19 05:07:47Z kan $
240269Srnordier
3125537SruFILES=		boot boot1 boot2
440326Srnordier
580751SjhbNM?=		nm
680751Sjhb
748919Srnordier# A value of 0x80 enables LBA support.
8134382SyarBOOT_BOOT1_FLAGS?=	0x80
948919Srnordier
1042480SrnordierBOOT_COMCONSOLE_PORT?= 0x3f8
1142480SrnordierBOOT_COMCONSOLE_SPEED?= 9600
1240541SrnordierB2SIOFMT?=	0x3
1340541Srnordier
14104673SgreenREL1=	0x700
1540269SrnordierORG1=	0x7c00
16104683SjhbORG2=	0x2000
1740269Srnordier
18125537Sru# Decide level of UFS support.
19108000SimpBOOT2_UFS?=	UFS1_AND_UFS2
20125537Sru#BOOT2_UFS?=	UFS2_ONLY
21125537Sru#BOOT2_UFS?=	UFS1_ONLY
22104635Sphk
23125566SruCFLAGS=	-Os \
24132870Skan	-fno-guess-branch-probability \
25132870Skan	-fomit-frame-pointer \
26132870Skan	-fno-unit-at-a-time \
27108149Sobrien	-mno-align-long-strings \
2896327Sjhb	-mrtd \
29148046Sache	-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
30107879Sphk	-D${BOOT2_UFS} \
31134382Syar	-DFLAGS=${BOOT_BOOT1_FLAGS} \
32125932Sru	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
33125932Sru	-DSIOFMT=${B2SIOFMT} \
34125932Sru	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
3597860Sphk	-I${.CURDIR}/../../common \
3696306Sobrien	-I${.CURDIR}/../btx/lib -I. \
3740269Srnordier	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
3840269Srnordier	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
39169732Skan	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
40169732Skan	-Winline --param max-inline-insns-single=100
4140269Srnordier
42125621SruLDFLAGS=-static -N --gc-sections
4340269Srnordier
44125537Sru# Pick up ../Makefile.inc early.
45125537Sru.include <bsd.init.mk>
4640269Srnordier
47125537SruCLEANFILES=	boot
48125537Sru
49109886Sphkboot: boot1 boot2
50109886Sphk	cat boot1 boot2 > boot
51109886Sphk
52125537SruCLEANFILES+=	boot1 boot1.out boot1.o
53125537Sru
5440269Srnordierboot1: boot1.out
5540308Srnordier	objcopy -S -O binary boot1.out ${.TARGET}
5640269Srnordier
5740269Srnordierboot1.out: boot1.o
5840269Srnordier	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
5940269Srnordier
60125537SruCLEANFILES+=	boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
61125537Sru		boot2.s boot2.s.tmp boot2.h sio.o
6296424Speter
63125537Sruboot2: boot2.ld
64125537Sru	@set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
65125537Sru	    echo "$$x bytes available"; test $$x -ge 0
66125537Sru	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
6780751Sjhb
68125537Sruboot2.ld: boot2.ldr boot2.bin ${BTXKERN}
69125537Sru	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
70125537Sru	    -o ${.TARGET} -P 1 boot2.bin
7140269Srnordier
7240269Srnordierboot2.ldr:
73125537Sru	dd if=/dev/zero of=${.TARGET} bs=276 count=1
7440269Srnordier
7540269Srnordierboot2.bin: boot2.out
7640308Srnordier	objcopy -S -O binary boot2.out ${.TARGET}
7740269Srnordier
78125537Sruboot2.out: ${BTXCRT} boot2.o sio.o
79125537Sru	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
8040269Srnordier
81125537Sruboot2.o: boot2.s
8280751Sjhb
83125564SruSRCS=	boot2.c boot2.h
84125564Sru
85125537Sruboot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
86125537Sru	${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
87125537Sru	sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
88125537Sru	rm -f boot2.s.tmp
8940404Srnordier
90125537Sruboot2.h: boot1.out
91125537Sru	${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
92125537Sru	    { x = $$1 - ORG1; \
93125537Sru	    printf("#define XREADORG %#x\n", REL1 + x) }' \
94125537Sru	    ORG1=`printf "%d" ${ORG1}` \
95125537Sru	    REL1=`printf "%d" ${REL1}` > ${.TARGET}
9640326Srnordier
97125556Sru.if ${MACHINE_ARCH} == "amd64"
98125581Srubeforedepend boot2.s: machine
99125556SruCLEANFILES+=	machine
100116864Spetermachine:
101116864Speter	ln -sf ${.CURDIR}/../../../i386/include machine
102116864Speter.endif
103116864Speter
104125537Sru.include <bsd.prog.mk>
105