GNU Info

Info Node: (libtool.info)Using Automake

(libtool.info)Using Automake


Next: Configuring Prev: Makefile rules Up: Integrating libtool
Enter node , (file) or (file)node

Using Automake with libtool
===========================

   Libtool library support is implemented under the `LTLIBRARIES'
primary.

   Here are some samples from the Automake `Makefile.am' in the libtool
distribution's `demo' subdirectory.

   First, to link a program against a libtool library, just use the
`program_LDADD' variable:

     bin_PROGRAMS = hell hell.debug
     
     # Build hell from main.c and libhello.la
     hell_SOURCES = main.c
     hell_LDADD = libhello.la
     
     # Create an easier-to-debug version of hell.
     hell_debug_SOURCES = main.c
     hell_debug_LDADD = libhello.la
     hell_debug_LDFLAGS = -static

   The flags `-dlopen' or `-dlpreopen' (Note: Link mode) would fit
better in the PROGRAM_LDADD variable.  Unfortunately, GNU automake, up
to release 1.4, doesn't accept these flags in a PROGRAM_LDADD variable,
so you have the following alternatives:

   * add them to PROGRAM_LDFLAGS, and list the libraries in
     PROGRAM_DEPENDENCIES, then wait for a release of GNU automake that
     accepts these flags where they belong;

   * surround the flags between quotes, but then you must set
     PROGRAM_DEPENDENCIES too:

          program_LDADD = "-dlopen" libfoo.la
          program_DEPENDENCIES = libfoo.la

   * set and `AC_SUBST' variables DLOPEN and DLPREOPEN in
     `configure.in' and use `@DLOPEN@' and `@DLPREOPEN@' as
     replacements for the explicit flags `-dlopen' and `-dlpreopen' in
     `program_LDADD'.  Automake will discard `AC_SUBST'ed variables
     from dependencies, so it will behave exactly as we expect it to
     behave when it accepts these flags in `program_LDADD'.  But hey!,
     this is ugly!

   You may use the `program_LDFLAGS' variable to stuff in any flags you
want to pass to libtool while linking `program' (such as `-static' to
avoid linking uninstalled shared libtool libraries).

   Building a libtool library is almost as trivial... note the use of
`libhello_la_LDFLAGS' to pass the `-version-info' (Note: Versioning)
option to libtool:

     # Build a libtool library, libhello.la for installation in libdir.
     lib_LTLIBRARIES = libhello.la
     libhello_la_SOURCES = hello.c foo.c
     libhello_la_LDFLAGS = -version-info 3:12:1

   The `-rpath' option is passed automatically by Automake (except for
libraries listed as `noinst_LTLIBRARIES'), so you should not specify it.

   Note: Building a Shared Library, for
more information.


automatically generated by info2www version 1.2.2.9