/config/ac_debug.m4

https://code.google.com/ · m4 · 53 lines · 30 code · 3 blank · 20 comment · 0 complexity · f79b2b7226156938eb64fd23f5aac1c2 MD5 · raw file

  1. ##*****************************************************************************
  2. ## $Id$
  3. ##*****************************************************************************
  4. # AUTHOR:
  5. # Chris Dunlap <cdunlap@llnl.gov>
  6. #
  7. # SYNOPSIS:
  8. # AC_DEBUG
  9. #
  10. # DESCRIPTION:
  11. # Adds support for the "--enable-debug" configure script option.
  12. # If CFLAGS are not passed to configure, they will be set based
  13. # on whether debugging has been enabled. Also, the NDEBUG macro
  14. # (used by assert) will be set accordingly.
  15. #
  16. # WARNINGS:
  17. # This macro must be placed after AC_PROG_CC or equivalent.
  18. ##*****************************************************************************
  19. AC_DEFUN([AC_DEBUG],
  20. [
  21. AC_MSG_CHECKING([whether debugging is enabled])
  22. AC_ARG_ENABLE([debug],
  23. AC_HELP_STRING([--enable-debug], [enable debugging code for development]),
  24. [ case "$enableval" in
  25. yes) ac_debug=yes ;;
  26. no) ac_debug=no ;;
  27. *) AC_MSG_RESULT([doh!])
  28. AC_MSG_ERROR([bad value "$enableval" for --enable-debug]) ;;
  29. esac
  30. ]
  31. )
  32. if test "$ac_debug" = yes; then
  33. if test -z "$ac_save_CFLAGS"; then
  34. test "$ac_cv_prog_cc_g" = yes && CFLAGS="-g"
  35. test "$GCC" = yes && CFLAGS="$CFLAGS -Wall"
  36. fi
  37. else
  38. if test -z "$ac_save_CFLAGS"; then
  39. test "$GCC" = yes && CFLAGS="-O3 -Wall -fno-strict-aliasing" || CFLAGS="-O3"
  40. # Do not strip binaries on Mac OS X.
  41. #
  42. if echo "$host" | grep -v darwin; then
  43. LDFLAGS="${LDFLAGS--s}"
  44. fi
  45. fi
  46. AC_DEFINE([NDEBUG], [1],
  47. [Define to 1 if you are building a production release.])
  48. fi
  49. AC_MSG_RESULT([${ac_debug=no}])
  50. ])