1 # gpg-error.m4 - autoconf macro to detect libgpg-error.
2 # Copyright (C) 2002, 2003, 2004, 2011 g10 Code GmbH
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
8 # This file is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
13 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
14 dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
16 AC_DEFUN([AM_PATH_GPG_ERROR],
17 [ AC_REQUIRE([AC_CANONICAL_HOST])
18 AC_ARG_WITH(gpg-error-prefix,
19 AC_HELP_STRING([--with-gpg-error-prefix=PFX],
20 [prefix where GPG Error is installed (optional)]),
21 gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
22 if test x$gpg_error_config_prefix != x ; then
23 if test x${GPG_ERROR_CONFIG+set} != xset ; then
24 GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
28 AC_PATH_TOOL(GPG_ERROR_CONFIG, gpg-error-config, no)
29 min_gpg_error_version=ifelse([$1], ,0.0,$1)
30 AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
32 if test "$GPG_ERROR_CONFIG" != "no" \
33 && test -f "$GPG_ERROR_CONFIG" ; then
34 req_major=`echo $min_gpg_error_version | \
35 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
36 req_minor=`echo $min_gpg_error_version | \
37 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
38 gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
39 major=`echo $gpg_error_config_version | \
40 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
41 minor=`echo $gpg_error_config_version | \
42 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
43 if test "$major" -gt "$req_major"; then
46 if test "$major" -eq "$req_major"; then
47 if test "$minor" -ge "$req_minor"; then
53 if test $ok = yes; then
54 GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
55 GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
56 AC_MSG_RESULT([yes ($gpg_error_config_version)])
57 ifelse([$2], , :, [$2])
58 gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none`
59 if test x"$gpg_error_config_host" != xnone ; then
60 if test x"$gpg_error_config_host" != x"$host" ; then
63 *** The config script $GPG_ERROR_CONFIG was
64 *** built for $gpg_error_config_host and thus may not match the
66 *** You may want to use the configure option --with-gpg-error-prefix
67 *** to specify a matching config script.
75 ifelse([$3], , :, [$3])
77 AC_SUBST(GPG_ERROR_CFLAGS)
78 AC_SUBST(GPG_ERROR_LIBS)