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 AS_HELP_STRING([--with-gpgme-prefix=PFX],[prefix where GPGME is installed (optional)]),
16 gpgme_config_prefix="$withval", gpgme_config_prefix="")
17 if test "x$gpgme_config_prefix" != x ; then
18 GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
20 AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
22 if test "$GPGME_CONFIG" != "no" ; then
23 gpgme_version=`$GPGME_CONFIG --version`
25 gpgme_version_major=`echo $gpgme_version | \
26 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
27 gpgme_version_minor=`echo $gpgme_version | \
28 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
29 gpgme_version_micro=`echo $gpgme_version | \
30 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
33 dnl AM_PATH_GPGME([MINIMUM-VERSION,
34 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
35 dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
37 AC_DEFUN([AM_PATH_GPGME],
38 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
39 tmp=ifelse([$1], ,1:0.4.2,$1)
40 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
41 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
42 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
45 min_gpgme_version="$tmp"
48 AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
50 if test "$GPGME_CONFIG" != "no" ; then
51 req_major=`echo $min_gpgme_version | \
52 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
53 req_minor=`echo $min_gpgme_version | \
54 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
55 req_micro=`echo $min_gpgme_version | \
56 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
57 if test "$gpgme_version_major" -gt "$req_major"; then
60 if test "$gpgme_version_major" -eq "$req_major"; then
61 if test "$gpgme_version_minor" -gt "$req_minor"; then
64 if test "$gpgme_version_minor" -eq "$req_minor"; then
65 if test "$gpgme_version_micro" -ge "$req_micro"; then
73 if test $ok = yes; then
74 # If we have a recent GPGME, we should also check that the
76 if test "$req_gpgme_api" -gt 0 ; then
77 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
78 if test "$tmp" -gt 0 ; then
79 if test "$req_gpgme_api" -ne "$tmp" ; then
85 if test $ok = yes; then
86 GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
87 GPGME_LIBS=`$GPGME_CONFIG --libs`
89 ifelse([$2], , :, [$2])
94 ifelse([$3], , :, [$3])
96 AC_SUBST(GPGME_CFLAGS)
100 dnl AM_PATH_GPGME_PTH([MINIMUM-VERSION,
101 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
102 dnl Test for libgpgme and define GPGME_PTH_CFLAGS and GPGME_PTH_LIBS.
104 AC_DEFUN([AM_PATH_GPGME_PTH],
105 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
106 tmp=ifelse([$1], ,1:0.4.2,$1)
107 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
108 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
109 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
112 min_gpgme_version="$tmp"
115 AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version)
117 if test "$GPGME_CONFIG" != "no" ; then
118 if `$GPGME_CONFIG --thread=pth 2> /dev/null` ; then
119 req_major=`echo $min_gpgme_version | \
120 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
121 req_minor=`echo $min_gpgme_version | \
122 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
123 req_micro=`echo $min_gpgme_version | \
124 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
125 if test "$gpgme_version_major" -gt "$req_major"; then
128 if test "$gpgme_version_major" -eq "$req_major"; then
129 if test "$gpgme_version_minor" -gt "$req_minor"; then
132 if test "$gpgme_version_minor" -eq "$req_minor"; then
133 if test "$gpgme_version_micro" -ge "$req_micro"; then
142 if test $ok = yes; then
143 # If we have a recent GPGME, we should also check that the
145 if test "$req_gpgme_api" -gt 0 ; then
146 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
147 if test "$tmp" -gt 0 ; then
148 if test "$req_gpgme_api" -ne "$tmp" ; then
154 if test $ok = yes; then
155 GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags`
156 GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs`
158 ifelse([$2], , :, [$2])
163 ifelse([$3], , :, [$3])
165 AC_SUBST(GPGME_PTH_CFLAGS)
166 AC_SUBST(GPGME_PTH_LIBS)
169 dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
170 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
171 dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
172 dnl and GPGME_PTHREAD_LIBS.
174 AC_DEFUN([AM_PATH_GPGME_PTHREAD],
175 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
176 tmp=ifelse([$1], ,1:0.4.2,$1)
177 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
178 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
179 min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
182 min_gpgme_version="$tmp"
185 AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
187 if test "$GPGME_CONFIG" != "no" ; then
188 if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
189 req_major=`echo $min_gpgme_version | \
190 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
191 req_minor=`echo $min_gpgme_version | \
192 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
193 req_micro=`echo $min_gpgme_version | \
194 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
195 if test "$gpgme_version_major" -gt "$req_major"; then
198 if test "$gpgme_version_major" -eq "$req_major"; then
199 if test "$gpgme_version_minor" -gt "$req_minor"; then
202 if test "$gpgme_version_minor" -eq "$req_minor"; then
203 if test "$gpgme_version_micro" -ge "$req_micro"; then
212 if test $ok = yes; then
213 # If we have a recent GPGME, we should also check that the
215 if test "$req_gpgme_api" -gt 0 ; then
216 tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
217 if test "$tmp" -gt 0 ; then
218 if test "$req_gpgme_api" -ne "$tmp" ; then
224 if test $ok = yes; then
225 GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
226 GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
228 ifelse([$2], , :, [$2])
230 GPGME_PTHREAD_CFLAGS=""
231 GPGME_PTHREAD_LIBS=""
233 ifelse([$3], , :, [$3])
235 AC_SUBST(GPGME_PTHREAD_CFLAGS)
236 AC_SUBST(GPGME_PTHREAD_LIBS)