27.7 Why are object files sometimes renamed?

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.

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.