From 68f9050a4b6769a7a2ee6b648dc5bd1f0211bc63 Mon Sep 17 00:00:00 2001 From: Joshua Sled Date: Wed, 31 Jan 2007 02:36:53 +0000 Subject: [PATCH] Force --enable-debug to strip spurious optimization added by AC_PROG_CC (for gcc). But if the user has optimization in their CFLAGS, make sure it's respected. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15477 57a11ea4-9604-0410-9ed3-97b8803252fd --- configure.in | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 3452c8c62f..c243acf630 100644 --- a/configure.in +++ b/configure.in @@ -37,6 +37,15 @@ GNUCASH_MAJOR_VERSION=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\ GNUCASH_MINOR_VERSION=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\2/' ]` GNUCASH_MICRO_VERSION=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\3/' ]` +# save any user/environment optimization flags before we muck with them in +# --enable-debug: +USER_OPTIMIZATION="" +for flag in $CFLAGS; do + if test -z $(echo $flag | sed -e 's,-O.,,'); then + USER_OPTIMIZATION="$USER_OPTIMIZATION ${flag}" + fi +done + ## Do this first, because the other tests depend on it: # Check for gcc and intltool (somehow breaks the suggested content @@ -563,7 +572,10 @@ AC_SUBST(GNC_LIBEXECDIR) AC_ARG_ENABLE( debug, [ --enable-debug compile with debugging flags set], - CFLAGS="${CFLAGS} -g" + # remove any optimization flags... + CFLAGS=$(echo $CFLAGS | sed -e 's,-O.,,g') + # ...except for those the user wants. + CFLAGS="${CFLAGS} -g ${USER_OPTIMIZATION}" LDFLAGS="${LDFLAGS} -g" AC_DEFINE(DEBUG_MEMORY,1,Enable debug memory), AC_DEFINE(DEBUG_MEMORY,0,Enable debug memory) )