1293297Semaste# $FreeBSD: releng/10.3/sys/boot/efi/loader/Makefile 294999 2016-01-28 17:24:40Z smh $
2293297Semaste
3293297SemasteMAN=
4293297Semaste
5293297Semaste.include <bsd.own.mk>
6293297Semaste
7293297SemasteMK_SSP=		no
8293297Semaste
9293297SemastePROG=		loader.sym
10293297SemasteINTERNALPROG=
11294981SsmhWARNS?=		3
12293297Semaste
13293297Semaste# architecture-specific loader code
14293297SemasteSRCS=	autoload.c \
15293297Semaste	bootinfo.c \
16293297Semaste	conf.c \
17293297Semaste	copy.c \
18293297Semaste	devicename.c \
19293297Semaste	main.c \
20293303Semaste	smbios.c \
21293297Semaste	vers.c
22293297Semaste
23294999Ssmh.if ${MK_ZFS} != "no"
24294999SsmhSRCS+=		zfs.c
25294999Ssmh.PATH:		${.CURDIR}/../../zfs
26294999Ssmh
27294999Ssmh# Disable warnings that are currently incompatible with the zfs boot code
28294999SsmhCWARNFLAGS.zfs.c+=	-Wno-sign-compare
29294999SsmhCWARNFLAGS.zfs.c+=	-Wno-array-bounds
30294999SsmhCWARNFLAGS.zfs.c+=	-Wno-missing-prototypes
31294999Ssmh.endif
32294999Ssmh
33293347Semaste.PATH: ${.CURDIR}/arch/${MACHINE}
34293303Semaste# For smbios.c
35293303Semaste.PATH: ${.CURDIR}/../../i386/libi386
36293347Semaste.include "${.CURDIR}/arch/${MACHINE}/Makefile.inc"
37293297Semaste
38293297SemasteCFLAGS+=	-fPIC
39293297SemasteCFLAGS+=	-I${.CURDIR}
40293347SemasteCFLAGS+=	-I${.CURDIR}/arch/${MACHINE}
41293297SemasteCFLAGS+=	-I${.CURDIR}/../include
42293347SemasteCFLAGS+=	-I${.CURDIR}/../include/${MACHINE}
43293297SemasteCFLAGS+=	-I${.CURDIR}/../../../contrib/dev/acpica/include
44293297SemasteCFLAGS+=	-I${.CURDIR}/../../..
45293303SemasteCFLAGS+=	-I${.CURDIR}/../../i386/libi386
46294999Ssmh.if ${MK_ZFS} != "no"
47294999SsmhCFLAGS+=	-I${.CURDIR}/../../zfs
48294999SsmhCFLAGS+=	-I${.CURDIR}/../../../cddl/boot/zfs
49294999SsmhCFLAGS+=	-DEFI_ZFS_BOOT
50294999Ssmh.endif
51293303SemasteCFLAGS+=	-DNO_PCI -DEFI
52293297Semaste
53293297Semaste.if ${MK_FORTH} != "no"
54293297SemasteBOOT_FORTH=	yes
55293297SemasteCFLAGS+=	-DBOOT_FORTH
56293297SemasteCFLAGS+=	-I${.CURDIR}/../../ficl
57293347SemasteCFLAGS+=	-I${.CURDIR}/../../ficl/${MACHINE}
58293297SemasteLIBFICL=	${.OBJDIR}/../../ficl/libficl.a
59293297Semaste.endif
60293297Semaste
61293297Semaste# Include bcache code.
62293297SemasteHAVE_BCACHE=    yes
63293297Semaste
64293297Semaste.if defined(EFI_STAGING_SIZE)
65293297SemasteCFLAGS+=	-DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
66293297Semaste.endif
67293297Semaste
68293297Semaste# Always add MI sources 
69293297Semaste.PATH:		${.CURDIR}/../../common
70293297Semaste.include	"${.CURDIR}/../../common/Makefile.inc"
71293297SemasteCFLAGS+=	-I${.CURDIR}/../../common
72293297Semaste
73293297SemasteFILES=	loader.efi
74293297SemasteFILESMODE_loader.efi=	${BINMODE}
75293297Semaste
76293347SemasteLDSCRIPT=	${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE}
77293297SemasteLDFLAGS=	-Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc
78293297Semaste
79293297SemasteCLEANFILES=	vers.c loader.efi
80293297Semaste
81293347SemasteNEWVERSWHAT=	"EFI loader" ${MACHINE}
82293297Semaste
83293297Semastevers.c:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../efi/loader/version
84293297Semaste	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
85293297Semaste
86293297SemasteOBJCOPY?=	objcopy
87293297SemasteOBJDUMP?=	objdump
88293297Semaste
89293297Semaste.if ${MACHINE_CPUARCH} == "amd64"
90293297SemasteEFI_TARGET=	efi-app-x86_64
91293297Semaste.elif ${MACHINE_CPUARCH} == "i386"
92293297SemasteEFI_TARGET=	efi-app-ia32
93293297Semaste.endif
94293297Semaste
95294268Semasteloader.efi: ${PROG}
96293297Semaste	if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \
97293297Semaste		${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \
98293297Semaste		exit 1; \
99293297Semaste	fi
100293297Semaste	${OBJCOPY} -j .text -j .sdata -j .data \
101293297Semaste		-j .dynamic -j .dynsym -j .rel.dyn \
102293297Semaste		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
103293297Semaste		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
104293297Semaste
105293297SemasteLIBEFI=		${.OBJDIR}/../libefi/libefi.a
106293297Semaste
107293297SemasteDPADD=		${LIBFICL} ${LIBEFI} ${LIBSTAND} ${LDSCRIPT}
108293297SemasteLDADD=		${LIBFICL} ${LIBEFI} ${LIBSTAND}
109293297Semaste
110293297Semaste.include <bsd.prog.mk>
111293297Semaste
112293297Semastebeforedepend ${OBJS}: machine x86
113293297Semaste
114293297SemasteCLEANFILES+=   machine x86
115293297Semaste
116293297Semastemachine:
117293297Semaste	ln -sf ${.CURDIR}/../../../amd64/include machine
118293297Semaste
119293297Semastex86:
120293297Semaste	ln -sf ${.CURDIR}/../../../x86/include x86
121