This is the mail archive of the
automake@gnu.org
mailing list for the automake project.
Re: AM_CPPFLAGS vs. [lib]_CPPFLAGS
- From: William S Fulton <wsf at fultondesigns dot co dot uk>
- To: Alexandre Duret-Lutz <duret_g at lrde dot epita dot fr>, Bill Moseley <moseley at hank dot org>, automake at gnu dot org
- Date: Fri, 18 Apr 2003 21:37:45 +0100
- Subject: Re: AM_CPPFLAGS vs. [lib]_CPPFLAGS
I was puzzling over this some time ago too. Perhaps this explanation
could be put in the manual?
William
Bill> But I don't understand why. Is this expected behavior?
Yes. If you use per-targets flag, objects files need to be
renamed just in case they would clash with objects files compiled
from the same sources, but with different flags.
Consider
bin_PROGRAMS = true false
true_SOURCES = generic.c
true_CPPFLAGS = -DEXIT_CODE=0
false_SOURCES = generic.c
false_CPPFLAGS = -DEXIT_CODE=1
Obviously the two programs are built from the same source, but
it would be bad if the shared the same object (generic.o)
because it cannot be built with EXIT_CODE=0 *and* EXIT_CODE=1...
Therefore Automake output rules to build two different objects:
true-generic.o and false-generic.o.
Automake doesn't actually look whether sources files are shared
to decide if it must rename objects. It will just rename all
objects of a target as soon as it sees per-target flags are
used.
If you don't use per-target flags, then it's ok to share
object files. For instance
AM_CPPFLAGS = -DVERSION=1.0
bin_PROGRAMS = true false
true_SOURCES = true.c version.c
false_SOURCES = false.c version.c
Here true and false will both use version.o.
--
Alexandre Duret-Lutz