]> git.llucax.com Git - software/mutt-debian.git/blob - m4/gpgme.m4
new patch to do a better debug, some minor changes to hyphen-as-minus.patch
[software/mutt-debian.git] / m4 / gpgme.m4
1 # gpgme.m4 - autoconf macro to detect GPGME.
2 # Copyright (C) 2002, 2003, 2004 g10 Code GmbH
3 #
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.
7 #
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.
11
12
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"
20   fi
21   AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
22
23   if test "$GPGME_CONFIG" != "no" ; then
24     gpgme_version=`$GPGME_CONFIG --version`
25   fi
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/'`
32 ])
33
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.
37 dnl
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/'`
44   else
45      req_gpgme_api=0
46      min_gpgme_version="$tmp"
47   fi
48
49   AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
50   ok=no
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
59         ok=yes
60     else 
61         if test "$gpgme_version_major" -eq "$req_major"; then
62             if test "$gpgme_version_minor" -gt "$req_minor"; then
63                ok=yes
64             else
65                if test "$gpgme_version_minor" -eq "$req_minor"; then
66                    if test "$gpgme_version_micro" -ge "$req_micro"; then
67                      ok=yes
68                    fi
69                fi
70             fi
71         fi
72     fi
73   fi
74   if test $ok = yes; then
75      # If we have a recent GPGME, we should also check that the
76      # API is compatible.
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
81              ok=no
82            fi
83         fi
84      fi
85   fi
86   if test $ok = yes; then
87     GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
88     GPGME_LIBS=`$GPGME_CONFIG --libs`
89     AC_MSG_RESULT(yes)
90     ifelse([$2], , :, [$2])
91   else
92     GPGME_CFLAGS=""
93     GPGME_LIBS=""
94     AC_MSG_RESULT(no)
95     ifelse([$3], , :, [$3])
96   fi
97   AC_SUBST(GPGME_CFLAGS)
98   AC_SUBST(GPGME_LIBS)
99 ])
100
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.
104 dnl
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/'`
111   else
112      req_gpgme_api=0
113      min_gpgme_version="$tmp"
114   fi
115
116   AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version)
117   ok=no
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
127         ok=yes
128       else 
129         if test "$gpgme_version_major" -eq "$req_major"; then
130           if test "$gpgme_version_minor" -gt "$req_minor"; then
131             ok=yes
132           else
133             if test "$gpgme_version_minor" -eq "$req_minor"; then
134               if test "$gpgme_version_micro" -ge "$req_micro"; then
135                 ok=yes
136               fi
137             fi
138           fi
139         fi
140       fi
141     fi
142   fi
143   if test $ok = yes; then
144      # If we have a recent GPGME, we should also check that the
145      # API is compatible.
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
150              ok=no
151            fi
152         fi
153      fi
154   fi
155   if test $ok = yes; then
156     GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags`
157     GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs`
158     AC_MSG_RESULT(yes)
159     ifelse([$2], , :, [$2])
160   else
161     GPGME_PTH_CFLAGS=""
162     GPGME_PTH_LIBS=""
163     AC_MSG_RESULT(no)
164     ifelse([$3], , :, [$3])
165   fi
166   AC_SUBST(GPGME_PTH_CFLAGS)
167   AC_SUBST(GPGME_PTH_LIBS)
168 ])
169
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.
174 dnl
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/'`
181   else
182      req_gpgme_api=0
183      min_gpgme_version="$tmp"
184   fi
185
186   AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
187   ok=no
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
197         ok=yes
198       else 
199         if test "$gpgme_version_major" -eq "$req_major"; then
200           if test "$gpgme_version_minor" -gt "$req_minor"; then
201             ok=yes
202           else
203             if test "$gpgme_version_minor" -eq "$req_minor"; then
204               if test "$gpgme_version_micro" -ge "$req_micro"; then
205                 ok=yes
206               fi
207             fi
208           fi
209         fi
210       fi
211     fi
212   fi
213   if test $ok = yes; then
214      # If we have a recent GPGME, we should also check that the
215      # API is compatible.
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
220              ok=no
221            fi
222         fi
223      fi
224   fi
225   if test $ok = yes; then
226     GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
227     GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
228     AC_MSG_RESULT(yes)
229     ifelse([$2], , :, [$2])
230   else
231     GPGME_PTHREAD_CFLAGS=""
232     GPGME_PTHREAD_LIBS=""
233     AC_MSG_RESULT(no)
234     ifelse([$3], , :, [$3])
235   fi
236   AC_SUBST(GPGME_PTHREAD_CFLAGS)
237   AC_SUBST(GPGME_PTHREAD_LIBS)
238 ])
239
240
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.
244 dnl
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/'`
251   else
252      req_gpgme_api=0
253      min_gpgme_version="$tmp"
254   fi
255
256   AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
257   ok=no
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
266         ok=yes
267     else 
268         if test "$gpgme_version_major" -eq "$req_major"; then
269             if test "$gpgme_version_minor" -gt "$req_minor"; then
270                ok=yes
271             else
272                if test "$gpgme_version_minor" -eq "$req_minor"; then
273                    if test "$gpgme_version_micro" -ge "$req_micro"; then
274                      ok=yes
275                    fi
276                fi
277             fi
278         fi
279     fi
280   fi
281   if test $ok = yes; then
282      # If we have a recent GPGME, we should also check that the
283      # API is compatible.
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
288              ok=no
289            fi
290         fi
291      fi
292   fi
293   if test $ok = yes; then
294     GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
295     GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
296     AC_MSG_RESULT(yes)
297     ifelse([$2], , :, [$2])
298   else
299     GPGME_GLIB_CFLAGS=""
300     GPGME_GLIB_LIBS=""
301     AC_MSG_RESULT(no)
302     ifelse([$3], , :, [$3])
303   fi
304   AC_SUBST(GPGME_GLIB_CFLAGS)
305   AC_SUBST(GPGME_GLIB_LIBS)
306 ])
307