2003-01-30 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / gpgme / gpgme.m4
1 dnl Autoconf macros for libgpgme
2 dnl $Id$
3
4
5 dnl AM_PATH_GPGME([MINIMUM-VERSION,
6 dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
7 dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS
8 dnl
9 AC_DEFUN(AM_PATH_GPGME,
10 [ AC_ARG_WITH(gpgme-prefix,
11             AC_HELP_STRING([--with-gpgme-prefix=PFX],
12                            [prefix where GPGME is installed (optional)]),
13      gpgme_config_prefix="$withval", gpgme_config_prefix="")
14   if test x$gpgme_config_prefix != x ; then
15      gpgme_config_args="$gpgme_config_args --prefix=$gpgme_config_prefix"
16      if test x${GPGME_CONFIG+set} != xset ; then
17         GPGME_CONFIG=$gpgme_config_prefix/bin/gpgme-config
18      fi
19   fi
20
21   AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
22   min_gpgme_version=ifelse([$1], ,0.3.9,$1)
23   AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
24   ok=no
25   if test "$GPGME_CONFIG" != "no" ; then
26     req_major=`echo $min_gpgme_version | \
27                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
28     req_minor=`echo $min_gpgme_version | \
29                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
30     req_micro=`echo $min_gpgme_version | \
31                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
32     gpgme_config_version=`$GPGME_CONFIG $gpgme_config_args --version`
33     major=`echo $gpgme_config_version | \
34                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
35     minor=`echo $gpgme_config_version | \
36                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
37     micro=`echo $gpgme_config_version | \
38                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
39     if test "$major" -gt "$req_major"; then
40         ok=yes
41     else 
42         if test "$major" -eq "$req_major"; then
43             if test "$minor" -gt "$req_minor"; then
44                ok=yes
45             else
46                if test "$minor" -eq "$req_minor"; then
47                    if test "$micro" -ge "$req_micro"; then
48                      ok=yes
49                    fi
50                fi
51             fi
52         fi
53     fi
54   fi
55   if test $ok = yes; then
56     GPGME_CFLAGS=`$GPGME_CONFIG $gpgme_config_args --cflags`
57     GPGME_LIBS=`$GPGME_CONFIG $gpgme_config_args --libs`
58     AC_MSG_RESULT(yes)
59     ifelse([$2], , :, [$2])
60   else
61     GPGME_CFLAGS=""
62     GPGME_LIBS=""
63     AC_MSG_RESULT(no)
64     ifelse([$3], , :, [$3])
65   fi
66   AC_SUBST(GPGME_CFLAGS)
67   AC_SUBST(GPGME_LIBS)
68 ])
69