bug-automake
[Top][All Lists]
Advanced

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

Re: Incorrect order of AM_CXXFLAGS and CXX_FLAGS?


From: Ralf Corsepius
Subject: Re: Incorrect order of AM_CXXFLAGS and CXX_FLAGS?
Date: Tue, 23 Nov 2004 15:39:09 +0100

On Tue, 2004-11-23 at 12:37 +0100, Marcel Loose wrote:
> Hi,
> 
> Recently, I stumbled across the following problem. We use the
> auto-tools in
> our build environment and have some GNU G++ compiler flags predefined
> -- they
> are defined as CXXFLAGS in an m4-macro that is invoked during
> configure.
> Among these flags are "-Wall" and "-W".
Well, it's arguable if these are CFLAGS, CXXFLAGS or CPPFLAGS.

Actually, they don't belong into any of these families, because most of
GCC's -W options are "overall options".

> I wanted to configure/compile one sub-package in our software tree with
> an
> extra flag "-Wno-unused-parameter". So I added a line AM_CXXFLAGS =
> -Wno-unused-parameter to my Makefile.am. The problem is, however, that
> it
> doesn't work. Automake adds the compiler flag before the default
> CXX_FLAGS,
> and as a result -Wall overrides the -Wno-unused-parameter flag.

You should not hard-code any compiler specific flags into a
Makefile.am ;)

> Now, I don't know whether this a GCC "bug", or not, but it would make
> sense,
> IMHO, to *append* AM_*FLAGS, rather than to *prepend* them. Especially
> because GCC usually retains the last occurrence of a switch that
> appears on
> the command line more than once.
> 
> So, instead of the current definition in automake:
> $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
> $(CPPFLAGS)
> $(AM_CXXFLAGS) $(CXXFLAGS),
> wouldn't it be better if it were defined as:
> $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS)
> $(AM_CPPFLAGS)
> $(CXXFLAGS) $(AM_CXXFLAGS)

No, because this would prevent you from being able to override flags
from the environment.

However, the work-around to your issue is quite simple:
Override CXXFLAGS from the environment to prevent the configure script
from choosing the defaults.

RAlf







reply via email to

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