GNOME Bugzilla – Bug 685204
./configure fails to add the '-g' flag to CFLAGS
Last modified: 2014-01-20 13:17:23 UTC
When calling `./configure --enable-debug' with a CFLAGS variable that doesn't contains the '-g' flag (eg. CFLAGS='-O0') ./configure fails to add it because it skips the 'case' statement checking for it's presence due to an inverted condition in the containing 'if'. This is the script used to verify the issue: echo "Running with CFLAGS unset" ./autogen.sh --prefix=$PREFIX --enable-debug > /dev/null 2>&1 && grep ^CFLAGS Makefile echo "Running with CFLAGS='-0'" CFLAGS='-O0' ./autogen.sh --prefix=$PREFIX --enable-debug > /dev/null 2>&1 && grep ^CFLAGS Makefile echo "Running with CFLAGS='-O0 -g'" CFLAGS='-O0 -g' ./autogen.sh --prefix=$PREFIX --enable-debug > /dev/null 2>&1 && grep ^CFLAGS Makefile Results from git master (2.34.0-12-gf61b892): Running with CFLAGS unset CFLAGS = -g -O2 -Wall Running with CFLAGS='-0' CFLAGS = -O0 -Wall # Note the lack of '-g' here Running with CFLAGS='-O0 -g' CFLAGS = -O0 -g -Wall Results with the patch applied: Running with CFLAGS unset CFLAGS = -g -O2 -Wall Running with CFLAGS='-0' CFLAGS = -O0 -g -Wall Running with CFLAGS='-O0 -g' CFLAGS = -O0 -g -Wall
Created attachment 225482 [details] [review] configure: Fix -g flag detection if CFLAGS is set When being passed the --enable-debug flag, ./configure looks for the CFLAGS environment variable and adds the '-g' flag if it isn't already there. Fix the check to see if CFLAGS has already been defined in the environment to restore the above described behaviour.