summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4')
-rw-r--r--m4/efl_libunwind.m461
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 @@
1dnl This code is public domain and can be freely used or copied.
2dnl File to auto-detect libunwind
3
4dnl Macro that checks for libunwind, first by using
5dnl pkg-config, then by trying to compile and link a simple
6dnl program, to see if libunwind is distributed on the system
7dnl but has no pkg-config support
8dnl
9dnl The biggest usecase is on Mac OS X, where there are no
10dnl pkg-config files, and the libunwind headers are lost
11dnl in an obscure place on the system (but whom the compilers
12dnl distributed by Apple are aware of).
13dnl
14dnl Usage: EFL_CHECK_LIBUNWIND
15dnl will inconditionaly set UNWIND_CFLAGS and UNWIND_LIBS
16dnl to follow pkg-config fashion.
17dnl
18AC_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])