m4/ax_lib_elfutils.m4: add cache variable
[babeltrace.git] / m4 / ax_lib_elfutils.m4
... / ...
CommitLineData
1# ax_lib_elfutils.m4 -- Check elfutils version
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
24# `_ELFUTILS_PREREQ` macro defined in <elfutils/version.h>.
25#
26# The cache variable for this test is `bt_cv_lib_elfutils`.
27#
28# AX_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
29# ---------------------------------------------------------------------------
30AC_DEFUN([AX_LIB_ELFUTILS], [
31 m4_pushdef([major_version], [$1])
32 m4_pushdef([minor_version], [$2])
33
34 m4_if([$#], 3, [
35 m4_pushdef([true_action], [$3])
36 ], [
37 m4_pushdef([true_action], [])
38 ])
39
40 m4_if([$#], 4, [
41 m4_pushdef([false_action], [$4])
42 ], [
43 m4_pushdef([false_action], [
44 AC_MSG_ERROR(elfutils >= major_version.minor_version is required)])
45 ])
46
47 AC_CACHE_CHECK(
48 [for elfutils version >= major_version.minor_version],
49 [bt_cv_lib_elfutils], [
50 AC_RUN_IFELSE([AC_LANG_SOURCE([
51 #include <stdlib.h>
52 #include <elfutils/version.h>
53
54 int main(void) {
55 return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE;
56 }
57 ])], [bt_cv_lib_elfutils=yes], [bt_cv_lib_elfutils=no])
58 ]
59 )
60
61 AS_IF([test "x$bt_cv_lib_elfutils" = "xyes"], [true_action], [false_action])
62
63 m4_popdef([false_action])
64 m4_popdef([true_action])
65 m4_popdef([minor_version])
66 m4_popdef([major_version])
67])
This page took 0.023247 seconds and 4 git commands to generate.