After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 685204 - ./configure fails to add the '-g' flag to CFLAGS
./configure fails to add the '-g' flag to CFLAGS
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-10-01 12:05 UTC by Emanuele Aina
Modified: 2014-01-20 13:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
configure: Fix -g flag detection if CFLAGS is set (1019 bytes, patch)
2012-10-01 12:05 UTC, Emanuele Aina
none Details | Review

Description Emanuele Aina 2012-10-01 12:05:06 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
Comment 1 Emanuele Aina 2012-10-01 12:05:09 UTC
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.