From 3b4c1dd4d395c5371c4f11161f5c3f964d478417 Mon Sep 17 00:00:00 2001 From: John Zimmermann Date: Fri, 18 May 2018 00:41:11 +0200 Subject: [PATCH] build: check for existence of execinfo.h GLIBC is not necessarily the only library that provides execinfo. With libexecinfo execinfo can be used also in other Libraries. The patch lets the configure check the existence of the header and the libexecinfo Library and uses them if avaible. (also fixes compilation if execinfo is not avaible) --- configure.ac | 3 +++ plugins/ofono.c | 2 ++ src/backtrace.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f78f376e..9e9286a5 100644 --- a/configure.ac +++ b/configure.ac @@ -86,6 +86,9 @@ AC_DEFINE_UNQUOTED(CONFIGDIR, "/etc/iwd", [Configuration directory]) AC_CHECK_HEADERS(linux/types.h linux/if_alg.h) +AC_CHECK_HEADERS_ONCE(execinfo.h) +AC_CHECK_LIB(execinfo, backtrace) + if (test "${enable_client}" != "no"); then AC_CHECK_HEADERS(readline/readline.h, enable_readline=yes, AC_MSG_ERROR(readline header files are required)) diff --git a/plugins/ofono.c b/plugins/ofono.c index 58a60d3f..5d108de5 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -653,7 +653,9 @@ static void parse_modem(const char *path, struct l_dbus_message_iter *props) * has been seen to happen. */ l_error("modem %s already found", path); +#ifdef HAVE_EXECINFO_H __iwd_backtrace_print(2); +#endif exit(1); } diff --git a/src/backtrace.c b/src/backtrace.c index 759a8431..f7732a63 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -27,7 +27,7 @@ #define _GNU_SOURCE #include -#ifdef __GLIBC__ +#ifdef HAVE_EXECINFO_H #include #include #include