[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How can I override CXXFLAGS?
From: |
Nick Bowler |
Subject: |
Re: How can I override CXXFLAGS? |
Date: |
Sun, 10 Aug 2014 17:21:55 -0400 |
User-agent: |
Mutt/1.5.22 (2013-10-16) |
On 2014-08-10 10:48 -0700, bholland wrote:
> I am working on a project that I joined and I noticed that the flags are all
> a mess. When a flag called --enabled-debug was set it it sets
>
> AM_CXXFLAGS="$AM_CXXFLAGS -g -Wall -O0"
> AM_LDFLAGS="$AM_LDFLAGS -g"
>
> but when I compile all of my stuff, the CXXFLAGS variable is set to -g -O2
> which completely negates the ability to debug.
[...]
> Basically, what I want is the expected default behavior. I want to set
> CXXFLAGS to nothing by default unless it has been specified by the user. It
> is very strange that this is not how it works so I suppose I am also curious
> as to why this is the case.
Your observation is correct, Autoconf sets default values
for CFLAGS/etc. if they are not explicitly specified by the
user. This is by design: if it did not happen, the sequence
./configure && make && make install would produce an unoptimized
build, which is not really good user experience.
Usually it suffices to just set debugging flags directly on the
command line, e.g.,
./configure CXXFLAGS="-g"
which has the side effect of suppressing the default flag assignment.
If for some reason you want to change the defaults, you can just set
them before AC_PROG_CXX, taking care not to override the user. For
example:
AS_IF([$debug_enabled && test x"${CXXFLAGS+set}" != x"set"],
[CXXFLAGS=-g])
Cheers,
--
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)