[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: modification of CFLAGS
From: |
Ralf Wildenhues |
Subject: |
Re: modification of CFLAGS |
Date: |
Thu, 20 May 2010 20:45:16 +0200 |
User-agent: |
Mutt/1.5.20 (2009-10-28) |
Hello Jason,
* Jason Curl wrote on Thu, May 20, 2010 at 08:40:39PM CEST:
> I'd like to write a macro, called LX_DEBUG. This checks if the user
> gives "--enable-debug" and then depending on the compiler, modify
> CFLAGS.
>
> However, I see that the autoconf macros already modify CFLAGS. Is
> there a way that I can obtain what the user originally entered
> *within* my macro after AC_PROG_CC? If the user provided CFLAGS, I
> wish to use that and make no modifications. Otherwise, if GNU CC is
> used, I wish to set it to "-O0 -g".
>
> Currently, autotools sets it to "-O2 -g". I can't seem to figure out
> where the original settings are given.
You can access $CFLAGS before AC_PROG_CC, for example save its value to
some other variable:
LX_CFLAGS=${CFLAGS-NONE}
This will set them to "NONE" if CFLAGS was not set, and to $CFLAGS if it
was set to some empty or nonempty value.
Then, in your macro, you can access and compare $LX_CFLAGS and $CFLAGS,
for example. The macro should be called right (or soon) after
AC_PROG_CC, I guess, so other compiler tests use your flags.
Cheers,
Ralf