Skip to content

Commit e59a0bc

Browse files
committed
Use pkgconfig for gnu-efi paths
* In use since 3.0.18 fixes bad detection on RISC-V Signed-off-by: Callum Farmer <[email protected]>
1 parent de727cf commit e59a0bc

File tree

2 files changed

+13
-33
lines changed

2 files changed

+13
-33
lines changed

efi/meson.build

+12-32
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ endif
2323
efi_ldsdir = get_option('efi-ldsdir')
2424
efi_incdir = get_option('efi-includedir')
2525

26+
if efi_incdir == ''
27+
efi_incdir = join_paths(gnuefi.get_variable(pkgconfig: 'includedir'), 'efi')
28+
endif
29+
2630
gnu_efi_path_arch = ''
2731
foreach name : [gnu_efi_arch, EFI_MACHINE_TYPE_NAME]
2832
if (gnu_efi_path_arch == '' and name != '' and
@@ -37,12 +41,7 @@ endif
3741

3842
efi_libdir = get_option('efi-libdir')
3943
if efi_libdir == ''
40-
fs = import('fs')
41-
multi = run_command(cc.cmd_array(), '-print-multi-os-directory', check: true).stdout().strip()
42-
efi_libdir = join_paths('/usr/lib/', multi)
43-
if not fs.is_dir(join_paths(efi_libdir, 'gnuefi'))
44-
efi_libdir = '/usr/lib'
45-
endif
44+
efi_libdir = gnuefi.get_variable(pkgconfig: 'libdir')
4645
endif
4746

4847
# The name we need to look for on this arch and OS: elf_x86_64_fbsd_efi.lds
@@ -51,34 +50,15 @@ if host_cpu == 'x86_64' and host_machine.system() == 'freebsd'
5150
lds_os = '_fbsd'
5251
endif
5352

54-
arch_lds = 'efi.lds'
55-
arch_crt = 'crt0.o'
53+
5654
if efi_ldsdir == ''
57-
efi_ldsdir = join_paths(efi_libdir, 'gnuefi', gnu_efi_path_arch)
58-
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
59-
if cmd.returncode() != 0
60-
arch_lds = 'elf_@0@@1@_efi.lds'.format(gnu_efi_path_arch, lds_os)
61-
arch_crt = 'crt0-efi-@[email protected]'.format(gnu_efi_path_arch)
62-
efi_ldsdir = join_paths(efi_libdir, 'gnuefi')
63-
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
64-
endif
65-
if cmd.returncode() != 0
6655
efi_ldsdir = efi_libdir
67-
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
68-
if cmd.returncode() != 0
69-
error('Cannot find @0@'.format(arch_lds))
70-
endif
71-
endif
72-
else
73-
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
74-
if cmd.returncode() != 0
75-
arch_lds = 'elf_@0@@1@_efi.lds'.format(gnu_efi_path_arch, lds_os)
76-
arch_crt = 'crt0-efi-@[email protected]'.format(gnu_efi_path_arch)
77-
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
78-
endif
79-
if cmd.returncode() != 0
80-
error('Cannot find @0@'.format(arch_lds))
81-
endif
56+
endif
57+
arch_lds = 'elf_@0@@1@_efi.lds'.format(gnu_efi_path_arch, lds_os)
58+
arch_crt = 'crt0-efi-@[email protected]'.format(gnu_efi_path_arch)
59+
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
60+
if cmd.returncode() != 0
61+
error('Cannot find @0@'.format(arch_lds))
8262
endif
8363
efi_crtdir = efi_ldsdir
8464

meson_options.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
option('efi-libdir', type : 'string', description : 'path to the EFI lib directory')
22
option('efi-ldsdir', type : 'string', description : 'path to the EFI lds directory')
3-
option('efi-includedir', type : 'string', value : '/usr/include/efi', description : 'path to the EFI header directory')
3+
option('efi-includedir', type : 'string', value : '', description : 'path to the EFI header directory')
44
option('efi_sbat_fwupd_generation', type : 'integer', value : 1, description : 'SBAT fwupd generation')
55
option('efi_sbat_distro_id', type : 'string', value : '', description : 'SBAT distribution ID, e.g. fedora')
66
option('efi_sbat_distro_summary', type : 'string', value : '', description : 'SBAT distribution summary, e.g. Fedora')

0 commit comments

Comments
 (0)