1# $FreeBSD: releng/11.0/sys/boot/i386/gptboot/Makefile 297283 2016-03-26 03:46:12Z bdrewery $
2
3.PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
4
5FILES=		gptboot
6MAN=		gptboot.8
7
8NM?=		nm
9
10BOOT_COMCONSOLE_PORT?= 0x3f8
11BOOT_COMCONSOLE_SPEED?= 9600
12B2SIOFMT?=	0x3
13
14REL1=	0x700
15ORG1=	0x7c00
16ORG2=	0x0
17
18# Decide level of UFS support.
19GPTBOOT_UFS?=	UFS1_AND_UFS2
20#GPTBOOT_UFS?=	UFS2_ONLY
21#GPTBOOT_UFS?=	UFS1_ONLY
22
23CFLAGS=	-DBOOTPROG=\"gptboot\" \
24	-O1 \
25	-DGPT \
26	-D${GPTBOOT_UFS} \
27	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
28	-DSIOFMT=${B2SIOFMT} \
29	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
30	-I${.CURDIR}/../../common \
31	-I${.CURDIR}/../common \
32	-I${.CURDIR}/../btx/lib -I. \
33	-I${.CURDIR}/../boot2 \
34	-I${.CURDIR}/../../.. \
35	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
36	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
37	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
38	-Winline
39
40CFLAGS.gcc+=	--param max-inline-insns-single=100
41
42.if !defined(LOADER_NO_GELI_SUPPORT)
43CFLAGS+=	-DLOADER_GELI_SUPPORT
44CFLAGS+=	-I${.CURDIR}/../../geli
45LIBGELIBOOT=	${.OBJDIR}/../../geli/libgeliboot.a
46.PATH:		${.CURDIR}/../../../opencrypto
47OPENCRYPTO_XTS=	xform_aes_xts.o
48.endif
49
50LD_FLAGS=-static -N --gc-sections
51
52LIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
53
54# Pick up ../Makefile.inc early.
55.include <bsd.init.mk>
56
57CLEANFILES=	gptboot
58
59gptboot: gptldr.bin gptboot.bin ${BTXKERN}
60	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
61	    -o ${.TARGET} gptboot.bin
62
63CLEANFILES+=	gptldr.bin gptldr.out gptldr.o
64
65gptldr.bin: gptldr.out
66	${OBJCOPY} -S -O binary gptldr.out ${.TARGET}
67
68gptldr.out: gptldr.o
69	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
70
71CLEANFILES+=	gptboot.bin gptboot.out gptboot.o sio.o crc32.o drv.o \
72		cons.o util.o ${OPENCRYPTO_XTS}
73
74gptboot.bin: gptboot.out
75	${OBJCOPY} -S -O binary gptboot.out ${.TARGET}
76
77gptboot.out: ${BTXCRT} gptboot.o sio.o crc32.o drv.o cons.o util.o ${OPENCRYPTO_XTS}
78	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND} ${LIBGELIBOOT}
79
80gptboot.o: ${.CURDIR}/../../common/ufsread.c
81
82.if ${MACHINE_CPUARCH} == "amd64"
83beforedepend gptboot.o: machine
84CLEANFILES+=	machine
85machine: .NOMETA
86	ln -sf ${.CURDIR}/../../../i386/include machine
87.endif
88
89.include <bsd.prog.mk>
90
91# XXX: clang integrated-as doesn't grok .codeNN directives yet
92CFLAGS.gptldr.S=	${CLANG_NO_IAS}
93