8.3.7 _LIBADD, _LDFLAGS, and _LIBTOOLFLAGS

As shown in previous sections, the ‘library_LIBADD’ variable should be used to list extra libtool objects (.lo files) or libtool libraries (.la) to add to library.

The ‘library_LDFLAGS’ variable is the place to list additional libtool linking flags, such as -version-info, -static, and a lot more. See Link mode in The Libtool Manual.

The libtool command has two kinds of options: mode-specific options and generic options. Mode-specific options such as the aforementioned linking flags should be lumped with the other flags passed to the tool invoked by libtool (hence the use of ‘library_LDFLAGS’ for libtool linking flags). Generic options include --tag=tag and --silent (see Invoking libtool in The Libtool Manual for more options). They should appear before the mode selection on the command line; in Makefile.ams they should be listed in the ‘library_LIBTOOLFLAGS’ variable.

If ‘library_LIBTOOLFLAGS’ is not defined, then the variable AM_LIBTOOLFLAGS is used instead.

These flags are passed to libtool after the --tag=tag option computed by Automake (if any), so ‘library_LIBTOOLFLAGS’ (or AM_LIBTOOLFLAGS) is a good place to override or supplement the --tag=tag setting.

The libtool rules also use a LIBTOOLFLAGS variable that should not be set in Makefile.am: this is a user variable (see Flag Variables Ordering). It allows users to run ‘make LIBTOOLFLAGS=--silent’, for instance. Note that the verbosity of libtool can also be influenced by the Automake support for silent rules (see How Automake can help in silencing Make).