autoconf
[Top][All Lists]
Advanced

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

Re: configure sets CFLAGS or how to disable default CFLAGS='-g -O2' for


From: Peter Volkov
Subject: Re: configure sets CFLAGS or how to disable default CFLAGS='-g -O2' for gcc?
Date: Sun, 02 Apr 2006 23:04:53 +0400

On Вск, 2006-04-02 at 13:06 -0400, Chris Pickett wrote:
> On Sun, April 2, 2006 7:35 am, Peter Volkov wrote:
> > AM_CFLAGS = $(GLIB_CFLAGS) -O3 -Wall -ffast-math
> 
> I wouldn't worry about -O3 and -ffast-math unless you are sure they will
> make a difference.

Yes. -O3 makes difference.

> Save CFLAGS before you call AC_PROG_CC, and restore it after, if you don't
> want "-g -O2".  Search the Autoconf list for AC_PROG_CC, there was a
> fairly clean way of doing it suggested in the last couple of years.  I
> know this because I recently had a similar problem: I wanted -O0 as the
> default.  AC_PROG_CC has been doing this since 1996.

Great! This works :) Thank you!

> > Another related question is what if I want to have different CFLAGS for
> > release and for debugging. How should I do this? I thought about different
> > AM_CFLAGS in Makefile.am and chose between them with
> > AM_CONDITIONAL, but now I don't know what to do.
> 
> I use AC_SUBST in configure.ac to define STRICT_CFLAGS, BROKEN_CFLAGS,
> DEBUG_CFLAGS and OPT_CFLAGS.  Strict flags give as many gcc warnings as
> possible, broken flags are those that don't play well for whatever reason
> and can't be used everywhere (e.g. I link against a library with variadic
> macros and so I have to put -Wno-variadic-macros in there, since I am
> using -ansi -pedantic -Werror).  Then to use these in a Makefile.am I do
> AM_CFLAGS += @STRICT_CFLAGS@, for example; you could also have them
> associated per-program.
> 
> You can use AC_ARG_ENABLE to get debugging and optimizing configure
> options, which can then be used inside Makefiles, just look at some
> examples of how this macro is used.  The one thing you should avoid is
> clobbering the environment CFLAGS in a configuration file, the end user
> should always be able to override (at least the important bits of) what
> you specified.

Ralf, in his mail mentioned that any setting of CFLAGS in program should
be avoided, but in my current program such approach could be very
convenient. Thank you again!

Peter.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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