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
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()
have_libelf = true
else
# This fallback is necessary on *BSD. elfutils isn't the only libelf
# implementation, and *BSD usually includes their own libelf as a system
# 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 = have_libelf and cc.has_function('elf_begin', dependencies : libelf)
have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf)