Re: tune gcc
On Tue, 18 Mar 2003 02:35:52 +1100
Rob Weir <firstname.lastname@example.org> wrote:
If setting CFLAGS is the answer, do you need to set all of them, or
only> the one you want to change?
Hm, I don't think I quite got what you meant there...You just set
whatever flags you'd set on the command line, anyway...
1. I set CFLAGS to <something>
2. In a program I want to compile (or its Makefile or wherever) CFLAGS
is set to <a bunch of things>
Does CFLAGS end up as <something> or as <something plus a bunch of
Does my setting add to or replace what would otherwise be set?
Let me take a shot at this. "CFLAGS" is just a popular name for a makefile
variable to hold the flags to be sent to the compiler. Whether or how it gets
used is entirely up to the Makefile or configure script being used. GCC and
other compilers do NOT look for or use CFLAGS, its not "special" to them. So
you'll need to look at the Makefile[.in] and maybe the configure.[in,ac], if
present, to to see how CFLAGS is being used, if at all.
If your package is using a configure script, i.e. it uses autoconf to build
the Makefile for you, CFLAGS is normally used, and you can usually set CFLAGS
first before running configure. On a bash shell you do something like this:
By convention, configure will use a CFLAGS variable if it exists at the moment
configure is run. Otherwise the script uses its own defaults. Most configure
scripts (by convention) will also *add* to the CFLAGS variable anything they
need, instead of overwriting or replacing it. After running configure, you
can look in the Makefile just produced and see your flags being assigned to
the CFLAGS variable.
If you aren't using a configure script, just a Makefile, you'll need to look
at the Makefile to see if it uses a CFLAGS variable, since there aren't the
same kind of conventions involved in hand-written Makefiles like there are
with using autoconf. In fact, there may not be a CFLAGS variable at all, or
even one like it but using a different name. In this case you'll have to edit
the Makefile yourself to set the flags you want passed to the compiler.