diff options
author | Jean Guyomarc'h <jean@guyomarch.bzh> | 2016-05-28 13:07:22 +0200 |
---|---|---|
committer | Jean Guyomarc'h <jean@guyomarch.bzh> | 2016-05-28 19:13:10 +0200 |
commit | 0193600e486759f4b0524b520e9128c2a3d19cbd (patch) | |
tree | fc505136086f514323db80a15e735f3c2ce51e7c /m4/efl_libunwind.m4 | |
parent | 01c7fd7cda1f89c8c0257c97f9822e40c4fb2df8 (diff) |
autotools: improve libunwind detection
Libuwind may not be shipped with a pkg-config file.
It can be distributed on the system, but the autotools
would fail to detect it because it relied only on pkg-config.
We now first check with pkg-config, and then try to compile and
link a program using libuwind to see if it is supported anyway.
This is a first step towards a working eina_log_backtrace on
Mac OS X.
Diffstat (limited to '')
-rw-r--r-- | m4/efl_libunwind.m4 | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/m4/efl_libunwind.m4 b/m4/efl_libunwind.m4 new file mode 100644 index 0000000000..e9ca682cfb --- /dev/null +++ b/m4/efl_libunwind.m4 | |||
@@ -0,0 +1,61 @@ | |||
1 | dnl This code is public domain and can be freely used or copied. | ||
2 | dnl File to auto-detect libunwind | ||
3 | |||
4 | dnl Macro that checks for libunwind, first by using | ||
5 | dnl pkg-config, then by trying to compile and link a simple | ||
6 | dnl program, to see if libunwind is distributed on the system | ||
7 | dnl but has no pkg-config support | ||
8 | dnl | ||
9 | dnl The biggest usecase is on Mac OS X, where there are no | ||
10 | dnl pkg-config files, and the libunwind headers are lost | ||
11 | dnl in an obscure place on the system (but whom the compilers | ||
12 | dnl distributed by Apple are aware of). | ||
13 | dnl | ||
14 | dnl Usage: EFL_CHECK_LIBUNWIND | ||
15 | dnl will inconditionaly set UNWIND_CFLAGS and UNWIND_LIBS | ||
16 | dnl to follow pkg-config fashion. | ||
17 | dnl | ||
18 | AC_DEFUN([EFL_CHECK_LIBUNWIND], | ||
19 | [dnl | ||
20 | dnl First, check with pkg-config | ||
21 | PKG_CHECK_MODULES([UNWIND], [libunwind libunwind-generic], | ||
22 | [have_unwind=yes], [have_unwind=no]) | ||
23 | |||
24 | dnl No pkg-config file... maybe system built-in? | ||
25 | if test "x${have_unwind}" = "xno"; then | ||
26 | AC_LANG_PUSH([C]) | ||
27 | AC_LINK_IFELSE( | ||
28 | [AC_LANG_PROGRAM( | ||
29 | [[ | ||
30 | #include <libunwind.h> | ||
31 | ]], | ||
32 | [[ | ||
33 | unw_context_t ctx; | ||
34 | unw_getcontext(&ctx); | ||
35 | ]] | ||
36 | )], | ||
37 | [ | ||
38 | have_unwind="yes" | ||
39 | ], | ||
40 | [ | ||
41 | have_unwind="no" | ||
42 | ] | ||
43 | ) | ||
44 | AC_MSG_CHECKING([for native libunwind]) | ||
45 | AC_MSG_RESULT([${have_unwind}]) | ||
46 | AC_LANG_POP([C]) | ||
47 | |||
48 | dnl Provide dummy variables to automake. | ||
49 | dnl In case pkg-config succeeded, these will be set and | ||
50 | dnl used in other automake files. To avoid, problems, | ||
51 | dnl we define empty variables. | ||
52 | UNWIND_CFLAGS="" | ||
53 | UNWIND_LIBS="" | ||
54 | AC_SUBST([UNWIND_CFLAGS]) | ||
55 | AC_SUBST([UNWIND_LIBS]) | ||
56 | fi | ||
57 | |||
58 | AS_IF([test "x$have_unwind" = "xyes"], | ||
59 | [AC_DEFINE([HAVE_UNWIND], [1], [Have libunwind])]) | ||
60 | AM_CONDITIONAL(HAVE_UNWIND, test "x$have_unwind" = "xyes") | ||
61 | ]) | ||