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 <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
# 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.)])
# 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])
], [])
AC_DEFINE([ENABLE_DEBUG_INFO], [1], [Define to 1 if you enable the 'debug info' feature])
], [])
AC_DEFUN([AX_LIB_ELFUTILS], [
m4_pushdef([major_version], [$1])
m4_pushdef([minor_version], [$2])
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],
AC_CACHE_CHECK(
[for elfutils version >= major_version.minor_version],