Commit | Line | Data |
---|---|---|
97e67ce6 JG |
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 | # AX_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) | |
27 | # --------------------------------------------------------------------------- | |
28 | AC_DEFUN([AX_LIB_ELFUTILS], [ | |
29 | m4_pushdef([major_version], [$1]) | |
30 | m4_pushdef([minor_version], [$2]) | |
31 | ||
32 | AC_MSG_CHECKING([for elfutils version >= major_version.minor_version]) | |
33 | m4_if([$#], 3, [ | |
34 | m4_pushdef([true_action], [$3]) | |
35 | ], [ | |
36 | m4_pushdef([true_action], []) | |
37 | ]) | |
38 | ||
39 | m4_if([$#], 4, [ | |
40 | m4_pushdef([false_action], [$4]) | |
41 | ], [ | |
42 | m4_pushdef([false_action], [ | |
43 | AC_MSG_ERROR(elfutils >= major_version.minor_version is required)]) | |
44 | ]) | |
45 | ||
46 | AC_RUN_IFELSE([ | |
47 | AC_LANG_SOURCE([ | |
48 | #include <stdlib.h> | |
49 | #include <elfutils/version.h> | |
50 | ||
51 | int main(void) { | |
52 | return _ELFUTILS_PREREQ(major_version, minor_version) ? EXIT_SUCCESS : EXIT_FAILURE; | |
53 | } | |
54 | ]) | |
55 | ], | |
56 | echo yes | |
57 | true_action, | |
58 | echo no | |
59 | false_action) | |
60 | ||
61 | m4_popdef([false_action]) | |
62 | m4_popdef([true_action]) | |
63 | m4_popdef([minor_version]) | |
64 | m4_popdef([major_version]) | |
65 | ]) |