autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_INIT seems to be setting CXXFLAGS


From: Monty Taylor
Subject: Re: AC_INIT seems to be setting CXXFLAGS
Date: Thu, 30 Jul 2009 12:20:51 -0700
User-agent: Thunderbird 2.0.0.22 (X11/20090608)

Bob Friesenhahn wrote:
> On Sun, 26 Jul 2009, Richard Connon wrote:
>>
>> Hi. I'm trying to write a configure.ac script for a project I'm working
>> on. At present it has AC_INIT at the beginning.
>> It seems that running that macro is adding "-g -O2" to the CXXFLAGS
>> variable. Is there anything I can do to stop this?

Funny - I was literally just about to send an email pointing out a bug
in part of that...

> Standard practice is to run configure like
> 
>   ./configure CXXFLAGS=-O3
> 
> or
> 
>   env CXXFLAGS=-O3 ./configure
> 
> In both cases, configure will no longer insert its default CXXFLAGS value.
> 
> It is supposed to be up to the user (the person who builds the software)
> to determine which flags are used.

AC_PROG_CXX will only add -g -O2 if CXXFLAGS is empty. The "cleanest"
way I've found to deal with this and not bork the end user's choices is:

  AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
        [CFLAGS=""])
  AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
        [CXXFLAGS=""])

I run that before AC_CANONICAL_TARGET, AC_PROG_CC or AC_PROG_CXX and it
does the trick.

The terrible part about how this mechanism works is that it injects into
CXXFLAGS itself, which means that, without my configure script can't
override that via the setting of AM_CXXFLAGS.

Monty




reply via email to

[Prev in Thread] Current Thread [Next in Thread]