1 # gpgme.m4 - autoconf macro to detect GPGME.
2 # Copyright (C) 2002, 2003, 2004, 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 AC_DEFUN([_AM_PATH_GPGME_CONFIG],
16 [ AC_ARG_WITH(gpgme-prefix,
17 AC_HELP_STRING([--with-gpgme-prefix=PFX],
18 [prefix where GPGME is installed (optional)]),
19 gpgme_config_prefix="$withval", gpgme_config_prefix="")
20 if test x"${GPGME_CONFIG}" = x ; then
21 if test x"${gpgme_config_prefix}" != x ; then
22 GPGME_CONFIG="${gpgme_config_prefix}/bin/gpgme-config"
26 if test -x "${SYSROOT}/bin/gpgme-config" ; then
27 GPGME_CONFIG="${SYSROOT}/bin/gpgme-config"
33 AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
39 AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
41 if test "$GPGME_CONFIG" != "no" ; then
42 gpgme_version=`$GPGME_CONFIG --version`
44 gpgme_version_major=`echo $gpgme_version | \
45 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
46 gpgme_version_minor=`echo $gpgme_version | \
47 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
48 gpgme_version_micro=`echo $gpgme_version | \
49 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
53 AC_DEFUN([_AM_PATH_GPGME_CONFIG_HOST_CHECK],
55 gpgme_config_host=`$GPGME_CONFIG --host 2>/dev/null || echo none`
56 if test x"$gpgme_config_host" != xnone ; then
57 if test x"$gpgme_config_host" != x"$host" ; then
60 *** The config script $GPGME_CONFIG was
61 *** built for $gpgme_config_host and thus may not match the
63 *** You may want to use the configure option --with-gpgme-prefix
64 *** to specify a matching config script or use \$SYSROOT.
66 gpg_config_script_warn="$gpg_config_script_warn gpgme"
72 dnl AM_PATH_GPGME([MINIMUM-VERSION,
73 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
74 dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
76 dnl If a prefix option is not used, the config script is first
77 dnl searched in $SYSROOT/bin and then along $PATH. If the used
78 dnl config script does not match the host specification the script
79 dnl is added to the gpg_config_script_warn variable.
81 AC_DEFUN([AM_PATH_GPGME],
82 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
83 tmp=ifelse([$1], ,1:0.4.2,$1)
84 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
85 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
86 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
89 min_gpgme_version="$tmp"
92 AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
94 if test "$GPGME_CONFIG" != "no" ; then
95 req_major=`echo $min_gpgme_version | \
96 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
97 req_minor=`echo $min_gpgme_version | \
98 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
99 req_micro=`echo $min_gpgme_version | \
100 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
101 if test "$gpgme_version_major" -gt "$req_major"; then
104 if test "$gpgme_version_major" -eq "$req_major"; then
105 if test "$gpgme_version_minor" -gt "$req_minor"; then
108 if test "$gpgme_version_minor" -eq "$req_minor"; then
109 if test "$gpgme_version_micro" -ge "$req_micro"; then
117 if test $ok = yes; then
118 # If we have a recent GPGME, we should also check that the
120 if test "$req_gpgme_api" -gt 0 ; then
121 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
122 if test "$tmp" -gt 0 ; then
123 if test "$req_gpgme_api" -ne "$tmp" ; then
129 if test $ok = yes; then
130 GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
131 GPGME_LIBS=`$GPGME_CONFIG --libs`
133 ifelse([$2], , :, [$2])
134 _AM_PATH_GPGME_CONFIG_HOST_CHECK
139 ifelse([$3], , :, [$3])
141 AC_SUBST(GPGME_CFLAGS)
145 dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
146 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
147 dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
148 dnl and GPGME_PTHREAD_LIBS.
150 AC_DEFUN([AM_PATH_GPGME_PTHREAD],
151 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
152 tmp=ifelse([$1], ,1:0.4.2,$1)
153 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
154 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
155 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
158 min_gpgme_version="$tmp"
161 AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
163 if test "$GPGME_CONFIG" != "no" ; then
164 if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
165 req_major=`echo $min_gpgme_version | \
166 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
167 req_minor=`echo $min_gpgme_version | \
168 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
169 req_micro=`echo $min_gpgme_version | \
170 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
171 if test "$gpgme_version_major" -gt "$req_major"; then
174 if test "$gpgme_version_major" -eq "$req_major"; then
175 if test "$gpgme_version_minor" -gt "$req_minor"; then
178 if test "$gpgme_version_minor" -eq "$req_minor"; then
179 if test "$gpgme_version_micro" -ge "$req_micro"; then
188 if test $ok = yes; then
189 # If we have a recent GPGME, we should also check that the
191 if test "$req_gpgme_api" -gt 0 ; then
192 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
193 if test "$tmp" -gt 0 ; then
194 if test "$req_gpgme_api" -ne "$tmp" ; then
200 if test $ok = yes; then
201 GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
202 GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
204 ifelse([$2], , :, [$2])
205 _AM_PATH_GPGME_CONFIG_HOST_CHECK
207 GPGME_PTHREAD_CFLAGS=""
208 GPGME_PTHREAD_LIBS=""
210 ifelse([$3], , :, [$3])
212 AC_SUBST(GPGME_PTHREAD_CFLAGS)
213 AC_SUBST(GPGME_PTHREAD_LIBS)
217 dnl AM_PATH_GPGME_GLIB([MINIMUM-VERSION,
218 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
219 dnl Test for libgpgme-glib and define GPGME_GLIB_CFLAGS and GPGME_GLIB_LIBS.
221 AC_DEFUN([AM_PATH_GPGME_GLIB],
222 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
223 tmp=ifelse([$1], ,1:0.4.2,$1)
224 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
225 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
226 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
229 min_gpgme_version="$tmp"
232 AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
234 if test "$GPGME_CONFIG" != "no" ; then
235 req_major=`echo $min_gpgme_version | \
236 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
237 req_minor=`echo $min_gpgme_version | \
238 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
239 req_micro=`echo $min_gpgme_version | \
240 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
241 if test "$gpgme_version_major" -gt "$req_major"; then
244 if test "$gpgme_version_major" -eq "$req_major"; then
245 if test "$gpgme_version_minor" -gt "$req_minor"; then
248 if test "$gpgme_version_minor" -eq "$req_minor"; then
249 if test "$gpgme_version_micro" -ge "$req_micro"; then
257 if test $ok = yes; then
258 # If we have a recent GPGME, we should also check that the
260 if test "$req_gpgme_api" -gt 0 ; then
261 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
262 if test "$tmp" -gt 0 ; then
263 if test "$req_gpgme_api" -ne "$tmp" ; then
269 if test $ok = yes; then
270 GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
271 GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
273 ifelse([$2], , :, [$2])
274 _AM_PATH_GPGME_CONFIG_HOST_CHECK
279 ifelse([$3], , :, [$3])
281 AC_SUBST(GPGME_GLIB_CFLAGS)
282 AC_SUBST(GPGME_GLIB_LIBS)