Next: Special handling for LIBOBJS and ALLOCA, Previous: Program and Library Variables, Up: Building Programs and Libraries [Contents][Index]
_SOURCES
_SOURCES
variables are used to specify source files of programs
(see Building a program), libraries (see Building a library), and Libtool
libraries (see Building a Shared Library).
When no such variable is specified for a target, Automake will define one itself. The default is to compile a single C file whose base name is the name of the target itself, with any extension replaced by .c. (Defaulting to C is terrible but we are stuck with it for historical reasons.)
For example if you have the following somewhere in your Makefile.am with no corresponding ‘libfoo_a_SOURCES’:
lib_LIBRARIES = libfoo.a sub/libc++.a
libfoo.a will be built using a default source file named libfoo.c, and sub/libc++.a will be built from sub/libc++.c. (In older versions sub/libc++.a would be built from sub_libc___a.c, i.e., the default source was the canonized name of the target, with .c appended. Be believe the new behavior is more sensible, but for backward compatibility automake will use the old name if a file or a rule with that name exist.)
Default sources are mainly useful in test suites, when building many tests programs each from a single source. For instance in
check_PROGRAMS = test1 test2 test3
test1, test2, and test3 will be built from test1.c, test2.c, and test3.c.
Another case where is this convenient is building many Libtool modules (moduleN.la), each defined in its own file (moduleN.c).
AM_LDFLAGS = -module lib_LTLIBRARIES = module1.la module2.la module3.la
Finally, there is one situation where this default source computation
needs to be avoided: when a target should not be built from sources.
We already saw such an example in Building true and false; this happens when all
the constituents of a target have already been compiled and need just
to be combined using a _LDADD
variable. Then it is necessary
to define an empty _SOURCES
variable, so that automake does not
compute a default.
bin_PROGRAMS = target target_SOURCES = target_LDADD = libmain.a libmisc.a
Next: Special handling for LIBOBJS and ALLOCA, Previous: Program and Library Variables, Up: Building Programs and Libraries [Contents][Index]