automake-1.16: Libtool Libraries
8.3.2 Building Libtool Libraries
--------------------------------
Automake uses libtool to build libraries declared with the ‘LTLIBRARIES’
primary. Each ‘_LTLIBRARIES’ variable is a list of libtool libraries to
build. For instance, to create a libtool library named ‘libgettext.la’,
and install it in ‘libdir’, write:
lib_LTLIBRARIES = libgettext.la
libgettext_la_SOURCES = gettext.c gettext.h ...
Automake predefines the variable ‘pkglibdir’, so you can use
‘pkglib_LTLIBRARIES’ to install libraries in ‘$(libdir)/@PACKAGE@/’.
If ‘gettext.h’ is a public header file that needs to be installed in
order for people to use the library, it should be declared using a
‘_HEADERS’ variable, not in ‘libgettext_la_SOURCES’. Headers listed in
the latter should be internal headers that are not part of the public
interface.
lib_LTLIBRARIES = libgettext.la
libgettext_la_SOURCES = gettext.c ...
include_HEADERS = gettext.h ...
A package can build and install such a library along with other
programs that use it. This dependency should be specified using
‘LDADD’. The following example builds a program named ‘hello’ that is
linked with ‘libgettext.la’.
lib_LTLIBRARIES = libgettext.la
libgettext_la_SOURCES = gettext.c ...
bin_PROGRAMS = hello
hello_SOURCES = hello.c ...
hello_LDADD = libgettext.la
Whether ‘hello’ is statically or dynamically linked with ‘libgettext.la’
is not yet known: this will depend on the configuration of libtool and
the capabilities of the host.