Make libelf dependency optional via meson feature

This commit is contained in:
Niklas Gürtler 2020-10-01 13:47:36 +00:00 committed by Philip Withnall
parent 9bc61def1f
commit aa0e120174
2 changed files with 7 additions and 2 deletions

View File

@ -874,14 +874,14 @@ endif
# Dependencies used by executables below # Dependencies used by executables below
have_libelf = false have_libelf = false
libelf = dependency('libelf', version : '>= 0.8.12', required : false) libelf = dependency('libelf', version : '>= 0.8.12', required : get_option ('libelf'))
if libelf.found() if libelf.found()
have_libelf = true have_libelf = true
else else
# This fallback is necessary on *BSD. elfutils isn't the only libelf # This fallback is necessary on *BSD. elfutils isn't the only libelf
# implementation, and *BSD usually includes their own libelf as a system # implementation, and *BSD usually includes their own libelf as a system
# library which doesn't have a corresponding .pc file. # library which doesn't have a corresponding .pc file.
libelf = cc.find_library('elf', required : false) libelf = cc.find_library('elf', required : get_option ('libelf'))
have_libelf = libelf.found() have_libelf = libelf.found()
have_libelf = have_libelf and cc.has_function('elf_begin', dependencies : libelf) have_libelf = have_libelf and cc.has_function('elf_begin', dependencies : libelf)
have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf) have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf)

View File

@ -111,3 +111,8 @@ option('glib_checks',
value : true, value : true,
yield : true, yield : true,
description : 'Enable GLib checks such as API guards (see docs/macros.txt)') description : 'Enable GLib checks such as API guards (see docs/macros.txt)')
option('libelf',
type : 'feature',
value : 'auto',
description : 'Enable support for listing and extracting from ELF resource files with gresource tool')