compositor: Use libunwind if available for better backtraces

libunwind has a dwarf parser and automatically queries the dlinfo
for location of dlopened modules.  The resulting backtrace is much
better and includes stack frames in dynamically loaded modules.

krh: Originally submitted for Xorg, adapted for weston:

  http://lists.x.org/archives/xorg-devel/2013-February/035493.html

Note this require libunwind at least 1.1 to get the pkg-config files.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
diff --git a/configure.ac b/configure.ac
index 32fbb4b..e613aa0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -281,6 +281,13 @@
 fi
 AC_SUBST(GCC_CFLAGS)
 
+PKG_CHECK_MODULES(LIBUNWIND, libunwind,
+                  [have_libunwind=yes], [have_libunwind=no])
+if test "x$have_libunwind" = xyes; then
+       AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
+fi
+AM_CONDITIONAL(HAVE_LIBUNWIND, [test "x$have_libunwind" = xyes])
+
 if test "x$WESTON_NATIVE_BACKEND" = "x"; then
 	WESTON_NATIVE_BACKEND="drm-backend.so"
 fi