[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 Makefile.am: AM_CFLAGS = -O0
That won't work as user CFLAGS come after AM_CFLAGS in the command line.
> b) in configure.ac: 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
> (http://tinyurl.com/3wkfdp5)
>
> 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
preferences.
You can do so too:
# Override CFLAGS if not set by the user.
test ${CFLAGS+set} = set || CFLAGS=-O0
AC_PROG_CC
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
CFLAGS_set_by_user=true
else
CFLAGS_set_by_user=false
fi
AC_PROG_CC
# Now, do your overriding based on $CFLAGS and $CFLAGS_set_by_user
# and whatever other data.
Cheers,
Ralf
[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.