PowerPC: convert ELFv2 conditionals form preprocessor to plain conditions
[platform/upstream/ltrace.git] / configure.ac
index da3b4cb..6fe5e3b 100644 (file)
@@ -1,6 +1,6 @@
 # -*- Autoconf -*-
 # This file is part of ltrace.
-# Copyright (C) 2010,2012,2013 Petr Machata, Red Hat Inc.
+# Copyright (C) 2010,2012,2013,2014 Petr Machata, Red Hat Inc.
 # Copyright (C) 2010,2011 Joe Damato
 # Copyright (C) 2010 Marc Kleine-Budde
 # Copyright (C) 2010 Zachary T Welch
@@ -43,7 +43,7 @@ case "${host_cpu}" in
     arm*|sa110)                HOST_CPU="arm" ;;
     cris*)             HOST_CPU="cris" ;;
     mips*)             HOST_CPU="mips" ;;
-    powerpc|powerpc64) HOST_CPU="ppc" ;;
+    powerpc|powerpc64|powerpc64le)     HOST_CPU="ppc" ;;
     sun4u|sparc64)     HOST_CPU="sparc" ;;
     s390x)             HOST_CPU="s390" ;;
     i?86|x86_64)       HOST_CPU="x86" ;;
@@ -128,6 +128,51 @@ dnl Check security_get_boolean_active availability.
 AC_CHECK_HEADERS(selinux/selinux.h)
 AC_CHECK_LIB(selinux, security_get_boolean_active)
 
+dnl Whether (and which) elfutils libdw.so to use for unwinding.
+AC_ARG_WITH(elfutils,
+  AS_HELP_STRING([--with-elfutils], [Use elfutils libdwfl unwinding support]),
+  [case "${withval}" in
+  (yes|no) enable_elfutils=$withval;;
+  (*) enable_elfutils=yes
+    AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
+    AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
+    elfutils_LD_LIBRARY_PATH="${withval}/lib:${withval}/lib/elfutils"
+    ;;
+esac],[enable_elfutils=maybe])
+
+dnl Check whether we have the elfutils libdwfl.h header installed.
+saved_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
+AC_CHECK_HEADERS([elfutils/libdwfl.h],[have_libdwfl_h=yes])
+CPPFLAGS="${saved_CPPFLAGS}"
+
+dnl And whether libdw.so provides the unwinding functions.
+saved_LDFLAGS="${LDFLAGS}"
+LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
+AC_CHECK_LIB([dw], [dwfl_getthread_frames], [have_libdw_dwfl_frames=yes])
+LDFLAGS="${saved_LDFLAGS}"
+
+AC_MSG_CHECKING([whether to use elfutils libdwfl unwinding support])
+case "${enable_elfutils}" in
+(yes|maybe)
+  if test x$have_libdwfl_h = xyes -a x$have_libdw_dwfl_frames = xyes; then
+    enable_elfutils=yes
+  elif test $enable_elfutils = maybe; then
+    enable_elfutils=no
+  else
+    AC_MSG_RESULT([$enable_elfutils])
+    AC_MSG_ERROR([Missing elfutils/libdwfl.h or dwfl_getthread_frames not in libdw.so])
+  fi
+  ;;
+(*) ;;
+esac
+AC_MSG_RESULT([$enable_elfutils])
+
+if test x"$enable_elfutils" = xyes; then
+  libdw_LIBS=-ldw
+  AC_SUBST(libdw_LIBS)
+  AC_DEFINE([HAVE_LIBDW], [1], [we have elfutils libdw])
+fi
 
 # HAVE_LIBUNWIND
 AC_ARG_WITH(libunwind,
@@ -165,12 +210,12 @@ AC_MSG_RESULT([$enable_libunwind])
 
 if test x"$enable_libunwind" = xyes; then
   case "${host_cpu}" in
-      arm*|sa110)         UNWIND_ARCH="arm" ;;
-      i?86)               UNWIND_ARCH="x86" ;;
-      powerpc)            UNWIND_ARCH="ppc32" ;;
-      powerpc64)          UNWIND_ARCH="ppc64" ;;
-      mips*)              UNWIND_ARCH="mips" ;;
-      *)                  UNWIND_ARCH="${host_cpu}" ;;
+      arm*|sa110)        UNWIND_ARCH="arm" ;;
+      i?86)              UNWIND_ARCH="x86" ;;
+      powerpc)           UNWIND_ARCH="ppc32" ;;
+      powerpc64|powerpc64le)   UNWIND_ARCH="ppc64" ;;
+      mips*)             UNWIND_ARCH="mips" ;;
+      *)                 UNWIND_ARCH="${host_cpu}" ;;
   esac
 
   saved_LDFLAGS="${LDFLAGS}"
@@ -193,6 +238,13 @@ if test x"$enable_libunwind" = xyes; then
   LDFLAGS="${saved_LDFLAGS}"
 fi
 
+if test x"$enable_elfutils" = xyes -a x"$enable_libunwind" = xyes; then
+  AC_MSG_ERROR([Cannot enable both --with-libunwind and --with-elfutils])
+fi
+
+if test x"$enable_elfutils" = xyes -o x"$enable_libunwind" = xyes; then
+  AC_DEFINE([HAVE_UNWINDER], [1], [we have an unwinder available])
+fi
 
 saved_CPPFLAGS="${CPPFLAGS}"
 saved_LDFLAGS="${LDFLAGS}"
@@ -335,17 +387,20 @@ if test x$use_valgrind = xyes; then
     fi
 fi
 AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes)
+AM_CONDITIONAL(HAVE_LIBDW, test x"$enable_elfutils" = xyes)
 
 AC_SUBST(AM_CPPFLAGS)
 AC_SUBST(AM_CFLAGS)
 AC_SUBST(AM_LDFLAGS)
 AC_SUBST(libelf_LD_LIBRARY_PATH)
+AC_SUBST(elfutils_LD_LIBRARY_PATH)
 AC_SUBST(libunwind_LD_LIBRARY_PATH)
 
 AC_CONFIG_FILES([
        Makefile
        sysdeps/Makefile
        sysdeps/linux-gnu/Makefile
+       sysdeps/linux-gnu/aarch64/Makefile
        sysdeps/linux-gnu/alpha/Makefile
        sysdeps/linux-gnu/arm/Makefile
        sysdeps/linux-gnu/cris/Makefile