1 # SPDX-License-Identifier: MIT
3 # Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 # bt_lib_elfutils.m4 -- Check elfutils version
7 # Check the currently installed version of elfutils by using the
8 # `_ELFUTILS_PREREQ` macro defined in <elfutils/version.h>.
10 # The cache variable for this test is `bt_cv_lib_elfutils`.
12 # BT_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
13 # ---------------------------------------------------------------------------
14 AC_DEFUN([BT_LIB_ELFUTILS], [
15 m4_pushdef([major_version], [$1])
16 m4_pushdef([minor_version], [$2])
17 m4_pushdef([true_action], m4_default([$3], [:]))
18 m4_pushdef([false_action], m4_default(
19 [$4], [AC_MSG_ERROR(elfutils >= major_version.minor_version is required)]
23 [for elfutils version >= major_version.minor_version],
24 [bt_cv_lib_elfutils], [
25 AC_RUN_IFELSE([AC_LANG_SOURCE([
27 #include <elfutils/version.h>
30 return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE;
32 ])], [bt_cv_lib_elfutils=yes], [bt_cv_lib_elfutils=no])
36 AS_IF([test "x$bt_cv_lib_elfutils" = "xyes"], [true_action], [false_action])
38 m4_popdef([false_action])
39 m4_popdef([true_action])
40 m4_popdef([minor_version])
41 m4_popdef([major_version])