1 |
|
# Copyright 2004-2024 Gentoo Authors
|
|
1 |
# Copyright 2004-2025 Gentoo Authors
|
2 |
2 |
# Distributed under the terms of the GNU General Public License v2
|
3 |
3 |
|
4 |
4 |
EAPI=8
|
5 |
5 |
|
6 |
|
inherit toolchain-funcs
|
|
6 |
inherit flag-o-matic toolchain-funcs
|
7 |
7 |
|
8 |
8 |
DESCRIPTION="Library for build EFI Applications"
|
9 |
9 |
HOMEPAGE="https://sourceforge.net/projects/gnu-efi/"
|
10 |
|
SRC_URI="https://downloads.sourceforge.net/gnu-efi/${P}.tar.bz2"
|
|
10 |
SRC_URI="https://github.com/ncroxon/gnu-efi/archive/${PV}.tar.gz -> ${P}.tar.gz"
|
11 |
11 |
|
12 |
12 |
# inc/, lib/ dirs (README.efilib)
|
13 |
13 |
# - BSD-2
|
... | ... | |
16 |
16 |
# - GPL-2+ : setjmp_ia32.S
|
17 |
17 |
LICENSE="GPL-2+ BSD BSD-2"
|
18 |
18 |
SLOT="0"
|
19 |
|
KEYWORDS="-* amd64 arm arm64 ~riscv x86"
|
|
19 |
KEYWORDS="-* amd64 arm arm64 ~loong ~riscv x86"
|
20 |
20 |
IUSE="abi_x86_32 abi_x86_64 custom-cflags"
|
21 |
21 |
REQUIRED_USE="
|
22 |
22 |
amd64? ( || ( abi_x86_32 abi_x86_64 ) )
|
23 |
23 |
x86? ( || ( abi_x86_32 abi_x86_64 ) )
|
24 |
24 |
"
|
25 |
25 |
|
|
26 |
# for ld.bfd and objcopy
|
|
27 |
BDEPEND="sys-devel/binutils"
|
|
28 |
|
26 |
29 |
# These objects get run early boot (i.e. not inside of Linux),
|
27 |
30 |
# so doing these QA checks on them doesn't make sense.
|
28 |
31 |
QA_EXECSTACK="usr/*/lib*efi.a:* usr/*/crt*.o"
|
29 |
32 |
RESTRICT="strip"
|
30 |
33 |
|
31 |
|
PATCHES=( "${FILESDIR}"/${PN}-3.0.9-fix-clang-build.patch )
|
|
34 |
PATCHES=(
|
|
35 |
"${FILESDIR}"/${PN}-3.0.18-clang.patch
|
|
36 |
"${FILESDIR}"/${PN}-3.0.18-remove-linux-headers.patch
|
|
37 |
)
|
|
38 |
|
|
39 |
check_and_set_objcopy() {
|
|
40 |
if [[ ${MERGE_TYPE} != "binary" ]]; then
|
|
41 |
|
|
42 |
if use arm || use riscv; then
|
|
43 |
# bug #939338
|
|
44 |
# objcopy does not understand PE/COFF on these arches: arm32, riscv64 and mips64le
|
|
45 |
# gnu-efi containes a workaround
|
|
46 |
return 0
|
|
47 |
fi
|
|
48 |
|
|
49 |
# bug #931792
|
|
50 |
# llvm-objcopy does not support EFI target, try to use binutils objcopy or fail
|
|
51 |
tc-export OBJCOPY
|
|
52 |
# Test OBJCOPY to see if it supports EFI targets, and return if it does
|
|
53 |
LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' && return 0
|
|
54 |
|
|
55 |
# If OBJCOPY does not support EFI targets, it is possible that the 'objcopy' on our path is
|
|
56 |
# still LLVM if the 'binutils-plugin' USE flag is set. In this case, we check to see if the
|
|
57 |
# '(prefix)/usr/bin/objcopy' binary is available (it should be, it's a dependency), and if
|
|
58 |
# so, we use the absolute path explicitly.
|
|
59 |
local binutils_objcopy="${EPREFIX}"/usr/bin/objcopy
|
|
60 |
if [[ -e "${binutils_objcopy}" ]]; then
|
|
61 |
OBJCOPY="${binutils_objcopy}"
|
|
62 |
einfo "Forcing OBJCOPY=${OBJCOPY}"
|
|
63 |
fi
|
|
64 |
|
|
65 |
# Test OBJCOPY again to see if it supports EFI targets, and fail if it doesn't
|
|
66 |
LC_ALL=C "${OBJCOPY}" --help | grep -q '\<pei-' || die "${OBJCOPY} (objcopy) does not support EFI target"
|
|
67 |
fi
|
|
68 |
}
|
|
69 |
|
|
70 |
check_compiler() {
|
|
71 |
if [[ ${MERGE_TYPE} != "binary" ]]; then
|
|
72 |
tc-is-gcc || tc-is-clang || die "Unsupported compiler"
|
|
73 |
fi
|
|
74 |
}
|
|
75 |
|
|
76 |
pkg_pretend() {
|
|
77 |
check_compiler
|
|
78 |
}
|
|
79 |
|
|
80 |
pkg_setup() {
|
|
81 |
check_compiler
|
|
82 |
check_and_set_objcopy
|
|
83 |
}
|
32 |
84 |
|
33 |
85 |
src_prepare() {
|
34 |
86 |
default
|
... | ... | |
42 |
94 |
aarch64*) arch=aarch64 ;;
|
43 |
95 |
ia64*) arch=ia64 ;;
|
44 |
96 |
i?86*) arch=ia32 ;;
|
|
97 |
loongarch64*) arch=loongarch64 ;;
|
45 |
98 |
riscv64*) arch=riscv64;;
|
46 |
99 |
x86_64*) arch=x86_64 ;;
|
47 |
100 |
*) die "Unknown CHOST" ;;
|
... | ... | |
68 |
121 |
unset CFLAGS CPPFLAGS LDFLAGS
|
69 |
122 |
fi
|
70 |
123 |
|
|
124 |
# work around musl: include first the compiler include dir, then the system one
|
|
125 |
# bug #933080, #938012
|
|
126 |
local CPPINCLUDEDIR
|
|
127 |
if tc-is-gcc; then
|
|
128 |
CPPINCLUDEDIR=$(LC_ALL=C ${CC} -print-search-dirs 2> /dev/null | grep ^install: | cut -f2 -d' ')/include
|
|
129 |
elif tc-is-clang; then
|
|
130 |
CPPINCLUDEDIR=$(LC_ALL=C ${CC} -print-resource-dir 2> /dev/null)/include
|
|
131 |
fi
|
|
132 |
append-cflags "-nostdinc -isystem ${CPPINCLUDEDIR} -isystem ${ESYSROOT}/usr/include"
|
|
133 |
|
71 |
134 |
if use amd64 || use x86; then
|
72 |
135 |
use abi_x86_32 && CHOST=i686 ABI=x86 efimake
|
73 |
136 |
use abi_x86_64 && CHOST=x86_64 ABI=amd64 efimake
|