1 # gpg-error.m4 - autoconf macro to detect libgpg-error.
2 # Copyright (C) 2002, 2003, 2004, 2011, 2014 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 # Last-changed: 2014-01-24
15 dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
16 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
18 dnl Test for libgpg-error and define GPG_ERROR_CFLAGS, GPG_ERROR_LIBS,
19 dnl GPG_ERROR_MT_CFLAGS, and GPG_ERROR_MT_LIBS. The _MT_ variants are
20 dnl used for programs requireding real multi thread support.
22 AC_DEFUN([AM_PATH_GPG_ERROR],
23 [ AC_REQUIRE([AC_CANONICAL_HOST])
24 gpg_error_config_prefix=""
25 dnl --with-libgpg-error-prefix=PFX is the preferred name for this option,
26 dnl since that is consistent with how our three siblings use the directory/
27 dnl package name in --with-$dir_name-prefix=PFX.
28 AC_ARG_WITH(libgpg-error-prefix,
29 AC_HELP_STRING([--with-libgpg-error-prefix=PFX],
30 [prefix where GPG Error is installed (optional)]),
31 [gpg_error_config_prefix="$withval"])
33 dnl Accept --with-gpg-error-prefix and make it work the same as
34 dnl --with-libgpg-error-prefix above, for backwards compatibility,
35 dnl but do not document this old, inconsistently-named option.
36 AC_ARG_WITH(gpg-error-prefix,,
37 [gpg_error_config_prefix="$withval"])
39 if test x$gpg_error_config_prefix != x ; then
40 if test x${GPG_ERROR_CONFIG+set} != xset ; then
41 GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
45 AC_PATH_TOOL(GPG_ERROR_CONFIG, gpg-error-config, no)
46 min_gpg_error_version=ifelse([$1], ,0.0,$1)
47 AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
49 if test "$GPG_ERROR_CONFIG" != "no" \
50 && test -f "$GPG_ERROR_CONFIG" ; then
51 req_major=`echo $min_gpg_error_version | \
52 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
53 req_minor=`echo $min_gpg_error_version | \
54 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
55 gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
56 major=`echo $gpg_error_config_version | \
57 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
58 minor=`echo $gpg_error_config_version | \
59 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
60 if test "$major" -gt "$req_major"; then
63 if test "$major" -eq "$req_major"; then
64 if test "$minor" -ge "$req_minor"; then
70 if test $ok = yes; then
71 GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
72 GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
73 GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null`
74 GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null`
75 AC_MSG_RESULT([yes ($gpg_error_config_version)])
76 ifelse([$2], , :, [$2])
77 gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none`
78 if test x"$gpg_error_config_host" != xnone ; then
79 if test x"$gpg_error_config_host" != x"$host" ; then
82 *** The config script $GPG_ERROR_CONFIG was
83 *** built for $gpg_error_config_host and thus may not match the
85 *** You may want to use the configure option --with-gpg-error-prefix
86 *** to specify a matching config script.
93 GPG_ERROR_MT_CFLAGS=""
96 ifelse([$3], , :, [$3])
98 AC_SUBST(GPG_ERROR_CFLAGS)
99 AC_SUBST(GPG_ERROR_LIBS)
100 AC_SUBST(GPG_ERROR_MT_CFLAGS)
101 AC_SUBST(GPG_ERROR_MT_LIBS)