Commit | Line | Data |
---|---|---|
b04abc0d | 1 | # bt_lib_elfutils.m4 -- Check elfutils version |
d3298a55 JG |
2 | # |
3 | # Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
4 | # | |
5 | # Permission is hereby granted, free of charge, to any person | |
6 | # obtaining a copy of this software and associated documentation files | |
7 | # (the "Software"), to deal in the Software without restriction, | |
8 | # including without limitation the rights to use, copy, modify, merge, | |
9 | # publish, distribute, sublicense, and/or sell copies of the Software, | |
10 | # and to permit persons to whom the Software is furnished to do so, | |
11 | # subject to the following conditions: The above copyright notice and | |
12 | # this permission notice shall be included in all copies or substantial | |
13 | # portions of the Software. | |
14 | # | |
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
22 | # | |
23 | # Check the currently installed version of elfutils by using the | |
ffa3b3ba PP |
24 | # `_ELFUTILS_PREREQ` macro defined in <elfutils/version.h>. |
25 | # | |
26 | # The cache variable for this test is `bt_cv_lib_elfutils`. | |
d3298a55 | 27 | # |
b04abc0d | 28 | # BT_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) |
d3298a55 | 29 | # --------------------------------------------------------------------------- |
b04abc0d | 30 | AC_DEFUN([BT_LIB_ELFUTILS], [ |
d3298a55 JG |
31 | m4_pushdef([major_version], [$1]) |
32 | m4_pushdef([minor_version], [$2]) | |
23f88ce2 PP |
33 | m4_pushdef([true_action], m4_default([$3], [:])) |
34 | m4_pushdef([false_action], m4_default( | |
35 | [$4], [AC_MSG_ERROR(elfutils >= major_version.minor_version is required)] | |
36 | )) | |
d3298a55 | 37 | |
ffa3b3ba PP |
38 | AC_CACHE_CHECK( |
39 | [for elfutils version >= major_version.minor_version], | |
40 | [bt_cv_lib_elfutils], [ | |
41 | AC_RUN_IFELSE([AC_LANG_SOURCE([ | |
42 | #include <stdlib.h> | |
43 | #include <elfutils/version.h> | |
44 | ||
45 | int main(void) { | |
46 | return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE; | |
47 | } | |
48 | ])], [bt_cv_lib_elfutils=yes], [bt_cv_lib_elfutils=no]) | |
49 | ] | |
50 | ) | |
d3298a55 | 51 | |
ffa3b3ba | 52 | AS_IF([test "x$bt_cv_lib_elfutils" = "xyes"], [true_action], [false_action]) |
d3298a55 JG |
53 | |
54 | m4_popdef([false_action]) | |
55 | m4_popdef([true_action]) | |
56 | m4_popdef([minor_version]) | |
57 | m4_popdef([major_version]) | |
58 | ]) |