*** empty log message ***
[gnutls.git] / libgcrypt.m4
blob0e8ab5803d6a77d84e4f595e90b1f7948172acad
1 dnl Autoconf macros for libgcrypt
2 dnl       Copyright (C) 2002 Free Software Foundation, Inc.
3 dnl
4 dnl This file is free software; as a special exception the author gives
5 dnl unlimited permission to copy and/or distribute it, with or without
6 dnl modifications, as long as this notice is preserved.
7 dnl
8 dnl This file is distributed in the hope that it will be useful, but
9 dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
14 dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
15 dnl Test for liblibgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS
16 dnl
17 AC_DEFUN(AM_PATH_LIBGCRYPT,
18 [ AC_ARG_WITH(libgcrypt-prefix,
19             AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
20                            [prefix where LIBGCRYPT is installed (optional)]),
21      libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
22   if test x$libgcrypt_config_prefix != x ; then
23      if test x${LIBGCRYPT_CONFIG+set} != xset ; then
24         LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config
25      fi
26   fi
28   AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
29   min_libgcrypt_version=ifelse([$1], ,0.4.4,$1)
30   AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
31   ok=no
32   if test "$LIBGCRYPT_CONFIG" != "no" ; then
33     req_major=`echo $min_libgcrypt_version | \
34                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
35     req_minor=`echo $min_libgcrypt_version | \
36                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
37     req_micro=`echo $min_libgcrypt_version | \
38                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
39     libgcrypt_config_version=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --version`
40     major=`echo $libgcrypt_config_version | \
41                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
42     minor=`echo $libgcrypt_config_version | \
43                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
44     micro=`echo $libgcrypt_config_version | \
45                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
46     if test "$major" -gt "$req_major"; then
47         ok=yes
48     else 
49         if test "$major" -eq "$req_major"; then
50             if test "$minor" -gt "$req_minor"; then
51                ok=yes
52             else
53                if test "$minor" -eq "$req_minor"; then
54                    if test "$micro" -ge "$req_micro"; then
55                      ok=yes
56                    fi
57                fi
58             fi
59         fi
60     fi
61   fi
62   if test $ok = yes; then
63     LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --cflags`
64     LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG $libgcrypt_config_args --libs`
65     AC_MSG_RESULT(yes)
66     ifelse([$2], , :, [$2])
67   else
68     LIBGCRYPT_CFLAGS=""
69     LIBGCRYPT_LIBS=""
70     AC_MSG_RESULT(no)
71     ifelse([$3], , :, [$3])
72   fi
73   AC_SUBST(LIBGCRYPT_CFLAGS)
74   AC_SUBST(LIBGCRYPT_LIBS)