[Top][All Lists]

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

Re: Setting optimizations without violating autotools principles

From: Ralf Wildenhues
Subject: Re: Setting optimizations without violating autotools principles
Date: Thu, 07 Jul 2011 23:16:05 +0200

Hi Chris,

On Thu, Jul 07, 2011 at 01:36:29PM -0700, Chris Stankevitz wrote:
> Q1: How do I specify that I want optimizations turned off?
> a) in AM_CFLAGS = -O0

That won't work as user CFLAGS come after AM_CFLAGS in the command line.

> b) in CFLAGS="$CFLAGS -O0"
> c) other
> Q2: Does your answer for Q1 work even when I use AC_PROG_CC which places -02 
> in CFLAGS?
> Q3: Does your answer for Q1 violate this autotools principle:
> You should never redefine a user variable such as CFLAGS 
> (
> Q4: Does AC_PROG_CC violate this principle?

AC_PROG_CC is documented to enable optimization, and enable
debugging if feasible[1], iff the user hasn't set her own

You can do so too:

# Override CFLAGS if not set by the user.
test ${CFLAGS+set} = set || CFLAGS=-O0

which answers Q1b and Q2.  Answer to Q3: no.  :-)

Hope that helps.

If you want to munge with CFLAGS but also want to take into account
what AC_PROG_CC would have set, you can do things like

if test ${CFLAGS+set} = set; then
# Now, do your overriding based on $CFLAGS and $CFLAGS_set_by_user
# and whatever other data.


[1] Yes, its definition of "feasible" was maaaybee somewhat valid ten
years, ago, but it definitely isn't today, and I don't know whether
it actually was back then.  Me no Autoconfer back then.

reply via email to

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