### 2.3 Building sources using Automake ¶

You can simply use `PKG_CHECK_MODULES` macro with `pkg-config`:

    PKG_CHECK_MODULES([LIBGCRYPT], [libgcrypt >= 1.11])

Alternatively, instead of using `pkg-config`, for building on an environment with no pkg-config, libgcrypt also provides an extension to Automake that does all the work for you. Please note that it is required to have gpgrt-config from libgpg-error installed in this case.

Macro: AM_PATH_LIBGCRYPT ([minimum-version], [action-if-found], [action-if-not-found]) ¶

  Check whether Libgcrypt (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 `LIBGCRYPT_CFLAGS` to the flags needed for compilation of the program to find the `gcrypt.h` header file, and `LIBGCRYPT_LIBS` to the linker flags needed to link the program to the Libgcrypt library.

  This macro locates for `libgcrypt.pc`, with cross-compile support.

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

    AM_CPPFLAGS = $(LIBGCRYPT_CFLAGS)
    LDADD = $(LIBGCRYPT_LIBS)