* acinclude.m4: Add AM_PATH_GPG_ERROR.
[gpgme.git] / acinclude.m4
1 dnl Macros to configure gpgme
2
3 dnl GNUPG_FIX_HDR_VERSION(FILE, NAME)
4 dnl Make the version number in gcrypt/gcrypt.h the same as the one here.
5 dnl (this is easier than to have a .in file just for one substitution)
6 dnl We must use a temp file in the current directory because make distcheck 
7 dnl install all sourcefiles RO.
8 dnl (wk 2001-12-18)
9 AC_DEFUN(GNUPG_FIX_HDR_VERSION,
10   [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > fixhdr.tmp
11     if cmp -s $srcdir/$1 fixhdr.tmp 2>/dev/null; then
12         rm -f fixhdr.tmp
13     else
14         rm -f $srcdir/$1
15         if mv fixhdr.tmp $srcdir/$1 ; then
16             :
17         else
18             AC_MSG_ERROR([[
19 ***
20 *** Failed to fix the version string macro $2 in $1.
21 *** The old file has been saved as fixhdr.tmp
22 ***]])
23         fi
24         AC_MSG_WARN([fixed the $2 macro in $1])
25     fi
26   ])
27
28
29 dnl ##
30 dnl ##  GNU Pth - The GNU Portable Threads
31 dnl ##  Copyright (c) 1999-2002 Ralf S. Engelschall <rse@engelschall.com>
32 dnl ##
33 dnl ##  This file is part of GNU Pth, a non-preemptive thread scheduling
34 dnl ##  library which can be found at http://www.gnu.org/software/pth/.
35 dnl ##
36 dnl ##  This library is free software; you can redistribute it and/or
37 dnl ##  modify it under the terms of the GNU Lesser General Public
38 dnl ##  License as published by the Free Software Foundation; either
39 dnl ##  version 2.1 of the License, or (at your option) any later version.
40 dnl ##
41 dnl ##  This library is distributed in the hope that it will be useful,
42 dnl ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
43 dnl ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 dnl ##  Lesser General Public License for more details.
45 dnl ##
46 dnl ##  You should have received a copy of the GNU Lesser General Public
47 dnl ##  License along with this library; if not, write to the Free Software
48 dnl ##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
49 dnl ##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
50 dnl ##
51 dnl ##  pth.m4: Autoconf macro for locating GNU Pth from within
52 dnl ##          configure.in of third-party software packages
53 dnl ##
54
55 dnl ##
56 dnl ##  Synopsis:
57 dnl ##  AC_CHECK_PTH([MIN-VERSION [,          # minimum Pth version, e.g. 1.2.0
58 dnl ##                DEFAULT-WITH-PTH [,     # default value for --with-pth option
59 dnl ##                DEFAULT-WITH-PTH-TEST [,# default value for --with-pth-test option
60 dnl ##                EXTEND-VARS [,          # whether CFLAGS/LDFLAGS/etc are extended
61 dnl ##                ACTION-IF-FOUND [,      # action to perform if Pth was found
62 dnl ##                ACTION-IF-NOT-FOUND     # action to perform if Pth was not found
63 dnl ##                ]]]]]])
64 dnl ##  Examples:
65 dnl ##  AC_CHECK_PTH(1.2.0)
66 dnl ##  AC_CHECK_PTH(1.2.0,,,no,CFLAGS="$CFLAGS -DHAVE_PTH $PTH_CFLAGS")
67 dnl ##  AC_CHECK_PTH(1.2.0,yes,yes,yes,CFLAGS="$CFLAGS -DHAVE_PTH")
68 dnl ##
69 dnl
70 dnl #   auxilliary macros
71 AC_DEFUN(_AC_PTH_ERROR, [dnl
72 AC_MSG_RESULT([*FAILED*])
73 dnl define(_ac_pth_line,dnl
74 dnl "+------------------------------------------------------------------------+")
75 dnl echo " _ac_pth_line" 1>&2
76 cat <<EOT | sed -e 's/^[[       ]]*/ | /' -e 's/>>/  /' 1>&2
77 $1
78 EOT
79 dnl echo " _ac_pth_line" 1>&2
80 dnl undefine(_ac_pth_line)
81 exit 1
82 ])
83 AC_DEFUN(_AC_PTH_VERBOSE, [dnl
84 if test ".$verbose" = .yes; then
85     AC_MSG_RESULT([  $1])
86 fi
87 ])
88 dnl #   the user macro
89 AC_DEFUN(AC_CHECK_PTH, [dnl
90 dnl
91 dnl #   prerequisites
92 AC_REQUIRE([AC_PROG_CC])dnl
93 AC_REQUIRE([AC_PROG_CPP])dnl
94 dnl
95 PTH_CPPFLAGS=''
96 PTH_CFLAGS=''
97 PTH_LDFLAGS=''
98 PTH_LIBS=''
99 AC_SUBST(PTH_CPPFLAGS)
100 AC_SUBST(PTH_CFLAGS)
101 AC_SUBST(PTH_LDFLAGS)
102 AC_SUBST(PTH_LIBS)
103 dnl #   command line options
104 AC_MSG_CHECKING(for GNU Pth)
105 _AC_PTH_VERBOSE([])
106 AC_ARG_WITH(pth,dnl
107 [  --with-pth[=ARG]        Build with GNU Pth Library  (default=]ifelse([$2],,yes,$2)[)],dnl
108 ,dnl
109 with_pth="ifelse([$2],,yes,$2)"
110 )dnl
111 AC_ARG_WITH(pth-test,dnl
112 [  --with-pth-test         Perform GNU Pth Sanity Test (default=]ifelse([$3],,yes,$3)[)],dnl
113 ,dnl
114 with_pth_test="ifelse([$3],,yes,$3)"
115 )dnl
116 _AC_PTH_VERBOSE([+ Command Line Options:])
117 _AC_PTH_VERBOSE([    o --with-pth=$with_pth])
118 _AC_PTH_VERBOSE([    o --with-pth-test=$with_pth_test])
119 dnl
120 dnl #   configuration
121 if test ".$with_pth" != .no; then
122     _pth_subdir=no
123     _pth_subdir_opts=''
124     case "$with_pth" in
125         subdir:* )
126             _pth_subdir=yes
127             changequote(, )dnl
128             _pth_subdir_opts=`echo $with_pth | sed -e 's/^subdir:[^     ]*[     ]*//'`
129             with_pth=`echo $with_pth | sed -e 's/^subdir:\([^   ]*\).*$/\1/'`
130             changequote([, ])dnl
131             ;;
132     esac
133     _pth_version=""
134     _pth_location=""
135     _pth_type=""
136     _pth_cppflags=""
137     _pth_cflags=""
138     _pth_ldflags=""
139     _pth_libs=""
140     if test ".$with_pth" = .yes; then
141         #   via config script in $PATH
142         changequote(, )dnl
143         _pth_version=`(pth-config --version) 2>/dev/null |\
144                       sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
145         changequote([, ])dnl
146         if test ".$_pth_version" != .; then
147             _pth_location=`pth-config --prefix`
148             _pth_type='installed'
149             _pth_cppflags=`pth-config --cflags`
150             _pth_cflags=`pth-config --cflags`
151             _pth_ldflags=`pth-config --ldflags`
152             _pth_libs=`pth-config --libs`
153         fi
154     elif test -d "$with_pth"; then
155         with_pth=`echo $with_pth | sed -e 's;/*$;;'`
156         _pth_found=no
157         #   via locally included source tree
158         if test ".$_pth_subdir" = .yes; then
159             _pth_location="$with_pth"
160             _pth_type='local'
161             _pth_cppflags="-I$with_pth"
162             _pth_cflags="-I$with_pth"
163             if test -f "$with_pth/ltconfig"; then
164                 _pth_ldflags="-L$with_pth/.libs"
165             else
166                 _pth_ldflags="-L$with_pth"
167             fi
168             _pth_libs="-lpth"
169             changequote(, )dnl
170             _pth_version=`grep '^const char PTH_Hello' $with_pth/pth_vers.c |\
171                           sed -e 's;^.*Version[         ]*\([0-9]*\.[0-9]*[.ab][0-9]*\)[        ].*$;\1;'`
172             changequote([, ])dnl
173             _pth_found=yes
174             ac_configure_args="$ac_configure_args --enable-subdir $_pth_subdir_opts"
175             with_pth_test=no
176         fi
177         #   via config script under a specified directory
178         #   (a standard installation, but not a source tree)
179         if test ".$_pth_found" = .no; then
180             for _dir in $with_pth/bin $with_pth; do
181                 if test -f "$_dir/pth-config"; then
182                     test -f "$_dir/pth-config.in" && continue # pth-config in source tree!
183                     changequote(, )dnl
184                     _pth_version=`($_dir/pth-config --version) 2>/dev/null |\
185                                   sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
186                     changequote([, ])dnl
187                     if test ".$_pth_version" != .; then
188                         _pth_location=`$_dir/pth-config --prefix`
189                         _pth_type="installed"
190                         _pth_cppflags=`$_dir/pth-config --cflags`
191                         _pth_cflags=`$_dir/pth-config --cflags`
192                         _pth_ldflags=`$_dir/pth-config --ldflags`
193                         _pth_libs=`$_dir/pth-config --libs`
194                         _pth_found=yes
195                         break
196                     fi
197                 fi
198             done
199         fi
200         #   in any subarea under a specified directory
201         #   (either a special installation or a Pth source tree)
202         if test ".$_pth_found" = .no; then
203             changequote(, )dnl
204             _pth_found=0
205             for _file in x `find $with_pth -name "pth.h" -type f -print`; do
206                 test .$_file = .x && continue
207                 _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
208                 _pth_version=`($_dir/pth-config --version) 2>/dev/null |\
209                               sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
210                 if test ".$_pth_version" = .; then
211                     _pth_version=`grep '^#define PTH_VERSION_STR' $_file |\
212                                   sed -e 's;^#define[   ]*PTH_VERSION_STR[      ]*"\([0-9]*\.[0-9]*[.ab][0-9]*\)[       ].*$;\1;'`
213                 fi
214                 _pth_cppflags="-I$_dir"
215                 _pth_cflags="-I$_dir"
216                 _pth_found=`expr $_pth_found + 1`
217             done
218             for _file in x `find $with_pth -name "libpth.[aso]" -type f -print`; do
219                 test .$_file = .x && continue
220                 _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
221                 _pth_ldflags="-L$_dir"
222                 _pth_libs="-lpth"
223                 _pth_found=`expr $_pth_found + 1`
224             done
225             changequote([, ])dnl
226             if test ".$_pth_found" = .2; then
227                 _pth_location="$with_pth"
228                 _pth_type="uninstalled"
229             else
230                 _pth_version=''
231             fi
232         fi
233     fi
234     _AC_PTH_VERBOSE([+ Determined Location:])
235     _AC_PTH_VERBOSE([    o path: $_pth_location])
236     _AC_PTH_VERBOSE([    o type: $_pth_type])
237     if test ".$_pth_version" = .; then
238         with_pth=no
239     else
240 dnl        if test ".$with_pth" != .yes; then
241 dnl             _AC_PTH_ERROR([dnl
242 dnl             Unable to locate GNU Pth under $with_pth.
243 dnl             Please specify the correct path to either a GNU Pth installation tree
244 dnl             (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in
245 dnl             the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a
246 dnl             path to a pth-X.Y.Z/ directory; but make sure the package is already
247 dnl             built, i.e., the "configure; make" step was already performed there).])
248 dnl        else
249 dnl             _AC_PTH_ERROR([dnl
250 dnl             Unable to locate GNU Pth in any system-wide location (see \$PATH).
251 dnl             Please specify the correct path to either a GNU Pth installation tree
252 dnl             (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in
253 dnl             the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a
254 dnl             path to a pth-X.Y.Z/ directory; but make sure the package is already
255 dnl             built, i.e., the "configure; make" step was already performed there).])
256 dnl        fi
257 dnl    fi
258     dnl #
259     dnl #  Check whether the found version is sufficiently new
260     dnl #
261     _req_version="ifelse([$1],,1.0.0,$1)"
262     for _var in _pth_version _req_version; do
263         eval "_val=\"\$${_var}\""
264         _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
265         _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
266         _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
267         _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
268         case $_rtype in
269             "a" ) _rtype=0 ;;
270             "b" ) _rtype=1 ;;
271             "." ) _rtype=2 ;;
272         esac
273         _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
274               "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
275         eval "${_var}_hex=\"\$_hex\""
276     done
277     _AC_PTH_VERBOSE([+ Determined Versions:])
278     _AC_PTH_VERBOSE([    o existing: $_pth_version -> 0x$_pth_version_hex])
279     _AC_PTH_VERBOSE([    o required: $_req_version -> 0x$_req_version_hex])
280     _ok=0
281     if test ".$_pth_version_hex" != .; then
282         if test ".$_req_version_hex" != .; then
283             if test $_pth_version_hex -ge $_req_version_hex; then
284                 _ok=1
285             fi
286         fi
287     fi
288     if test ".$_ok" = .0; then
289         _AC_PTH_ERROR([dnl
290         Found Pth version $_pth_version, but required at least version $_req_version.
291         Upgrade Pth under $_pth_location to $_req_version or higher first, please.])
292     fi
293     dnl #
294     dnl #   Perform Pth Sanity Compile Check
295     dnl #
296     if test ".$with_pth_test" = .yes; then
297         _ac_save_CPPFLAGS="$CPPFLAGS"
298         _ac_save_CFLAGS="$CFLAGS"
299         _ac_save_LDFLAGS="$LDFLAGS"
300         _ac_save_LIBS="$LIBS"
301         CPPFLAGS="$CPPFLAGS $_pth_cppflags"
302         CFLAGS="$CFLAGS $_pth_cflags"
303         LDFLAGS="$LDFLAGS $_pth_ldflags"
304         LIBS="$LIBS $_pth_libs"
305         _AC_PTH_VERBOSE([+ Test Build Environment:])
306         _AC_PTH_VERBOSE([    o CPPFLAGS=\"$CPPFLAGS\"])
307         _AC_PTH_VERBOSE([    o CFLAGS=\"$CFLAGS\"])
308         _AC_PTH_VERBOSE([    o LDFLAGS=\"$LDFLAGS\"])
309         _AC_PTH_VERBOSE([    o LIBS=\"$LIBS\"])
310         cross_compile=no
311         define(_code1, [dnl
312         #include <stdio.h>
313         #include <pth.h>
314         ])
315         define(_code2, [dnl
316         int main(int argc, char *argv[])
317         {
318             FILE *fp;
319             if (!(fp = fopen("conftestval", "w")))
320                 exit(1);
321             fprintf(fp, "hmm");
322             fclose(fp);
323             pth_init();
324             pth_kill();
325             if (!(fp = fopen("conftestval", "w")))
326                 exit(1);
327             fprintf(fp, "yes");
328             fclose(fp);
329             exit(0);
330         }
331         ])
332         _AC_PTH_VERBOSE([+ Performing Sanity Checks:])
333         _AC_PTH_VERBOSE([    o pre-processor test])
334         AC_TRY_CPP(_code1, _ok=yes, _ok=no)
335         if test ".$_ok" != .yes; then
336             _AC_PTH_ERROR([dnl
337             Found GNU Pth $_pth_version under $_pth_location, but
338             was unable to perform a sanity pre-processor check. This means
339             the GNU Pth header pth.h was not found.
340             We used the following build environment:
341             >> CPP="$CPP"
342             >> CPPFLAGS="$CPPFLAGS"
343             See config.log for possibly more details.])
344         fi
345         _AC_PTH_VERBOSE([    o link check])
346         AC_TRY_LINK(_code1, _code2, _ok=yes, _ok=no)
347         if test ".$_ok" != .yes; then
348             _AC_PTH_ERROR([dnl
349             Found GNU Pth $_pth_version under $_pth_location, but
350             was unable to perform a sanity linker check. This means
351             the GNU Pth library libpth.a was not found.
352             We used the following build environment:
353             >> CC="$CC"
354             >> CFLAGS="$CFLAGS"
355             >> LDFLAGS="$LDFLAGS"
356             >> LIBS="$LIBS"
357             See config.log for possibly more details.])
358         fi
359         _AC_PTH_VERBOSE([    o run-time check])
360         AC_TRY_RUN(_code1 _code2, _ok=`cat conftestval`, _ok=no, _ok=no)
361         if test ".$_ok" != .yes; then
362             if test ".$_ok" = .no; then
363                 _AC_PTH_ERROR([dnl
364                 Found GNU Pth $_pth_version under $_pth_location, but
365                 was unable to perform a sanity execution check. This usually
366                 means that the GNU Pth shared library libpth.so is present
367                 but \$LD_LIBRARY_PATH is incomplete to execute a Pth test.
368                 In this case either disable this test via --without-pth-test,
369                 or extend \$LD_LIBRARY_PATH, or build GNU Pth as a static
370                 library only via its --disable-shared Autoconf option.
371                 We used the following build environment:
372                 >> CC="$CC"
373                 >> CFLAGS="$CFLAGS"
374                 >> LDFLAGS="$LDFLAGS"
375                 >> LIBS="$LIBS"
376                 See config.log for possibly more details.])
377             else
378                 _AC_PTH_ERROR([dnl
379                 Found GNU Pth $_pth_version under $_pth_location, but
380                 was unable to perform a sanity run-time check. This usually
381                 means that the GNU Pth library failed to work and possibly
382                 caused a core dump in the test program. In this case it
383                 is strongly recommended that you re-install GNU Pth and this
384                 time make sure that it really passes its "make test" procedure.
385                 We used the following build environment:
386                 >> CC="$CC"
387                 >> CFLAGS="$CFLAGS"
388                 >> LDFLAGS="$LDFLAGS"
389                 >> LIBS="$LIBS"
390                 See config.log for possibly more details.])
391             fi
392         fi
393         _extendvars="ifelse([$4],,yes,$4)"
394         if test ".$_extendvars" != .yes; then
395             CPPFLAGS="$_ac_save_CPPFLAGS"
396             CFLAGS="$_ac_save_CFLAGS"
397             LDFLAGS="$_ac_save_LDFLAGS"
398             LIBS="$_ac_save_LIBS"
399         fi
400     else
401         _extendvars="ifelse([$4],,yes,$4)"
402         if test ".$_extendvars" = .yes; then
403             if test ".$_pth_subdir" = .yes; then
404                 CPPFLAGS="$CPPFLAGS $_pth_cppflags"
405                 CFLAGS="$CFLAGS $_pth_cflags"
406                 LDFLAGS="$LDFLAGS $_pth_ldflags"
407                 LIBS="$LIBS $_pth_libs"
408             fi
409         fi
410     fi
411     PTH_CPPFLAGS="$_pth_cppflags"
412     PTH_CFLAGS="$_pth_cflags"
413     PTH_LDFLAGS="$_pth_ldflags"
414     PTH_LIBS="$_pth_libs"
415     AC_SUBST(PTH_CPPFLAGS)
416     AC_SUBST(PTH_CFLAGS)
417     AC_SUBST(PTH_LDFLAGS)
418     AC_SUBST(PTH_LIBS)
419     _AC_PTH_VERBOSE([+ Final Results:])
420     _AC_PTH_VERBOSE([    o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"])
421     _AC_PTH_VERBOSE([    o PTH_CFLAGS=\"$PTH_CFLAGS\"])
422     _AC_PTH_VERBOSE([    o PTH_LDFLAGS=\"$PTH_LDFLAGS\"])
423     _AC_PTH_VERBOSE([    o PTH_LIBS=\"$PTH_LIBS\"])
424 fi
425 fi
426 if test ".$with_pth" != .no; then
427     AC_MSG_RESULT([version $_pth_version, $_pth_type under $_pth_location])
428     ifelse([$5], , :, [$5])
429 else
430     AC_MSG_RESULT([no])
431     ifelse([$6], , :, [$6])
432 fi
433 ])
434
435 dnl GNUPG_CHECK_VA_COPY()
436 dnl   Do some check on how to implement va_copy.
437 dnl   May define MUST_COPY_VA_BY_VAL.
438 dnl   Actual test code taken from glib-1.1.
439 AC_DEFUN(GNUPG_CHECK_VA_COPY,
440 [ AC_MSG_CHECKING(whether va_lists must be copied by value)
441   AC_CACHE_VAL(gnupg_cv_must_copy_va_byval,[
442     gnupg_cv_must_copy_va_byval=no
443     AC_TRY_RUN([
444        #include <stdarg.h>
445        void f (int i, ...)
446        {
447           va_list args1, args2;
448           va_start (args1, i);
449           args2 = args1;
450           if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
451             exit (1);
452           va_end (args1);
453           va_end (args2);
454        }
455       
456        int main()
457        {
458           f (0, 42);
459             return 0;
460        }
461     ],gnupg_cv_must_copy_va_byval=yes)
462   ])
463   if test "$gnupg_cv_must_copy_va_byval" = yes; then
464      AC_DEFINE(MUST_COPY_VA_BYVAL,1,[used to implement the va_copy macro])
465   fi
466   AC_MSG_RESULT($gnupg_cv_must_copy_va_byval)
467 ])
468
469
470 # glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
471 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
472 dnl This file is free software, distributed under the terms of the GNU
473 dnl General Public License.  As a special exception to the GNU General
474 dnl Public License, this file may be distributed as part of a program
475 dnl that contains a configuration script generated by Autoconf, under
476 dnl the same distribution terms as the rest of that program.
477
478 # Test for the GNU C Library, version 2.1 or newer.
479 # From Bruno Haible.
480
481 AC_DEFUN([jm_GLIBC21],
482   [
483     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
484       ac_cv_gnu_library_2_1,
485       [AC_EGREP_CPP([Lucky GNU user],
486         [
487 #include <features.h>
488 #ifdef __GNU_LIBRARY__
489  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
490   Lucky GNU user
491  #endif
492 #endif
493         ],
494         ac_cv_gnu_library_2_1=yes,
495         ac_cv_gnu_library_2_1=no)
496       ]
497     )
498     AC_SUBST(GLIBC21)
499     GLIBC21="$ac_cv_gnu_library_2_1"
500   ]
501 )
502
503
504 dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
505 dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
506 dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
507 dnl
508 dnl taken from libgpg-error 0.6
509 dnl
510 AC_DEFUN(AM_PATH_GPG_ERROR,
511 [ AC_ARG_WITH(gpg-error-prefix,
512             AC_HELP_STRING([--with-gpg-error-prefix=PFX],
513                            [prefix where GPG Error is installed (optional)]),
514      gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
515   if test x$gpg_error_config_prefix != x ; then
516      if test x${GPG_ERROR_CONFIG+set} != xset ; then
517         GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
518      fi
519   fi
520
521   AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
522   min_gpg_error_version=ifelse([$1], ,0.0,$1)
523   AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
524   ok=no
525   if test "$GPG_ERROR_CONFIG" != "no" ; then
526     req_major=`echo $min_gpg_error_version | \
527                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
528     req_minor=`echo $min_gpg_error_version | \
529                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
530     gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
531     major=`echo $gpg_error_config_version | \
532                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
533     minor=`echo $gpg_error_config_version | \
534                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
535     if test "$major" -gt "$req_major"; then
536         ok=yes
537     else 
538         if test "$major" -eq "$req_major"; then
539             if test "$minor" -ge "$req_minor"; then
540                ok=yes
541             fi
542         fi
543     fi
544   fi
545   if test $ok = yes; then
546     GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
547     GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
548     AC_MSG_RESULT(yes)
549     ifelse([$2], , :, [$2])
550   else
551     GPG_ERROR_CFLAGS=""
552     GPG_ERROR_LIBS=""
553     AC_MSG_RESULT(no)
554     ifelse([$3], , :, [$3])
555   fi
556   AC_SUBST(GPG_ERROR_CFLAGS)
557   AC_SUBST(GPG_ERROR_LIBS)
558 ])
559
560