2004-01-13 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / gpgme / gpgme.m4
1 dnl Autoconf macros for libgpgme
2 dnl $Id$
3
4 AC_DEFUN(_AM_PATH_GPGME_CONFIG,
5 [ AC_ARG_WITH(gpgme-prefix,
6             AC_HELP_STRING([--with-gpgme-prefix=PFX],
7                            [prefix where GPGME is installed (optional)]),
8      gpgme_config_prefix="$withval", gpgme_config_prefix="")
9   if test "x$gpgme_config_prefix" != x ; then
10       GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
11   fi
12   AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
13
14   gpgme_version=`$GPGME_CONFIG --version`
15   gpgme_version_major=`echo $gpgme_version | \
16                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
17   gpgme_version_minor=`echo $gpgme_version | \
18                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
19   gpgme_version_micro=`echo $gpgme_version | \
20                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
21 ])
22
23 dnl AM_PATH_GPGME([MINIMUM-VERSION,
24 dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
25 dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
26 dnl
27 AC_DEFUN([AM_PATH_GPGME],
28 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
29   min_gpgme_version=ifelse([$1], ,0.4.2,$1)
30   AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
31   ok=no
32   if test "$GPGME_CONFIG" != "no" ; then
33     req_major=`echo $min_gpgme_version | \
34                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
35     req_minor=`echo $min_gpgme_version | \
36                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
37     req_micro=`echo $min_gpgme_version | \
38                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
39     if test "$gpgme_version_major" -gt "$req_major"; then
40         ok=yes
41     else 
42         if test "$gpgme_version_major" -eq "$req_major"; then
43             if test "$gpgme_version_minor" -gt "$req_minor"; then
44                ok=yes
45             else
46                if test "$gpgme_version_minor" -eq "$req_minor"; then
47                    if test "$gpgme_version_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 --cflags`
57     GPGME_LIBS=`$GPGME_CONFIG --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
70 dnl AM_PATH_GPGME_PTH([MINIMUM-VERSION,
71 dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
72 dnl Test for libgpgme and define GPGME_PTH_CFLAGS and GPGME_PTH_LIBS.
73 dnl
74 AC_DEFUN([AM_PATH_GPGME_PTH],
75 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
76   min_gpgme_version=ifelse([$1], ,0.4.2,$1)
77   AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version)
78   ok=no
79   if test "$GPGME_CONFIG" != "no" ; then
80     if `$GPGME_CONFIG --thread=pth 2> /dev/null` ; then
81       req_major=`echo $min_gpgme_version | \
82                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
83       req_minor=`echo $min_gpgme_version | \
84                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
85       req_micro=`echo $min_gpgme_version | \
86                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
87       if test "$gpgme_version_major" -gt "$req_major"; then
88         ok=yes
89       else 
90         if test "$gpgme_version_major" -eq "$req_major"; then
91           if test "$gpgme_version_minor" -gt "$req_minor"; then
92             ok=yes
93           else
94             if test "$gpgme_version_minor" -eq "$req_minor"; then
95               if test "$gpgme_version_micro" -ge "$req_micro"; then
96                 ok=yes
97               fi
98             fi
99           fi
100         fi
101       fi
102     fi
103   fi
104   if test $ok = yes; then
105     GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags`
106     GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs`
107     AC_MSG_RESULT(yes)
108     ifelse([$2], , :, [$2])
109   else
110     GPGME_PTH_CFLAGS=""
111     GPGME_PTH_LIBS=""
112     AC_MSG_RESULT(no)
113     ifelse([$3], , :, [$3])
114   fi
115   AC_SUBST(GPGME_PTH_CFLAGS)
116   AC_SUBST(GPGME_PTH_LIBS)
117 ])
118
119 dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
120 dnl                       [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
121 dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
122 dnl  and GPGME_PTHREAD_LIBS.
123 dnl
124 AC_DEFUN([AM_PATH_GPGME_PTHREAD],
125 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
126   min_gpgme_version=ifelse([$1], ,0.4.2,$1)
127   AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
128   ok=no
129   if test "$GPGME_CONFIG" != "no" ; then
130     if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
131       req_major=`echo $min_gpgme_version | \
132                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
133       req_minor=`echo $min_gpgme_version | \
134                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
135       req_micro=`echo $min_gpgme_version | \
136                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
137       if test "$gpgme_version_major" -gt "$req_major"; then
138         ok=yes
139       else 
140         if test "$gpgme_version_major" -eq "$req_major"; then
141           if test "$gpgme_version_minor" -gt "$req_minor"; then
142             ok=yes
143           else
144             if test "$gpgme_version_minor" -eq "$req_minor"; then
145               if test "$gpgme_version_micro" -ge "$req_micro"; then
146                 ok=yes
147               fi
148             fi
149           fi
150         fi
151       fi
152     fi
153   fi
154   if test $ok = yes; then
155     GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
156     GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
157     AC_MSG_RESULT(yes)
158     ifelse([$2], , :, [$2])
159   else
160     GPGME_PTHREAD_CFLAGS=""
161     GPGME_PTHREAD_LIBS=""
162     AC_MSG_RESULT(no)
163     ifelse([$3], , :, [$3])
164   fi
165   AC_SUBST(GPGME_PTHREAD_CFLAGS)
166   AC_SUBST(GPGME_PTHREAD_LIBS)
167 ])