1SUMMARY = "Libraries for producing EFI binaries"
2HOMEPAGE = "http://sourceforge.net/projects/gnu-efi/"
3DESCRIPTION = "GNU-EFI aims to Develop EFI applications for ARM-64, ARM-32, x86_64, IA-64 (IPF), IA-32 (x86), and MIPS platforms using the GNU toolchain and the EFI development environment."
4SECTION = "devel"
5LICENSE = "GPL-2.0-or-later & BSD-2-Clause"
6LIC_FILES_CHKSUM = "file://gnuefi/crt0-efi-arm.S;beginline=4;endline=16;md5=8b0a86085b86eda7a3c7e8a1eb7ec753 \
7                    file://gnuefi/crt0-efi-aarch64.S;beginline=4;endline=16;md5=8b0a86085b86eda7a3c7e8a1eb7ec753 \
8                    file://inc/efishellintf.h;beginline=13;endline=20;md5=ee14c1530c341a7050837adead6bc9a5 \
9                    file://lib/arm/math.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
10                    file://lib/arm/initplat.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
11                    file://lib/aarch64/math.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
12                    file://lib/aarch64/initplat.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
13                   "
14
15COMPATIBLE_HOST = "(x86_64.*|i.86.*|aarch64.*|arm.*|riscv64.*)-linux"
16COMPATIBLE_HOST:armv4 = 'null'
17
18SRC_URI = "git://github.com/ncroxon/gnu-efi;protocol=https;branch=master \
19           file://0002-Do-not-treat-warnings-as-errors.patch \
20           "
21SRCREV = "5ea320f0f01c8de8f9dd4e4e38a245608f0287dd"
22
23S = "${WORKDIR}/git"
24
25inherit github-releases
26
27do_configure:linux-gnux32:prepend() {
28	cp ${STAGING_INCDIR}/gnu/stubs-x32.h ${STAGING_INCDIR}/gnu/stubs-64.h
29	cp ${STAGING_INCDIR}/bits/long-double-32.h ${STAGING_INCDIR}/bits/long-double-64.h
30}
31
32def gnu_efi_arch(d):
33    import re
34    tarch = d.getVar("TARGET_ARCH")
35    if re.match("i[3456789]86", tarch):
36        return "ia32"
37    return tarch
38
39do_compile:prepend() {
40    unset LDFLAGS
41}
42
43EXTRA_OEMAKE = "'V=1' 'ARCH=${@gnu_efi_arch(d)}' \
44                'HOSTCC=${BUILD_CC}' 'CC=${CC}' \
45                'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \
46                'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' \
47                'PREFIX=${prefix}' 'LIBDIR=${libdir}' 'INCLUDEDIR=${includedir}' \
48                "
49
50# gnu-efi's Makefile treats prefix as toolchain prefix, so don't
51# export it.
52prefix[unexport] = "1"
53
54do_install() {
55        oe_runmake install INSTALLROOT="${D}"
56}
57
58FILES:${PN} += "${libdir}/*.lds ${libdir}/gnuefi/apps"
59
60# 64-bit binaries are expected for EFI when targeting X32
61INSANE_SKIP:${PN}-dev:append:linux-gnux32 = " arch"
62INSANE_SKIP:${PN}-dev:append:linux-muslx32 = " arch"
63
64BBCLASSEXTEND = "native"
65
66# It doesn't support sse, its make.defaults sets:
67# CFLAGS += -mno-mmx -mno-sse
68# So also remove -mfpmath=sse from TUNE_CCARGS
69TUNE_CCARGS:remove = "-mfpmath=sse"
70
71python () {
72    ccargs = d.getVar('TUNE_CCARGS').split()
73    if '-mx32' in ccargs:
74        # use x86_64 EFI ABI
75        ccargs.remove('-mx32')
76        ccargs.append('-m64')
77        d.setVar('TUNE_CCARGS', ' '.join(ccargs))
78}
79