From: Michael Jeanson Date: Wed, 16 Sep 2020 18:46:55 +0000 (-0400) Subject: Fix: elfutils detection fallback for sles12 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=1c482ed8da42029e59b4258c86739e5c046be600 Fix: elfutils detection fallback for sles12 Turns out SLES12 doesn't bother shipping .pc files for elfutils, add a fallback compile test that will work even in cross-compilation. Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau Change-Id: Ia31b9add4831a9c4a67a440e7b1777d5f12d94d9 --- diff --git a/configure.ac b/configure.ac index f424973d..8c7dec29 100644 --- a/configure.ac +++ b/configure.ac @@ -543,7 +543,14 @@ AE_IF_FEATURE_ENABLED([debug-info], [ dnl PKG_CHECK_MODULES defines ELFUTILS_LIBS ], [ - AC_MSG_ERROR([elfutils >= 0.154 is required to use the debug info feature. You can disable this feature using --disable-debug-info.]) + AC_MSG_WARN([pkg-config was unable to find a valid .pc for libelf/libdw. Set PKG_CONFIG_PATH to specify the pkg-config configuration file location.]) + + # Turns out SLES12 doesn't bother shipping .pc file for libelf + AC_MSG_WARN([Finding libelf without pkg-config.]) + AC_CHECK_LIB([elf], [elf_version], [], [AC_MSG_ERROR(Missing libelf (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)]) + AC_CHECK_LIB([dw], [dwarf_begin], [], [AC_MSG_ERROR(Missing libdw (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)]) + AE_LIB_ELFUTILS([0], [154], [], [AC_MSG_ERROR(elfutils >= 0.154 is required to use the debug info feature. You can disable this feature using --disable-debug-info.)]) + ELFUTILS_LIBS="-lelf -ldw" ]) ]) AC_SUBST([ELFUTILS_LIBS]) diff --git a/m4/ae_lib_elfutils.m4 b/m4/ae_lib_elfutils.m4 new file mode 100644 index 00000000..50300913 --- /dev/null +++ b/m4/ae_lib_elfutils.m4 @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: MIT +# +# Copyright (C) 2016 Jérémie Galarneau +# Copyright (C) 2020 Michael Jeanson +# +# ae_lib_elfutils.m4 -- Check elfutils version +# +# Check the currently installed version of elfutils by using the +# `_ELFUTILS_PREREQ` macro defined in . +# +# The cache variable for this test is `ae_cv_lib_elfutils`. +# +# AE_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# --------------------------------------------------------------------------- +AC_DEFUN([AE_LIB_ELFUTILS], [ +m4_pushdef([major_version], [$1]) +m4_pushdef([minor_version], [$2]) +m4_pushdef([true_action], m4_default([$3], [:])) +m4_pushdef([false_action], m4_default( + [$4], [AC_MSG_ERROR(elfutils >= major_version.minor_version is required)] +)) + +AC_CACHE_CHECK( + [for elfutils version >= major_version.minor_version], + [ae_cv_lib_elfutils], [ + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([ + #include + + #if (!_ELFUTILS_PREREQ(][]major_version[][, ][]minor_version[][)) + #error "elfutils minimum required version not met." + #endif + + void main(void) { + return; + } + ])], + [ae_cv_lib_elfutils=yes], + [ae_cv_lib_elfutils=no] + ) + AC_LANG_POP([C]) +]) + +AS_IF([test "x$ae_cv_lib_elfutils" = "xyes"], [true_action], [false_action]) + +m4_popdef([false_action]) +m4_popdef([true_action]) +m4_popdef([minor_version]) +m4_popdef([major_version]) +])