summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-04-02 12:03:43 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-05 05:42:38 -0400
commit958c6fbdc7ba76313f6f6d110f5a0ee2474d26b6 (patch)
tree28042a1582176404d9fba26d54d27f7ec80c74de /m4
parent0de2012cc05b12a810d27f5c9009c870cf6fabfd (diff)
downloadhaskell-958c6fbdc7ba76313f6f6d110f5a0ee2474d26b6.tar.gz
configure: Move libdw search logic to macro
Diffstat (limited to 'm4')
-rw-r--r--m4/fp_find_libdw.m457
1 files changed, 57 insertions, 0 deletions
diff --git a/m4/fp_find_libdw.m4 b/m4/fp_find_libdw.m4
new file mode 100644
index 0000000000..ce830c0fa8
--- /dev/null
+++ b/m4/fp_find_libdw.m4
@@ -0,0 +1,57 @@
+dnl ** Have libdw?
+dnl --------------------------------------------------------------
+dnl Sets UseLibdw.
+AC_DEFUN([FP_FIND_LIBDW],
+[
+ AC_ARG_WITH([libdw-libraries],
+ [AS_HELP_STRING([--with-libdw-libraries=ARG],
+ [Find libraries for libdw in ARG [default=system default]])
+ ],
+ [
+ LibdwLibDir="$withval"
+ LIBDW_LDFLAGS="-L$withval"
+ ])
+
+ AC_SUBST(LibdwLibDir)
+
+ AC_ARG_WITH([libdw-includes],
+ [AS_HELP_STRING([--with-libdw-includes=ARG],
+ [Find includes for libdw in ARG [default=system default]])
+ ],
+ [
+ LibdwIncludeDir="$withval"
+ LIBDW_CFLAGS="-I$withval"
+ ])
+
+ AC_SUBST(LibdwIncludeDir)
+
+ UseLibdw=NO
+ USE_LIBDW=0
+ AC_ARG_ENABLE(dwarf-unwind,
+ [AS_HELP_STRING([--enable-dwarf-unwind],
+ [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])])
+ if test "$enable_dwarf_unwind" = "yes" ; then
+ CFLAGS2="$CFLAGS"
+ CFLAGS="$LIBDW_CFLAGS $CFLAGS"
+ LDFLAGS2="$LDFLAGS"
+ LDFLAGS="$LIBDW_LDFLAGS $LDFLAGS"
+
+ AC_CHECK_LIB(dw, dwfl_attach_state,
+ [AC_CHECK_HEADERS([elfutils/libdw.h], [break], [])
+ UseLibdw=YES],
+ [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])])
+
+ CFLAGS="$CFLAGS2"
+ LDFLAGS="$LDFLAGS2"
+ fi
+
+ AC_SUBST(UseLibdw)
+ if test $UseLibdw = "YES" ; then
+ USE_LIBDW=1
+ AC_SUBST([CabalHaveLibdw],[True])
+ else
+ AC_SUBST([CabalHaveLibdw],[False])
+ fi
+ AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw])
+])
+