Skip to content

Commit

Permalink
Use pkgconfig for gnu-efi paths
Browse files Browse the repository at this point in the history
* In use since 3.0.18 fixes bad detection on RISC-V

Signed-off-by: Callum Farmer <[email protected]>
  • Loading branch information
gmbr3 committed Nov 23, 2024
1 parent 6dcf4f9 commit 1535c1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
44 changes: 12 additions & 32 deletions efi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ endif
efi_ldsdir = get_option('efi-ldsdir')
efi_incdir = get_option('efi-includedir')

if efi_incdir == ''
efi_incdir = join_paths(gnuefi.get_variable(pkgconfig: 'includedir'), 'efi')
endif

gnu_efi_path_arch = ''
foreach name : [gnu_efi_arch, EFI_MACHINE_TYPE_NAME]
if (gnu_efi_path_arch == '' and name != '' and
Expand All @@ -37,12 +41,7 @@ endif

efi_libdir = get_option('efi-libdir')
if efi_libdir == ''
fs = import('fs')
multi = run_command(cc.cmd_array(), '-print-multi-os-directory', check: true).stdout().strip()
efi_libdir = join_paths('/usr/lib/', multi)
if not fs.is_dir(join_paths(efi_libdir, 'gnuefi'))
efi_libdir = '/usr/lib'
endif
efi_libdir = gnuefi.get_variable(pkgconfig: 'libdir')
endif

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

arch_lds = 'efi.lds'
arch_crt = 'crt0.o'

if efi_ldsdir == ''
efi_ldsdir = join_paths(efi_libdir, 'gnuefi', gnu_efi_path_arch)
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
if cmd.returncode() != 0
arch_lds = 'elf_@0@@1@_efi.lds'.format(gnu_efi_path_arch, lds_os)
arch_crt = 'crt0-efi-@[email protected]'.format(gnu_efi_path_arch)
efi_ldsdir = join_paths(efi_libdir, 'gnuefi')
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
endif
if cmd.returncode() != 0
efi_ldsdir = efi_libdir
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
if cmd.returncode() != 0
error('Cannot find @0@'.format(arch_lds))
endif
endif
else
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
if cmd.returncode() != 0
arch_lds = 'elf_@0@@1@_efi.lds'.format(gnu_efi_path_arch, lds_os)
arch_crt = 'crt0-efi-@[email protected]'.format(gnu_efi_path_arch)
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
endif
if cmd.returncode() != 0
error('Cannot find @0@'.format(arch_lds))
endif
endif
arch_lds = 'elf_@0@@1@_efi.lds'.format(gnu_efi_path_arch, lds_os)
arch_crt = 'crt0-efi-@[email protected]'.format(gnu_efi_path_arch)
cmd = run_command('test', '-f', join_paths(efi_ldsdir, arch_lds), check: false)
if cmd.returncode() != 0
error('Cannot find @0@'.format(arch_lds))
endif
efi_crtdir = efi_ldsdir

Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
option('efi-libdir', type : 'string', description : 'path to the EFI lib directory')
option('efi-ldsdir', type : 'string', description : 'path to the EFI lds directory')
option('efi-includedir', type : 'string', value : '/usr/include/efi', description : 'path to the EFI header directory')
option('efi-includedir', type : 'string', value : '', description : 'path to the EFI header directory')
option('efi_sbat_fwupd_generation', type : 'integer', value : 1, description : 'SBAT fwupd generation')
option('efi_sbat_distro_id', type : 'string', value : '', description : 'SBAT distribution ID, e.g. fedora')
option('efi_sbat_distro_summary', type : 'string', value : '', description : 'SBAT distribution summary, e.g. Fedora')
Expand Down

0 comments on commit 1535c1f

Please sign in to comment.