summaryrefslogtreecommitdiff
path: root/m4/fp_find_libdw.m4
blob: ce830c0fa8235b980077f4202ff25e7a96f88b43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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])
])