| 1 | # SPDX-License-Identifier: MIT |
| 2 | # |
| 3 | # Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | # |
| 5 | # bt_lib_elfutils.m4 -- Check elfutils version |
| 6 | # |
| 7 | # Check the currently installed version of elfutils by using the |
| 8 | # `_ELFUTILS_PREREQ` macro defined in <elfutils/version.h>. |
| 9 | # |
| 10 | # The cache variable for this test is `bt_cv_lib_elfutils`. |
| 11 | # |
| 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)] |
| 20 | )) |
| 21 | |
| 22 | AC_CACHE_CHECK( |
| 23 | [for elfutils version >= major_version.minor_version], |
| 24 | [bt_cv_lib_elfutils], [ |
| 25 | AC_RUN_IFELSE([AC_LANG_SOURCE([ |
| 26 | #include <stdlib.h> |
| 27 | #include <elfutils/version.h> |
| 28 | |
| 29 | int main(void) { |
| 30 | return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE; |
| 31 | } |
| 32 | ])], [bt_cv_lib_elfutils=yes], [bt_cv_lib_elfutils=no]) |
| 33 | ] |
| 34 | ) |
| 35 | |
| 36 | AS_IF([test "x$bt_cv_lib_elfutils" = "xyes"], [true_action], [false_action]) |
| 37 | |
| 38 | m4_popdef([false_action]) |
| 39 | m4_popdef([true_action]) |
| 40 | m4_popdef([minor_version]) |
| 41 | m4_popdef([major_version]) |
| 42 | ]) |