Makefile revision 219483
150477Speter# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 219483 2011-03-11 13:11:15Z jhb $
240269Srnordier
3213136Spjd.PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
440326Srnordier
5172940SjhbFILES=		gptboot
6172940Sjhb
780751SjhbNM?=		nm
880751Sjhb
942480SrnordierBOOT_COMCONSOLE_PORT?= 0x3f8
1042480SrnordierBOOT_COMCONSOLE_SPEED?= 9600
1140541SrnordierB2SIOFMT?=	0x3
1240541Srnordier
13104673SgreenREL1=	0x700
1440269SrnordierORG1=	0x7c00
15172940SjhbORG2=	0x0
1640269Srnordier
17125537Sru# Decide level of UFS support.
18172940SjhbGPTBOOT_UFS?=	UFS1_AND_UFS2
19172940Sjhb#GPTBOOT_UFS?=	UFS2_ONLY
20172940Sjhb#GPTBOOT_UFS?=	UFS1_ONLY
21104635Sphk
22213136SpjdCFLAGS=	-DBOOTPROG=\"gptboot\" \
23213136Spjd	-Os \
24132870Skan	-fno-guess-branch-probability \
25132870Skan	-fomit-frame-pointer \
26132870Skan	-fno-unit-at-a-time \
27108149Sobrien	-mno-align-long-strings \
2896327Sjhb	-mrtd \
29213136Spjd	-DGPT \
30172940Sjhb	-D${GPTBOOT_UFS} \
31125932Sru	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
32125932Sru	-DSIOFMT=${B2SIOFMT} \
33125932Sru	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
3497860Sphk	-I${.CURDIR}/../../common \
35213136Spjd	-I${.CURDIR}/../common \
36173026Sjhb	-I${.CURDIR}/../btx/lib -I. \
37172940Sjhb	-I${.CURDIR}/../boot2 \
38213568Spho	-I${.CURDIR}/../../.. \
3940269Srnordier	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
4040269Srnordier	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
41169732Skan	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
42169732Skan	-Winline --param max-inline-insns-single=100
4340269Srnordier
44218893Sdim.if ${CC:T:Mclang} == "clang"
45218893Sdim# XXX: clang integrated-as doesn't grok .codeNN directives yet
46218893SdimCFLAGS+=	${.IMPSRC:T:Mgptldr.S:C/^.+$/-no-integrated-as/}
47218893Sdim.endif
48218893Sdim
49125621SruLDFLAGS=-static -N --gc-sections
5040269Srnordier
51125537Sru# Pick up ../Makefile.inc early.
52125537Sru.include <bsd.init.mk>
5340269Srnordier
54172940SjhbCLEANFILES=	gptboot
55125537Sru
56172940Sjhbgptboot: gptldr.bin gptboot.bin ${BTXKERN}
57172940Sjhb	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
58172940Sjhb	    -o ${.TARGET} gptboot.bin
59109886Sphk
60172940SjhbCLEANFILES+=	gptldr.bin gptldr.out gptldr.o
61125537Sru
62172940Sjhbgptldr.bin: gptldr.out
63172940Sjhb	objcopy -S -O binary gptldr.out ${.TARGET}
6440269Srnordier
65172940Sjhbgptldr.out: gptldr.o
66172940Sjhb	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
6740269Srnordier
68219483SjhbCLEANFILES+=	gptboot.bin gptboot.out gptboot.o sio.o gpt.o crc32.o drv.o \
69219483Sjhb		cons.o util.o
7096424Speter
71172940Sjhbgptboot.bin: gptboot.out
72172940Sjhb	objcopy -S -O binary gptboot.out ${.TARGET}
7380751Sjhb
74213136Spjdgptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o
75213136Spjd	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
7640269Srnordier
77172940Sjhbgptboot.o: ${.CURDIR}/../../common/ufsread.c
7880751Sjhb
79211677Simp.if ${MACHINE_CPUARCH} == "amd64"
80172940Sjhbbeforedepend gptboot.o: machine
81125556SruCLEANFILES+=	machine
82116864Spetermachine:
83116864Speter	ln -sf ${.CURDIR}/../../../i386/include machine
84116864Speter.endif
85116864Speter
86125537Sru.include <bsd.prog.mk>
87