1160157Smarcel# $FreeBSD: stable/10/sys/boot/i386/gptzfsboot/Makefile 308915 2016-11-21 10:14:36Z avg $
2160157Smarcel
3160157Smarcel.PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../gptboot \
4160157Smarcel		${.CURDIR}/../zfsboot ${.CURDIR}/../common \
5160157Smarcel		${.CURDIR}/../../common
6160157Smarcel
7160157SmarcelFILES=		gptzfsboot
8160157SmarcelMAN=		gptzfsboot.8
9160157Smarcel
10160157SmarcelNM?=		nm
11160157Smarcel
12160157SmarcelBOOT_COMCONSOLE_PORT?= 0x3f8
13160157SmarcelBOOT_COMCONSOLE_SPEED?= 9600
14160157SmarcelB2SIOFMT?=	0x3
15160157Smarcel
16160157SmarcelREL1=	0x700
17160157SmarcelORG1=	0x7c00
18160157SmarcelORG2=	0x0
19160157Smarcel
20160157SmarcelCFLAGS=	-DBOOTPROG=\"gptzfsboot\" \
21160157Smarcel	-O1 \
22160157Smarcel	-DGPT -DZFS -DBOOT2 \
23160157Smarcel	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
24160157Smarcel	-DSIOFMT=${B2SIOFMT} \
25160157Smarcel	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
26160157Smarcel	-I${.CURDIR}/../../common \
27160157Smarcel	-I${.CURDIR}/../common \
28160157Smarcel	-I${.CURDIR}/../../zfs \
29160157Smarcel	-I${.CURDIR}/../../../cddl/boot/zfs \
30160157Smarcel	-I${.CURDIR}/../btx/lib -I. \
31160157Smarcel	-I${.CURDIR}/../boot2 \
32160157Smarcel	-I${.CURDIR}/../../.. \
33160157Smarcel	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
34160157Smarcel	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
35160157Smarcel	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
36160157Smarcel	-Winline
37160157Smarcel
38160157SmarcelCFLAGS.gcc+=	--param max-inline-insns-single=100
39160157Smarcel
40160157SmarcelLD_FLAGS=-static -N --gc-sections
41160157Smarcel
42160157SmarcelLIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
43160157Smarcel
44160157Smarcel# Pick up ../Makefile.inc early.
45.include <bsd.init.mk>
46
47CLEANFILES=	gptzfsboot
48
49gptzfsboot: gptldr.bin gptzfsboot.bin ${BTXKERN}
50	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
51	    -o ${.TARGET} gptzfsboot.bin
52
53CLEANFILES+=	gptldr.bin gptldr.out gptldr.o
54
55gptldr.bin: gptldr.out
56	${OBJCOPY} -S -O binary gptldr.out ${.TARGET}
57
58gptldr.out: gptldr.o
59	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
60
61CLEANFILES+=	gptzfsboot.bin gptzfsboot.out zfsboot.o sio.o cons.o \
62		drv.o gpt.o util.o
63
64gptzfsboot.bin: gptzfsboot.out
65	${OBJCOPY} -S -O binary gptzfsboot.out ${.TARGET}
66
67gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o
68	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
69
70zfsboot.o: ${.CURDIR}/../../zfs/zfsimpl.c
71
72.if ${MACHINE_CPUARCH} == "amd64"
73beforedepend zfsboot.o: machine
74CLEANFILES+=	machine
75machine:
76	ln -sf ${.CURDIR}/../../../i386/include machine
77.endif
78
79.include <bsd.prog.mk>
80
81# XXX: clang integrated-as doesn't grok .codeNN directives yet
82CFLAGS.gptldr.S=	${CLANG_NO_IAS}
83CFLAGS+=		${CFLAGS.${.IMPSRC:T}}
84