File: debug.m4

package info (click to toggle)
flamp 2.2.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,204 kB
  • sloc: cpp: 35,035; ansic: 5,806; sh: 4,264; makefile: 243
file content (113 lines) | stat: -rw-r--r-- 3,933 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
AC_DEFUN([AC_FL_RDYNAMIC], [
  LDFLAGS_saved="$LDFLAGS"
  LDFLAGS="$LDFLAGS -rdynamic"

  AC_MSG_CHECKING([whether $CC supports -rdynamic])
  # don't try this on win32; it succeeds but emits a warning at link time
  if test "x$target_win32" != "xyes"; then
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_rdynamic=yes],[ac_cv_rdynamic=no])
  else
      ac_cv_rdynamic=no
  fi
  AC_MSG_RESULT([$ac_cv_rdynamic])

  AC_LANG_PUSH(C++)
    AC_MSG_CHECKING([whether $CXX supports -rdynamic])
    if test "x$target_win32" != "xyes"; then
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_rdynamic=yes],[ac_cv_rdynamic=no])
    else
        ac_cv_rdynamic=no
    fi
  AC_LANG_POP(C++)
  AC_MSG_RESULT([$ac_cv_rdynamic])

  LDFLAGS="$LDFLAGS_saved"
])


AC_DEFUN([AC_FL_DEBUG], [
  AC_REQUIRE([AC_FL_OPT])
  AC_ARG_ENABLE([debug],
                AS_HELP_STRING([--enable-debug], [turn on debugging]),
                [case "${enableval}" in
                  yes|no) ac_cv_debug="${enableval}" ;;
                  *)      AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
                 esac],
                 [ac_cv_debug=no])

  AC_ARG_VAR([BFD_CFLAGS], [C compiler flags for libbfd])
  AC_ARG_VAR([BFD_LIBS], [linker flags for libbfd])
  AC_ARG_WITH([bfd],
              AS_HELP_STRING([--with-bfd@<:@=DIR@:>@],
                             [search for libbfd in DIR/include and DIR/lib @<:@mingw32 only@:>@]),
              [ac_cv_want_bfd="$withval"],
              [ac_cv_want_bfd=yes])

  if test "x$ac_cv_debug" = "xyes" && test "x$ac_cv_want_bfd" != "xno" && \
     test "x$target_mingw32" = "xyes"; then
      if test "x$ac_cv_want_bfd" != "xyes"; then # set -I and -L switches
          bfd_default_cflags="-I${ac_cv_want_bfd}/include"
          bfd_default_libs="-L${ac_cv_want_bfd}/lib"
      fi
      # don't override the user-specified vars
      BFD_CFLAGS="${BFD_CFLAGS:-$bfd_default_cflags}"
      BFD_LIBS="${BFD_LIBS:-$bfd_default_libs}"
      ac_cv_want_bfd="yes"

      CPPFLAGS_saved="$CPPFLAGS"
      LDFLAGS_saved="$LDFLAGS"
      CPPFLAGS="$CPPFLAGS $BFD_CFLAGS"
      LDFLAGS="$LDFLAGS $BFD_LIBS"

      AC_CHECK_HEADER([bfd.h], [ac_cv_have_bfd="yes"], [ac_cv_have_bfd="no"])
      if test "x$ac_cv_have_bfd" = "xyes"; then
          bfd_other_libs="-liberty -lpsapi -limagehlp"
          AC_CHECK_LIB([bfd], [bfd_set_format], [ac_cv_have_bfd="yes"], [ac_cv_have_bfd="no"], [$bfd_other_libs])
      fi
      CPPFLAGS="$CPPFLAGS_saved"
      LDFLAGS="$LDFLAGS_saved"
      if test "x$ac_cv_have_bfd" = "xyes"; then
          BFD_LIBS="$BFD_LIBS -lbfd $bfd_other_libs"
      fi
  fi

  if test "x$ac_cv_debug" = "xyes"; then
      AC_MSG_CHECKING([for debug info flag])
      if test "x$GXX" = "xyes"; then
          if test "x$target_mingw32" = "xyes"; then
              gflag="-gstabs"
          else
              gflag="-ggdb3"
          fi
      else
          gflag="-g"
      fi
      AC_MSG_RESULT([$gflag])
      DEBUG_CFLAGS="-O0 -fno-inline-functions -fno-omit-frame-pointer $gflag -Wall"

      AC_FL_RDYNAMIC
      if test "x$ac_cv_rdynamic" = "xyes"; then
          RDYNAMIC=-rdynamic
      fi

      CXXFLAGS=""
      CFLAGS="$CXXFLAGS"
      AC_MSG_NOTICE([debugging enabled; overriding CXXFLAGS])

      if test "x$target_darwin" = "xyes"; then
          ac_cv_compat_stack=yes
	  AC_DEFINE([HAVE_DBG_STACK], 1, [Define to 1 if we have dbg::stack])
      elif test "x$target_mingw32" = "xyes" && test "x$ac_cv_have_bfd" = "xyes"; then
          ac_cv_compat_stack=yes
	  AC_DEFINE([HAVE_DBG_STACK], 1, [Define to 1 if we have dbg::stack])
      else
          ac_cv_compat_stack=no
	  AC_DEFINE([HAVE_DBG_STACK], 0, [Define to 0 if not using dbg::stack])
      fi
  fi
  AM_CONDITIONAL([ENABLE_DEBUG], [test "x$ac_cv_debug" = "xyes"])
  AC_SUBST([DEBUG_CFLAGS])
  AC_SUBST([RDYNAMIC])

  AM_CONDITIONAL([COMPAT_STACK], [test "x$ac_cv_compat_stack" = "xyes"])
])