From 6e8aca60a8a3efaf397eab15d8b0cff3720e83b1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 25 Aug 2012 21:37:40 -0700 Subject: [PATCH] * 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. --- ChangeLog | 6 ++++++ configure.ac | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/ChangeLog b/ChangeLog index 554103d149e..228cf1d74d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-08-26 Paul Eggert + + * 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 * lib/makefile.w32-in ($(BLD)/execinfo.$(O)): Update dependencies. diff --git a/configure.ac b/configure.ac index b10cb24bab6..71ec98390aa 100644 --- a/configure.ac +++ b/configure.ac @@ -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 -- 2.39.2