libtool: Using Automake

1 
1 5.3 Using Automake with libtool
1 ===============================
1 
1 Libtool library support is implemented under the 'LTLIBRARIES' primary.
1 
1    Here are some samples from the Automake 'Makefile.am' in the libtool
1 distribution's 'demo' subdirectory.
1 
1    First, to link a program against a libtool library, just use the
1 'program_LDADD'(1) variable:
1 
1      bin_PROGRAMS = hell hell_static
1 
1      # Build hell from main.c and libhello.la
1      hell_SOURCES = main.c
1      hell_LDADD = libhello.la
1 
1      # Create a statically linked version of hell.
1      hell_static_SOURCES = main.c
1      hell_static_LDADD = libhello.la
1      hell_static_LDFLAGS = -static
1 
1    You may use the 'program_LDFLAGS' variable to stuff in any flags you
1 want to pass to libtool while linking 'program' (such as '-static' to
1 avoid linking uninstalled shared libtool libraries).
1 
1    Building a libtool library is almost as trivial... note the use of
1 'libhello_la_LDFLAGS' to pass the '-version-info' (⇒Versioning)
1 option to libtool:
1 
1      # Build a libtool library, libhello.la for installation in libdir.
1      lib_LTLIBRARIES = libhello.la
1      libhello_la_SOURCES = hello.c foo.c
1      libhello_la_LDFLAGS = -version-info 3:12:1
1 
1    The '-rpath' option is passed automatically by Automake (except for
1 libraries listed as 'noinst_LTLIBRARIES'), so you should not specify it.
1 
1    ⇒Building a Shared Library (automake)A Shared Library, for more
1 information.
1 
1    ---------- Footnotes ----------
1 
1    (1) Since GNU Automake 1.5, the flags '-dlopen' or '-dlpreopen'
1 (⇒Link mode) can be employed with the 'program_LDADD' variable.
1 Unfortunately, older releases didn't accept these flags, so if you are
1 stuck with an ancient Automake, we recommend quoting the flag itself,
1 and setting 'program_DEPENDENCIES' too:
1 
1      program_LDADD = "-dlopen" libfoo.la
1      program_DEPENDENCIES = libfoo.la
1