Commit | Line | Data |
---|---|---|
1c482ed8 MJ |
1 | # SPDX-License-Identifier: MIT |
2 | # | |
3 | # Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
4 | # Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com> | |
5 | # | |
6 | # ae_lib_elfutils.m4 -- Check elfutils version | |
7 | # | |
8 | # Check the currently installed version of elfutils by using the | |
9 | # `_ELFUTILS_PREREQ` macro defined in <elfutils/version.h>. | |
10 | # | |
11 | # The cache variable for this test is `ae_cv_lib_elfutils`. | |
12 | # | |
13 | # AE_LIB_ELFUTILS(MAJOR_VERSION, MINOR_VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) | |
14 | # --------------------------------------------------------------------------- | |
15 | AC_DEFUN([AE_LIB_ELFUTILS], [ | |
16 | m4_pushdef([major_version], [$1]) | |
17 | m4_pushdef([minor_version], [$2]) | |
18 | m4_pushdef([true_action], m4_default([$3], [:])) | |
19 | m4_pushdef([false_action], m4_default( | |
20 | [$4], [AC_MSG_ERROR(elfutils >= major_version.minor_version is required)] | |
21 | )) | |
22 | ||
23 | AC_CACHE_CHECK( | |
24 | [for elfutils version >= major_version.minor_version], | |
25 | [ae_cv_lib_elfutils], [ | |
26 | AC_LANG_PUSH([C]) | |
27 | AC_COMPILE_IFELSE( | |
28 | [AC_LANG_SOURCE([ | |
29 | #include <elfutils/version.h> | |
30 | ||
31 | #if (!_ELFUTILS_PREREQ(][]major_version[][, ][]minor_version[][)) | |
32 | #error "elfutils minimum required version not met." | |
33 | #endif | |
34 | ||
35 | void main(void) { | |
36 | return; | |
37 | } | |
38 | ])], | |
39 | [ae_cv_lib_elfutils=yes], | |
40 | [ae_cv_lib_elfutils=no] | |
41 | ) | |
42 | AC_LANG_POP([C]) | |
43 | ]) | |
44 | ||
45 | AS_IF([test "x$ae_cv_lib_elfutils" = "xyes"], [true_action], [false_action]) | |
46 | ||
47 | m4_popdef([false_action]) | |
48 | m4_popdef([true_action]) | |
49 | m4_popdef([minor_version]) | |
50 | m4_popdef([major_version]) | |
51 | ]) |