0002-m4-ax_lib_elfutils.m4-add-cache-variable.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From 697ab0905c59561562dc52cd3b925781e07814f3 Mon Sep 17 00:00:00 2001
  2. From: Philippe Proulx <eeppeliteloop@gmail.com>
  3. Date: Wed, 2 Nov 2016 01:40:12 -0400
  4. Subject: [PATCH] m4/ax_lib_elfutils.m4: add cache variable
  5. This patch adds an autoconf cache variable to override the
  6. AC_RUN_IFELSE() test result when cross-compiling.
  7. Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
  8. [Philippe: grabbed from this pull request:
  9. https://github.com/efficios/babeltrace/pull/52
  10. ]
  11. ---
  12. m4/ax_lib_elfutils.m4 | 32 +++++++++++++++++---------------
  13. 1 file changed, 17 insertions(+), 15 deletions(-)
  14. diff --git a/m4/ax_lib_elfutils.m4 b/m4/ax_lib_elfutils.m4
  15. index fcfe06b..f4fcb0d 100644
  16. --- a/m4/ax_lib_elfutils.m4
  17. +++ b/m4/ax_lib_elfutils.m4
  18. @@ -21,7 +21,9 @@
  19. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. #
  21. # Check the currently installed version of elfutils by using the
  22. -# _ELFUTILS_PREREQ macro defined in elfutils/version.h.
  23. +# `_ELFUTILS_PREREQ` macro defined in <elfutils/version.h>.
  24. +#
  25. +# The cache variable for this test is `bt_cv_lib_elfutils`.
  26. #
  27. # AX_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
  28. # ---------------------------------------------------------------------------
  29. @@ -29,7 +31,6 @@ AC_DEFUN([AX_LIB_ELFUTILS], [
  30. m4_pushdef([major_version], [$1])
  31. m4_pushdef([minor_version], [$2])
  32. - AC_MSG_CHECKING([for elfutils version >= major_version.minor_version])
  33. m4_if([$#], 3, [
  34. m4_pushdef([true_action], [$3])
  35. ], [
  36. @@ -43,20 +44,21 @@ AC_DEFUN([AX_LIB_ELFUTILS], [
  37. AC_MSG_ERROR(elfutils >= major_version.minor_version is required)])
  38. ])
  39. - AC_RUN_IFELSE([
  40. - AC_LANG_SOURCE([
  41. - #include <stdlib.h>
  42. - #include <elfutils/version.h>
  43. + AC_CACHE_CHECK(
  44. + [for elfutils version >= major_version.minor_version],
  45. + [bt_cv_lib_elfutils], [
  46. + AC_RUN_IFELSE([AC_LANG_SOURCE([
  47. + #include <stdlib.h>
  48. + #include <elfutils/version.h>
  49. +
  50. + int main(void) {
  51. + return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE;
  52. + }
  53. + ])], [bt_cv_lib_elfutils=yes], [bt_cv_lib_elfutils=no])
  54. + ]
  55. + )
  56. - int main(void) {
  57. - return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE;
  58. - }
  59. - ])
  60. - ],
  61. - echo yes
  62. - true_action,
  63. - echo no
  64. - false_action)
  65. + AS_IF([test "x$bt_cv_lib_elfutils" = "xyes"], [true_action], [false_action])
  66. m4_popdef([false_action])
  67. m4_popdef([true_action])
  68. --
  69. 2.9.3