2005-10-07 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / m4 / gpg-error.m4
bloba5875f00497758517bd2cc56754b53c340ba9ce2
1 dnl Autoconf macros for libgpg-error
3 dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
4 dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
5 dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
6 dnl
7 AC_DEFUN([AM_PATH_GPG_ERROR],
8 [ AC_ARG_WITH(gpg-error-prefix,
9             AC_HELP_STRING([--with-gpg-error-prefix=PFX],
10                            [prefix where GPG Error is installed (optional)]),
11      gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
12   if test x$gpg_error_config_prefix != x ; then
13      if test x${GPG_ERROR_CONFIG+set} != xset ; then
14         GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
15      fi
16   fi
18   AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
19   min_gpg_error_version=ifelse([$1], ,0.0,$1)
20   AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
21   ok=no
22   if test "$GPG_ERROR_CONFIG" != "no" ; then
23     req_major=`echo $min_gpg_error_version | \
24                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
25     req_minor=`echo $min_gpg_error_version | \
26                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
27     gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
28     major=`echo $gpg_error_config_version | \
29                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
30     minor=`echo $gpg_error_config_version | \
31                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
32     if test "$major" -gt "$req_major"; then
33         ok=yes
34     else 
35         if test "$major" -eq "$req_major"; then
36             if test "$minor" -ge "$req_minor"; then
37                ok=yes
38             fi
39         fi
40     fi
41   fi
42   if test $ok = yes; then
43     GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
44     GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
45     AC_MSG_RESULT(yes)
46     ifelse([$2], , :, [$2])
47   else
48     GPG_ERROR_CFLAGS=""
49     GPG_ERROR_LIBS=""
50     AC_MSG_RESULT(no)
51     ifelse([$3], , :, [$3])
52   fi
53   AC_SUBST(GPG_ERROR_CFLAGS)
54   AC_SUBST(GPG_ERROR_LIBS)