diff options
author | Ting-Wei Lan <lantw@src.gnome.org> | 2018-06-03 02:32:22 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw@src.gnome.org> | 2018-06-09 09:40:51 +0800 |
commit | a77790330b134c66157a24395fd60bac8299f17b (patch) | |
tree | 5964186ffa018d394e722cd281297642325cbeea | |
parent | c61f01f0ff9889c393304e8ffa7ee099ba5ed8f6 (diff) | |
download | glib-a77790330b134c66157a24395fd60bac8299f17b.tar.gz |
meson: libelf.pc is not always available
libelf, just like libc, is not a single project. It is an interface
which can be implemented independently by different operating systems.
Therefore, we cannot expect all systems to provide a .pc file, and we
should fallback to cc.find_library and cc.has_function like what we
already do in autotools build.
-rw-r--r-- | gio/meson.build | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gio/meson.build b/gio/meson.build index b8baaa639..119e58059 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -855,9 +855,26 @@ else endif # Dependencies used by executables below +have_libelf = false libelf = dependency('libelf', version : '>= 0.8.12', required : false) 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) + 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) + have_libelf = have_libelf and cc.has_function('elf_getshdrnum', dependencies : libelf) + have_libelf = have_libelf and cc.has_header('libelf.h') +endif + +if have_libelf glib_conf.set('HAVE_LIBELF', 1) +else + libelf = [] endif gconstructor_as_data_h = custom_target('gconstructor_as_data.h', |