autoconf
[Top][All Lists]
Advanced

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

Re: changing the default "-g -O2"


From: Bob Proulx
Subject: Re: changing the default "-g -O2"
Date: Mon, 31 Mar 2003 21:57:56 -0700
User-agent: Mutt/1.3.28i

sashan wrote:
> 
> I've been trying to get to grips with autoconf. When I create a simple 
> 'hello world' type project the flags "-g -O2" are passed to the 
> compiler. How do I change this? What AC_* macro do I need to use?

In general you should not need to change this.  It is a good default
set of options.  And regardless would you would not want to change
this in the configure.ac file.  [There are always exceptions to every
rule, however.]  If configure detects that it can pass both -g and -O
to the compiler it does.  GCC can both optimize and debug at the same
time.  [Again, that is the rule but sometimes it does not do both as
well as one would like.]

But you can't guarentee that GCC will be the compiler used by a
program on someone else's machine.  And conversely you can't guarentee
that the native 'cc' would be the compiler.  The whole point of
configure is to test and probe and determine dynamically what is a
good compiler and what are the options to the compiler that work.

Autoconf also gives you ways to override its probed values.  You can
pass them either in the environment or on the command line.  The
command line is preferred.  This means that I can force the native
'cc' compiler even if 'gcc' is installed, for example.  Here is one
common case that I use for configure.

  ./configure CC=cc CFLAGS='-Ae -O +DA1.1 +DS2.0'

With flexibility such as this one would not want to hard code in
particular values into a configure.ac file.  It is impossible to guess
all possible ways in which a package might be used on different
systems.  The flexibility of using working defaults and allowing user
overrides for special cases makes this very powerful.

Having said all of this I feel from reading your note that you really
mean something more than just the specific question and answer
provided here.  Perhaps if you shared the overall thing that you are
trying to do someone on the list would have a better suggestion as to
how to do the thing you are trying to do?

Bob




reply via email to

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