Makefile revision 232930
150477Speter# $FreeBSD: stable/9/sys/boot/i386/gptboot/Makefile 232930 2012-03-13 18:39:57Z dim $
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\" \
23225530Savg	-O1 \
24213136Spjd	-DGPT \
25172940Sjhb	-D${GPTBOOT_UFS} \
26125932Sru	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
27125932Sru	-DSIOFMT=${B2SIOFMT} \
28125932Sru	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
2997860Sphk	-I${.CURDIR}/../../common \
30213136Spjd	-I${.CURDIR}/../common \
31173026Sjhb	-I${.CURDIR}/../btx/lib -I. \
32172940Sjhb	-I${.CURDIR}/../boot2 \
33213568Spho	-I${.CURDIR}/../../.. \
3440269Srnordier	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
3540269Srnordier	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
36169732Skan	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
37169732Skan	-Winline --param max-inline-insns-single=100
3840269Srnordier
39125621SruLDFLAGS=-static -N --gc-sections
4040269Srnordier
41125537Sru# Pick up ../Makefile.inc early.
42125537Sru.include <bsd.init.mk>
4340269Srnordier
44172940SjhbCLEANFILES=	gptboot
45125537Sru
46172940Sjhbgptboot: gptldr.bin gptboot.bin ${BTXKERN}
47172940Sjhb	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
48172940Sjhb	    -o ${.TARGET} gptboot.bin
49109886Sphk
50172940SjhbCLEANFILES+=	gptldr.bin gptldr.out gptldr.o
51125537Sru
52172940Sjhbgptldr.bin: gptldr.out
53172940Sjhb	objcopy -S -O binary gptldr.out ${.TARGET}
5440269Srnordier
55172940Sjhbgptldr.out: gptldr.o
56172940Sjhb	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
5740269Srnordier
58219483SjhbCLEANFILES+=	gptboot.bin gptboot.out gptboot.o sio.o gpt.o crc32.o drv.o \
59219483Sjhb		cons.o util.o
6096424Speter
61172940Sjhbgptboot.bin: gptboot.out
62172940Sjhb	objcopy -S -O binary gptboot.out ${.TARGET}
6380751Sjhb
64213136Spjdgptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o
65213136Spjd	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
6640269Srnordier
67172940Sjhbgptboot.o: ${.CURDIR}/../../common/ufsread.c
6880751Sjhb
69211677Simp.if ${MACHINE_CPUARCH} == "amd64"
70172940Sjhbbeforedepend gptboot.o: machine
71125556SruCLEANFILES+=	machine
72116864Spetermachine:
73116864Speter	ln -sf ${.CURDIR}/../../../i386/include machine
74116864Speter.endif
75116864Speter
76125537Sru.include <bsd.prog.mk>
77232930Sdim
78232930Sdim# XXX: clang integrated-as doesn't grok .codeNN directives yet
79232930SdimCFLAGS.gptldr.S=	${CLANG_NO_IAS}
80232930SdimCFLAGS+=		${CFLAGS.${.IMPSRC:T}}
81