autoconf
[Top][All Lists]
Advanced

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

Re: Setting optimizations without violating autotools principles


From: Eric Blake
Subject: Re: Setting optimizations without violating autotools principles
Date: Thu, 07 Jul 2011 15:00:01 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

On 07/07/2011 02:36 PM, Chris Stankevitz wrote:
> Q1: How do I specify that I want optimizations turned off?

As an end-user:

./configure CFLAGS='-O0'

As a package developer, you can't require optimizations off, but you can
suggest them as the default, by adding this to your configure.ac after
AC_INIT but prior to AC_PROG_CC:

: ${CFLAGS="-O0"}

This example is documented in the autoconf manual under AC_PROG_CC.

> 
> Q2: Does your answer for Q1 work even when I use AC_PROG_CC which places -02 
> in CFLAGS?

The end-user's selection always trumps the configure default.  And the
configure default is '-g' for non-gcc, and '-g -O2' for gcc, unless you
as the package developer used the configure.ac trick in Q1 to change it.

> Q3: Does your answer for Q1 violate this autotools principle:
> You should never redefine a user variable such as CFLAGS 
> (http://tinyurl.com/3wkfdp5)

Nope.  As the package developer, you are only setting the default.  The
end user can always override you.

> 
> Q4: Does AC_PROG_CC violate this principle?

Nope - those are flags which the package developer uses no matter what
the user passes, _and_ which occur on the command line prior to $CFLAGS
(so the end user can _still_ override any flag that can be negated by
another option later on the command line).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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