]> git.eshelyaron.com Git - emacs.git/commitdiff
* configure.ac (CFLAGS): Prefer -g3 to -g if -g3 works
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Aug 2012 04:37:40 +0000 (21:37 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Aug 2012 04:37:40 +0000 (21:37 -0700)
and if the user has not specified CFLAGS.  -g3 simplifies
debugging, since it makes macros visible to the debugger.

ChangeLog
configure.ac

index 554103d149efdc9c7aceaa74664c4c2f3364c961..228cf1d74d7d595053ae396d1cbdece228e0e6f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * configure.ac (CFLAGS): Prefer -g3 to -g if -g3 works
+       and if the user has not specified CFLAGS.  -g3 simplifies
+       debugging, since it makes macros visible to the debugger.
+
 2012-08-25  Juanma Barranquero  <lekktu@gmail.com>
 
        * lib/makefile.w32-in ($(BLD)/execinfo.$(O)): Update dependencies.
index b10cb24bab67044160a1105c85c1669a913155bf..71ec98390aa18788cfb67b6a2ab84467d89cbf30 100644 (file)
@@ -577,6 +577,34 @@ fi
 # Initialize gnulib right after choosing the compiler.
 gl_EARLY
 
+# It's helpful to have C macros available to GDB, so prefer -g3 to -g
+# if -g3 works and the user does not specify CFLAGS.
+# This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
+if test "$ac_test_CFLAGS" != set; then
+  case $CFLAGS in
+    '-g')
+      emacs_g3_CFLAGS='-g3';;
+    '-g -O2')
+      emacs_g3_CFLAGS='-g3 -O2';;
+    *)
+      emacs_g3_CFLAGS='';;
+  esac
+  if test -n "$emacs_g3_CFLAGS"; then
+    emacs_save_CFLAGS=$CFLAGS
+    CFLAGS=$emacs_g3_CFLAGS
+    AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
+      [emacs_cv_prog_cc_g3],
+      [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+        [emacs_cv_prog_cc_g3=yes],
+         [emacs_cv_prog_cc_g3=no])])
+    if test $emacs_cv_prog_cc_g3 = yes; then
+      CFLAGS=$emacs_g3_CFLAGS
+    else
+      CFLAGS=$emacs_save_CFLAGS
+    fi
+  fi
+fi
+
 AC_ARG_ENABLE([gcc-warnings],
   [AS_HELP_STRING([--enable-gcc-warnings],
                   [turn on lots of GCC warnings. This is intended for