configure: introduce new macro AX_LIB_ELFUTILS
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 28 Apr 2016 22:07:48 +0000 (18:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 May 2016 19:42:42 +0000 (15:42 -0400)
elfutils has only just started providing pkg-config metadata
which makes the current version check unreliable. This introduces
a new M4 macro which checks elfutils' version using the
_ELFUTILS_PREREQ macro (defined in elfutils/version.h).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
m4/ax_lib_elfutils.m4 [new file with mode: 0644]

index eec5f35420dbe08059d2e5bb18d03c9b788c17cf..b161828ab55f16c42a1ce3109e0c227da7587e9e 100644 (file)
@@ -245,8 +245,10 @@ AS_IF([test "x$DEFAULT_ENABLE_DEBUGINFO" = xyes],
 
 AM_CONDITIONAL([ENABLE_DEBUGINFO], [test "x$enable_debuginfo" = xyes])
 AS_IF([test "x$enable_debuginfo" = xyes], [
-            PKG_CHECK_MODULES(LIBDW, [libdw >= 0.154], [], [AC_MSG_ERROR(Missing libdw (from elfutils >= 0.154) which is required by debug-info. You can disable this feature using --disable-debuginfo.)])
-            PKG_CHECK_MODULES(LIBELF, [libelf >= 0.154], [], [AC_MSG_ERROR(Missing libelf (from elfutils >= 0.154) which is required by debug-info. You can disable this feature using --disable-debuginfo.)])
+           # Check if libelf and libdw are present
+           AC_CHECK_LIB([elf], [elf_version], [], [AC_MSG_ERROR(Missing libdw (from elfutils >= 0.154) which is required by debug-info. You can disable this feature using --disable-debuginfo.)])
+           AC_CHECK_LIB([dw], [dwarf_begin], [], [AC_MSG_ERROR(Missing libelf (from elfutils >= 0.154) which is required by debug-info. You can disable this feature using --disable-debuginfo.)])
+           AX_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-debuginfo.)])
             AC_DEFINE([ENABLE_DEBUGINFO], [1], [Define to 1 if you enable the 'debug-info' feature])
 ], [])
 
diff --git a/m4/ax_lib_elfutils.m4 b/m4/ax_lib_elfutils.m4
new file mode 100644 (file)
index 0000000..fcfe06b
--- /dev/null
@@ -0,0 +1,65 @@
+# ax_lib_elfutils.m4 -- Check elfutils version
+#
+# Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions: The above copyright notice and
+# this permission notice shall be included in all copies or substantial
+# portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Check the currently installed version of elfutils by using the
+# _ELFUTILS_PREREQ macro defined in elfutils/version.h.
+#
+# AX_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# ---------------------------------------------------------------------------
+AC_DEFUN([AX_LIB_ELFUTILS], [
+       m4_pushdef([major_version], [$1])
+       m4_pushdef([minor_version], [$2])
+
+       AC_MSG_CHECKING([for elfutils version >= major_version.minor_version])
+       m4_if([$#], 3, [
+               m4_pushdef([true_action], [$3])
+       ], [
+               m4_pushdef([true_action], [])
+       ])
+
+       m4_if([$#], 4, [
+               m4_pushdef([false_action], [$4])
+       ], [
+               m4_pushdef([false_action], [
+                       AC_MSG_ERROR(elfutils >= major_version.minor_version is required)])
+       ])
+
+       AC_RUN_IFELSE([
+               AC_LANG_SOURCE([
+                       #include <stdlib.h>
+                       #include <elfutils/version.h>
+
+                       int main(void) {
+                               return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE;
+                       }
+               ])
+       ],
+               echo yes
+               true_action,
+               echo no
+               false_action)
+
+       m4_popdef([false_action])
+       m4_popdef([true_action])
+       m4_popdef([minor_version])
+       m4_popdef([major_version])
+])
This page took 0.035045 seconds and 4 git commands to generate.