Next: Automatic de-ANSI-fication, Previous: Building a program, Up: Building Programs and Libraries [Index]
Building a library is much like building a program. In this case, the
name of the primary is ‘LIBRARIES’. Libraries can be installed in
libdir
or pkglibdir
.
Each ‘_LIBRARIES’ variable is a list of the base names of libraries to be built. For instance to create a library named libcpio.a, but not install it, you would write:
noinst_LIBRARIES = cpio
The sources that go into a library are determined exactly as they are for programs, via the ‘_SOURCES’ variables. Note that programs and libraries share a namespace, so one cannot have a program (lob) and a library (liblob.a) with the same name in one directory.
Extra objects can be added to a library using the ‘library_LIBADD’
variable. This should be used for objects determined by
configure
. Again from cpio:
cpio_LIBADD = @LIBOBJS@ @ALLOCA@
Note that Automake explicitly recognizes the use of @LIBOBJS@
and @ALLOCA@
in the above example, and uses this information,
plus the list of LIBOBJS
files derived from configure.in
to automatically include the appropriate source files in the
distribution (see What Goes in a Distribution). These source files are also automatically
handled in the dependency-tracking scheme, see See Automatic dependency tracking.