This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Should `configure' record LDFLAGS as well as CFLAGS?
- From: Jim Blandy <jimb at redhat dot com>
- To: gdb at sources dot redhat dot com
- Date: Fri, 19 Jul 2002 15:36:43 -0500 (EST)
- Subject: Should `configure' record LDFLAGS as well as CFLAGS?
There may be some well-known reason this isn't done, but I don't know
it, so I thought I'd ask anyway.
When you run the configure script for GDB, it captures the value of
the `CFLAGS' environment variable and sticks it in the makefiles it
generates, so you don't need to retype it. For example:
$ CFLAGS=-g3 $D/configure --prefix=$DI
$ make
... this make then runs with CFLAGS set to `-g3'.
I think this is because the Makefile.in files all have lines like
this:
$ cd $D
$ find . -name 'Makefile.in' | xargs grep '@CFLAGS@'
./gdb/Makefile.in:CFLAGS = @CFLAGS@
./gdb/gdbserver/Makefile.in:CFLAGS = @CFLAGS@
./gdb/rdi-share/Makefile.in:CFLAGS = @CFLAGS@
./bfd/Makefile.in:CFLAGS = @CFLAGS@
./opcodes/Makefile.in:CFLAGS = @CFLAGS@
./readline/Makefile.in:CFLAGS = @CFLAGS@
./readline/examples/Makefile.in:CFLAGS = @CFLAGS@
./readline/shlib/Makefile.in:CFLAGS = @CFLAGS@
./readline/shlib/Makefile.in:LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@ @CFLAGS@
./libiberty/Makefile.in:CFLAGS = @CFLAGS@
./libiberty/testsuite/Makefile.in:CFLAGS = @CFLAGS@
./sim/Makefile.in:CFLAGS = @CFLAGS@
./sim/common/Makefile.in:CFLAGS = @CFLAGS@
./sim/igen/Makefile.in:CFLAGS = @CFLAGS@
./sim/ppc/Makefile.in:CFLAGS = @CFLAGS@
./sim/w65/Makefile.in:CFLAGS = @CFLAGS@
./utils/spu/Makefile.in:CFLAGS = @CFLAGS@
./intl/Makefile.in:CFLAGS = @CFLAGS@
$
However, LDFLAGS isn't (usually) treated the same way:
$ find . -name 'Makefile.in' | xargs grep '@LDFLAGS@'
./gdb/rdi-share/Makefile.in:LDFLAGS = @LDFLAGS@
./bfd/Makefile.in:LDFLAGS = @LDFLAGS@
./opcodes/Makefile.in:LDFLAGS = @LDFLAGS@
./readline/shlib/Makefile.in:LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@ @CFLAGS@
./intl/Makefile.in:LDFLAGS = @LDFLAGS@
$
So whatever setting for LDFLAGS you establish while running
`configure' only affect the compilations the configure script runs
itself; the program then gets built with whatever settings you pass
when you run `make'.
This seems inconsistent to me: if you configure and build with
different LDFLAGS, configuration tests might yield results that are
wrong for the build.
And you can't just stuff everything you want in CFLAGS. If I say, for
example:
$ CFLAGS='-g3 -L ${LIB} -Wl,-rpath,${LIB},-dynamic-linker,${LIB}/ld-linux.so.2' $D/configure --prefix=$DI
that gets into all the Makefiles, but then I get lots of messages from
the compiler invocations that just build .o files warning that the
-rpath and -dynamic-linker options are being ignored since I'm not
linking.
So, does anyone know why we shouldn't add LDFLAGS = @LDFLAGS@ to
gdb/Makefile.in?