Makefile revision 253211
1219820Sjeff# $FreeBSD: stable/9/sys/boot/i386/gptboot/Makefile 253211 2013-07-11 15:45:51Z wblock $
2219820Sjeff
3219820Sjeff.PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
4219820Sjeff
5270710ShselaskyFILES=		gptboot
6219820SjeffMAN=		gptboot.8
7219820Sjeff
8219820SjeffNM?=		nm
9219820Sjeff
10219820SjeffBOOT_COMCONSOLE_PORT?= 0x3f8
11219820SjeffBOOT_COMCONSOLE_SPEED?= 9600
12219820SjeffB2SIOFMT?=	0x3
13219820Sjeff
14219820SjeffREL1=	0x700
15219820SjeffORG1=	0x7c00
16219820SjeffORG2=	0x0
17219820Sjeff
18219820Sjeff# Decide level of UFS support.
19219820SjeffGPTBOOT_UFS?=	UFS1_AND_UFS2
20219820Sjeff#GPTBOOT_UFS?=	UFS2_ONLY
21219820Sjeff#GPTBOOT_UFS?=	UFS1_ONLY
22219820Sjeff
23219820SjeffCFLAGS=	-DBOOTPROG=\"gptboot\" \
24219820Sjeff	-O1 \
25219820Sjeff	-DGPT \
26219820Sjeff	-D${GPTBOOT_UFS} \
27219820Sjeff	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
28219820Sjeff	-DSIOFMT=${B2SIOFMT} \
29219820Sjeff	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
30219820Sjeff	-I${.CURDIR}/../../common \
31219820Sjeff	-I${.CURDIR}/../common \
32219820Sjeff	-I${.CURDIR}/../btx/lib -I. \
33219820Sjeff	-I${.CURDIR}/../boot2 \
34219820Sjeff	-I${.CURDIR}/../../.. \
35219820Sjeff	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
36219820Sjeff	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
37219820Sjeff	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
38219820Sjeff	-Winline --param max-inline-insns-single=100
39219820Sjeff
40219820SjeffLDFLAGS=-static -N --gc-sections
41219820Sjeff
42219820Sjeff# Pick up ../Makefile.inc early.
43219820Sjeff.include <bsd.init.mk>
44219820Sjeff
45219820SjeffCLEANFILES=	gptboot
46219820Sjeff
47219820Sjeffgptboot: gptldr.bin gptboot.bin ${BTXKERN}
48219820Sjeff	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
49219820Sjeff	    -o ${.TARGET} gptboot.bin
50219820Sjeff
51219820SjeffCLEANFILES+=	gptldr.bin gptldr.out gptldr.o
52219820Sjeff
53219820Sjeffgptldr.bin: gptldr.out
54219820Sjeff	objcopy -S -O binary gptldr.out ${.TARGET}
55219820Sjeff
56219820Sjeffgptldr.out: gptldr.o
57219820Sjeff	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
58219820Sjeff
59219820SjeffCLEANFILES+=	gptboot.bin gptboot.out gptboot.o sio.o gpt.o crc32.o drv.o \
60219820Sjeff		cons.o util.o
61219820Sjeff
62219820Sjeffgptboot.bin: gptboot.out
63270710Shselasky	objcopy -S -O binary gptboot.out ${.TARGET}
64
65gptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o
66	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
67
68gptboot.o: ${.CURDIR}/../../common/ufsread.c
69
70.if ${MACHINE_CPUARCH} == "amd64"
71beforedepend gptboot.o: machine
72CLEANFILES+=	machine
73machine:
74	ln -sf ${.CURDIR}/../../../i386/include machine
75.endif
76
77.include <bsd.prog.mk>
78
79# XXX: clang integrated-as doesn't grok .codeNN directives yet
80CFLAGS.gptldr.S=	${CLANG_NO_IAS}
81CFLAGS+=		${CFLAGS.${.IMPSRC:T}}
82