Next: , Previous: , Up: Preparation   [Contents][Index]


2.4 Using Automake

It is much easier if you use GNU Automake instead of writing your own Makefiles. If you do that you do not have to worry about finding and invoking the gpgme-config script at all. GPGME provides an extension to Automake that does all the work for you.

Macro: AM_PATH_GPGME ([minimum-version], [action-if-found], [action-if-not-found])
Macro: AM_PATH_GPGME_PTH ([minimum-version], [action-if-found], [action-if-not-found])
Macro: AM_PATH_GPGME_PTHREAD ([minimum-version], [action-if-found], [action-if-not-found])

Check whether GPGME (at least version minimum-version, if given) exists on the host system. If it is found, execute action-if-found, otherwise do action-if-not-found, if given.

Additionally, the function defines GPGME_CFLAGS to the flags needed for compilation of the program to find the gpgme.h header file, and GPGME_LIBS to the linker flags needed to link the program to the GPGME library. If the used helper script does not match the target type you are building for a warning is printed and the string libgcrypt is appended to the variable gpg_config_script_warn.

AM_PATH_GPGME_PTHREAD checks for the version of GPGME that can be used with the native pthread implementation, and defines GPGME_PTHREAD_CFLAGS and GPGME_PTHREAD_LIBS. Since version 1.8.0 this is no longer required to GPGME_PTHREAD as GPGME itself is thread safe.

This macro searches for gpgme-config along the PATH. If you are cross-compiling, it is useful to set the environment variable SYSROOT to the top directory of your target. The macro will then first look for the helper program in the bin directory below that top directory. An absolute directory name must be used for SYSROOT. Finally, if the configure command line option --with-gpgme-prefix is used, only its value is used for the top directory below which the helper script is expected.

You can use the defined Autoconf variables like this in your Makefile.am:

AM_CPPFLAGS = $(GPGME_CFLAGS)
LDADD = $(GPGME_LIBS)

Next: , Previous: , Up: Preparation   [Contents][Index]