1 # gpgme.m4 - autoconf macro to detect GPGME.
2 # Copyright (C) 2002, 2003, 2004 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.
13 AC_DEFUN([_AM_PATH_GPGME_CONFIG],
14 [ AC_ARG_WITH(gpgme-prefix,
15 AC_HELP_STRING([--with-gpgme-prefix=PFX],
16 [prefix where GPGME is installed (optional)]),
17 gpgme_config_prefix="$withval", gpgme_config_prefix="")
18 if test "x$gpgme_config_prefix" != x ; then
19 GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
21 AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
23 if test "$GPGME_CONFIG" != "no" ; then
24 gpgme_version=`$GPGME_CONFIG --version`
26 gpgme_version_major=`echo $gpgme_version | \
27 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
28 gpgme_version_minor=`echo $gpgme_version | \
29 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
30 gpgme_version_micro=`echo $gpgme_version | \
31 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
34 dnl AM_PATH_GPGME([MINIMUM-VERSION,
35 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
36 dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
38 AC_DEFUN([AM_PATH_GPGME],
39 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
40 tmp=ifelse([$1], ,1:0.4.2,$1)
41 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
42 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
43 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
46 min_gpgme_version="$tmp"
49 AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
51 if test "$GPGME_CONFIG" != "no" ; then
52 req_major=`echo $min_gpgme_version | \
53 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
54 req_minor=`echo $min_gpgme_version | \
55 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
56 req_micro=`echo $min_gpgme_version | \
57 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
58 if test "$gpgme_version_major" -gt "$req_major"; then
61 if test "$gpgme_version_major" -eq "$req_major"; then
62 if test "$gpgme_version_minor" -gt "$req_minor"; then
65 if test "$gpgme_version_minor" -eq "$req_minor"; then
66 if test "$gpgme_version_micro" -ge "$req_micro"; then
74 if test $ok = yes; then
75 # If we have a recent GPGME, we should also check that the
77 if test "$req_gpgme_api" -gt 0 ; then
78 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
79 if test "$tmp" -gt 0 ; then
80 if test "$req_gpgme_api" -ne "$tmp" ; then
86 if test $ok = yes; then
87 GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
88 GPGME_LIBS=`$GPGME_CONFIG --libs`
90 ifelse([$2], , :, [$2])
95 ifelse([$3], , :, [$3])
97 AC_SUBST(GPGME_CFLAGS)
101 dnl AM_PATH_GPGME_PTH([MINIMUM-VERSION,
102 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
103 dnl Test for libgpgme and define GPGME_PTH_CFLAGS and GPGME_PTH_LIBS.
105 AC_DEFUN([AM_PATH_GPGME_PTH],
106 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
107 tmp=ifelse([$1], ,1:0.4.2,$1)
108 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
109 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
110 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
113 min_gpgme_version="$tmp"
116 AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version)
118 if test "$GPGME_CONFIG" != "no" ; then
119 if `$GPGME_CONFIG --thread=pth 2> /dev/null` ; then
120 req_major=`echo $min_gpgme_version | \
121 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
122 req_minor=`echo $min_gpgme_version | \
123 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
124 req_micro=`echo $min_gpgme_version | \
125 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
126 if test "$gpgme_version_major" -gt "$req_major"; then
129 if test "$gpgme_version_major" -eq "$req_major"; then
130 if test "$gpgme_version_minor" -gt "$req_minor"; then
133 if test "$gpgme_version_minor" -eq "$req_minor"; then
134 if test "$gpgme_version_micro" -ge "$req_micro"; then
143 if test $ok = yes; then
144 # If we have a recent GPGME, we should also check that the
146 if test "$req_gpgme_api" -gt 0 ; then
147 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
148 if test "$tmp" -gt 0 ; then
149 if test "$req_gpgme_api" -ne "$tmp" ; then
155 if test $ok = yes; then
156 GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags`
157 GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs`
159 ifelse([$2], , :, [$2])
164 ifelse([$3], , :, [$3])
166 AC_SUBST(GPGME_PTH_CFLAGS)
167 AC_SUBST(GPGME_PTH_LIBS)
170 dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
171 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
172 dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
173 dnl and GPGME_PTHREAD_LIBS.
175 AC_DEFUN([AM_PATH_GPGME_PTHREAD],
176 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
177 tmp=ifelse([$1], ,1:0.4.2,$1)
178 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
179 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
180 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
183 min_gpgme_version="$tmp"
186 AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
188 if test "$GPGME_CONFIG" != "no" ; then
189 if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
190 req_major=`echo $min_gpgme_version | \
191 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
192 req_minor=`echo $min_gpgme_version | \
193 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
194 req_micro=`echo $min_gpgme_version | \
195 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
196 if test "$gpgme_version_major" -gt "$req_major"; then
199 if test "$gpgme_version_major" -eq "$req_major"; then
200 if test "$gpgme_version_minor" -gt "$req_minor"; then
203 if test "$gpgme_version_minor" -eq "$req_minor"; then
204 if test "$gpgme_version_micro" -ge "$req_micro"; then
213 if test $ok = yes; then
214 # If we have a recent GPGME, we should also check that the
216 if test "$req_gpgme_api" -gt 0 ; then
217 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
218 if test "$tmp" -gt 0 ; then
219 if test "$req_gpgme_api" -ne "$tmp" ; then
225 if test $ok = yes; then
226 GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
227 GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
229 ifelse([$2], , :, [$2])
231 GPGME_PTHREAD_CFLAGS=""
232 GPGME_PTHREAD_LIBS=""
234 ifelse([$3], , :, [$3])
236 AC_SUBST(GPGME_PTHREAD_CFLAGS)
237 AC_SUBST(GPGME_PTHREAD_LIBS)
241 dnl AM_PATH_GPGME_GLIB([MINIMUM-VERSION,
242 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
243 dnl Test for libgpgme-glib and define GPGME_GLIB_CFLAGS and GPGME_GLIB_LIBS.
245 AC_DEFUN([AM_PATH_GPGME_GLIB],
246 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
247 tmp=ifelse([$1], ,1:0.4.2,$1)
248 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
249 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
250 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
253 min_gpgme_version="$tmp"
256 AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
258 if test "$GPGME_CONFIG" != "no" ; then
259 req_major=`echo $min_gpgme_version | \
260 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
261 req_minor=`echo $min_gpgme_version | \
262 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
263 req_micro=`echo $min_gpgme_version | \
264 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
265 if test "$gpgme_version_major" -gt "$req_major"; then
268 if test "$gpgme_version_major" -eq "$req_major"; then
269 if test "$gpgme_version_minor" -gt "$req_minor"; then
272 if test "$gpgme_version_minor" -eq "$req_minor"; then
273 if test "$gpgme_version_micro" -ge "$req_micro"; then
281 if test $ok = yes; then
282 # If we have a recent GPGME, we should also check that the
284 if test "$req_gpgme_api" -gt 0 ; then
285 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
286 if test "$tmp" -gt 0 ; then
287 if test "$req_gpgme_api" -ne "$tmp" ; then
293 if test $ok = yes; then
294 GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
295 GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
297 ifelse([$2], , :, [$2])
302 ifelse([$3], , :, [$3])
304 AC_SUBST(GPGME_GLIB_CFLAGS)
305 AC_SUBST(GPGME_GLIB_LIBS)