Makefile.am for shared libraries

Makefile.am for a simple program.

AM_CPPFLAGS = $(all_includes)

lib_LTLIBRARIES = libkonq.la
libkonq_la_LIBADD = $(LIB_KPARTS)
libkonq_la_LDFLAGS = $(all_libraries) -version-info 6:0:2 -no-undefined
libkonq_la_SOURCES = popupmenu.cc knewmenu.cpp ...

METASOURCES = AUTO

The lib_ prefix means that the library will be installed in lib/. Then comes the name of the library, always followed by .la. Note how this becomes _la in the lines that refer to it.

*_LTLIBRARIES

means "LibTool libraries", i.e. it asks for libtool to handle them. You should always use this for libs.

*_LIBADD

is the list of libraries that this lib depends upon. Note that it's LDADD for programs and LIBADD for libs, since it's not exactly the same thing (a lib only remembers which libs it depends upon, it doesn't "link them in"). See LDADD about how to order dependencies.

*_LDFLAGS

ontains the flags passed to the linker. $(all_libraries) for the -L flags as usual, but also the version number of the library (see info libtool / Versioning / Libtool versioning for details). -no-undefined is strongly recommended: it allows to check at link time that the library doesn't have undefined symbols. If any undefined symbol shows up, it means that either you forgot to implement a method, or a dependent library is missing in the LIBADD line. The rest is similar to the "compiling a binary" case.