(automake-1.16.info)Renamed Objects


Next: Per-Object Flags Prev: Flag Variables Ordering Up: FAQ
Enter node , (file) or (file)node

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.

     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 (Note: Program and Library Variables).


automatically generated by info2www version 1.2.2.9