Next: Per-Object Flags, Previous: Flag Variables Ordering, Up: FAQ
This happens when per-target compilation flags are used. Object files need to be renamed just in case they would clash with object files compiled from the same sources, but with different flags. Consider the following example.
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 they shared the same object, because generic.o cannot be built with both ‘-DEXIT_CODE=0’ and ‘-DEXIT_CODE=1’. Therefore automake outputs rules to build two different objects: true-generic.o and false-generic.o.
automake doesn't actually look whether source 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 compilation flags used.
It's OK to share object files when per-target compilation flags are not used. For instance, true and false will both use version.o in the following example.
AM_CPPFLAGS = -DVERSION=1.0 bin_PROGRAMS = true false true_SOURCES = true.c version.c false_SOURCES = false.c version.c
Note that the renaming of objects is also affected by the
_SHORTNAME variable (see Program and Library Variables).