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-10-02
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 requireing real multi thread support.
22 dnl If a prefix option is not used, the config script is first
23 dnl searched in $SYSROOT/bin and then along $PATH. If the used
24 dnl config script does not match the host specification the script
25 dnl is added to the gpg_config_script_warn variable.
27 AC_DEFUN([AM_PATH_GPG_ERROR],
28 [ AC_REQUIRE([AC_CANONICAL_HOST])
29 gpg_error_config_prefix=""
30 dnl --with-libgpg-error-prefix=PFX is the preferred name for this option,
31 dnl since that is consistent with how our three siblings use the directory/
32 dnl package name in --with-$dir_name-prefix=PFX.
33 AC_ARG_WITH(libgpg-error-prefix,
34 AC_HELP_STRING([--with-libgpg-error-prefix=PFX],
35 [prefix where GPG Error is installed (optional)]),
36 [gpg_error_config_prefix="$withval"])
38 dnl Accept --with-gpg-error-prefix and make it work the same as
39 dnl --with-libgpg-error-prefix above, for backwards compatibility,
40 dnl but do not document this old, inconsistently-named option.
41 AC_ARG_WITH(gpg-error-prefix,,
42 [gpg_error_config_prefix="$withval"])
44 if test x"${GPG_ERROR_CONFIG}" = x ; then
45 if test x"${gpg_error_config_prefix}" != x ; then
46 GPG_ERROR_CONFIG="${gpg_error_config_prefix}/bin/gpg-error-config"
50 if test -x "${SYSROOT}/bin/gpg-error-config" ; then
51 GPG_ERROR_CONFIG="${SYSROOT}/bin/gpg-error-config"
57 AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
63 AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
64 min_gpg_error_version=ifelse([$1], ,0.0,$1)
65 AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
67 if test "$GPG_ERROR_CONFIG" != "no" \
68 && test -f "$GPG_ERROR_CONFIG" ; then
69 req_major=`echo $min_gpg_error_version | \
70 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
71 req_minor=`echo $min_gpg_error_version | \
72 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
73 gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
74 major=`echo $gpg_error_config_version | \
75 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
76 minor=`echo $gpg_error_config_version | \
77 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
78 if test "$major" -gt "$req_major"; then
81 if test "$major" -eq "$req_major"; then
82 if test "$minor" -ge "$req_minor"; then
88 if test $ok = yes; then
89 GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
90 GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
91 GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null`
92 GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null`
93 AC_MSG_RESULT([yes ($gpg_error_config_version)])
94 ifelse([$2], , :, [$2])
95 gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none`
96 if test x"$gpg_error_config_host" != xnone ; then
97 if test x"$gpg_error_config_host" != x"$host" ; then
100 *** The config script $GPG_ERROR_CONFIG was
101 *** built for $gpg_error_config_host and thus may not match the
103 *** You may want to use the configure option --with-gpg-error-prefix
104 *** to specify a matching config script or use \$SYSROOT.
106 gpg_config_script_warn="$gpg_config_script_warn libgpg-error"
112 GPG_ERROR_MT_CFLAGS=""
115 ifelse([$3], , :, [$3])
117 AC_SUBST(GPG_ERROR_CFLAGS)
118 AC_SUBST(GPG_ERROR_LIBS)
119 AC_SUBST(GPG_ERROR_MT_CFLAGS)
120 AC_SUBST(GPG_ERROR_MT_LIBS)