Chapter 4. The libkavclient library and GNU autotools

This chapter is intended for programmers who wish to use the libkavclient library in conjunction with GNU autotools. It assumes basic familiarity with GNU autoconf, automake and libtool.

If you are developing application using GNU autotools (autoconf, automake and libtool), you may benefit from autoconf macros that ship with libkavclient. You can use these macros in your configure.in (or configure.ac) files to check for presense (and location) of libkavclient. The macros are defined in the file named kavclient.m4, which is by default installed into a directory where aclocal command can find it (usually /usr/share/aclocal). Thus you can simply put them in your configure.in, and they will work; just don't forget to run aclocal (which you will need to do anyway if you are using automake).

There are two macros that you can use to detect libkavclient: KAV_PATH_KAVCLIENT and KAV_REQUIRE_KAVCLIENT

The KAV_PATH_KAVCLIENT macro takes two arguments, action-if-found and action-if-not-found. When invoked, it will look for the libkavclient library. If found, it will set set KAV_LIBS variable to -lkavclient plus any necessary -L option, KAV_INCLUDES to necessary -I option (the variables are set in shell and will be substituted in Makefiles), define HAVE_KAVCLIENT_H and HAVE_LIBKAVCLIENT preprocessor symbols and execute action-if-found. If libkavclient is not found, the macro will execute action-if-not-found. The macro invocation also adds --with-kavclient-libs and --with-kavclient-includes options to your configure script. These options may be specified by your package builder when configure is invoked to indicate locations of libkavclient header and library, if they are installed to non-standard places.

If your application requires libkavclient (i.e. won't build without it at all), you can use a simpler macro KAV_REQUIRE_KAVCLIENT. This macro takes no arguments. It checks for the presense of libkavclient, and, if it's found, adds necessary -I option to CPPFLAGS Makefile variable and necessary -l amd -L options to LIBS Makefile variable. Thus your application will compile and links with libkavclient without any further ado. It also adds corresponding flags to all_includes and all_libraries variables, for the benefit of KDE applications that often use them (in particular, those created with KDevelop). If libkavclient is not found, the macro reports an error and stops your configure script. Since KAV_REQUIRE_KAVCLIENT calls KAV_PATH_KAVCLIENT internally, it also adds --with-kavclient-libs and --with-kavclient-includes options to your configure script.

The libkavclient library itself is built with libtool and libtool pseudo-library libkavclient.la is installed with it, to facilitate building applicatins that use libkavclient with libtool.