[Top][All Lists]

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

Re: Best means to override CXXFLAGS locally

From: Sander Niemeijer
Subject: Re: Best means to override CXXFLAGS locally
Date: Mon, 23 Oct 2006 13:56:45 +0200

Hi Ralf,

I have been struggling with the 'single file disable optimization issue' for a while and used to have a somewhat ugly solution up to this point. The recent fixes in automake that ensure that target_??FLAGS always overrides AM_??FLAGS make your suggestion a valid solution now.

In our project we have a single file (part of a libtool library target) that is too big to be compiled with optimization turned on.
Based on your suggestion I now use the following approach:

In I have the following (at the bottom of the file!, just before AC_OUTPUT):
# here are some rules that set the value for DISOPT_FLAG for certain compilers. For gcc this is -O0
# ...

# store CFLAGS in CFG_CFLAGS and clear CFLAGS so we can override the flags (e.g. DISOPT_FLAG) in our Makefile(s)

Then in each I have at the top:
and for each target_CFLAGS setting in a I add '$ (CFG_CFLAGS)'

The single file that has to be build with optimization turned off is now build as a libtool 'convenience library':

bigfile_la_sources = bigfile.c
and this convenience library is added to the original library by adding '' to the _la_LIBADD setting of the original library.

The catch with this approach is that running a 'make CFLAGS=<some other flags>' (if you ever do such a thing) will no longer replace the initial CFLAGS settings that were provided to the configure script (or set by AC_PROG_CC). It will just add them at the end (and also override the DISOPT_FLAG!). With the way I have set up the CFG_CFLAGS setting in you can now still replace the original CFLAGS by using 'make CFG_CFLAGS=<some other flags>'.

Best regards,

On 22-okt-2006, at 13:46, Ralf Wildenhues wrote:

Hello Akim,

* Akim Demaille wrote on Sun, Oct 22, 2006 at 01:10:02PM CEST:
What would be the cleanest means to handle this exception?

Here is what I did:

I think it's much better to do the munging in  Store the
CFLAGS set by the user and/or AC_PROG_CC in AM_CFLAGS, and override
CFLAGS. Depending upon whether the changed flags settings apply to only
a few, non-portability-problematic files in your project, the rest of
the configure tests should run with the flags set by the user, and you
should only override at the end, or the converse.

Much cleaner, involves much less changes.  If you have something that
works nicely and is reasonably generally useful, post a summary, or
even better, a FAQ addition to the manual.  ;-)


reply via email to

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