From 65b80f2da39998e66ba3f3fb180e45fdf0b00d87 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 2 Nov 2016 01:41:13 -0400 Subject: [PATCH] m4/ax_lib_elfutils.m4: use m4_default() for optional args. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The current macro code does not work because, if you provide 4 arguments to the macro, then `true_action` is not defined (but it should be: it's the third argument). Use m4_default() here to expand to a default value if the argument does not exist. Also use [:] instead of [] (good practice, safer for shells). Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- configure.ac | 2 +- m4/ax_lib_elfutils.m4 | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index c6b29d79..e74faaa8 100644 --- a/configure.ac +++ b/configure.ac @@ -281,7 +281,7 @@ AS_IF([test "x$_enable_debug_info" = xyes], [ # Check if libelf and libdw are present 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.)]) - 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-debug-info.)]) + 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-debug-info.)]) AC_DEFINE([ENABLE_DEBUG_INFO], [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 index f4fcb0dd..5cefc748 100644 --- a/m4/ax_lib_elfutils.m4 +++ b/m4/ax_lib_elfutils.m4 @@ -30,19 +30,10 @@ AC_DEFUN([AX_LIB_ELFUTILS], [ m4_pushdef([major_version], [$1]) m4_pushdef([minor_version], [$2]) - - 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)]) - ]) + 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], -- 2.34.1