automake-1.16: Renamed Objects

 
 26.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.
 
      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 determine whether source files are shared
 to decide if it must rename objects.  It just renames all objects of a
 target as soon as it sees that per-target compilation flags are 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 (⇒Program and Library Variables).