libgcrypt.m4 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. dnl Autoconf macros for libgcrypt
  2. dnl Copyright (C) 2002, 2004 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.
  11. dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
  12. dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
  13. dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
  14. dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed
  15. dnl with the API version to also check the API compatibility. Example:
  16. dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed
  17. dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using
  18. dnl this features allows to prevent build against newer versions of libgcrypt
  19. dnl with a changed API.
  20. dnl
  21. AC_DEFUN([AM_PATH_LIBGCRYPT],
  22. [ AC_ARG_WITH(libgcrypt-prefix,
  23. AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
  24. [prefix where LIBGCRYPT is installed (optional)]),
  25. libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
  26. if test x$libgcrypt_config_prefix != x ; then
  27. if test x${LIBGCRYPT_CONFIG+set} != xset ; then
  28. LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config
  29. fi
  30. fi
  31. AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
  32. tmp=ifelse([$1], ,1:1.2.0,$1)
  33. if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
  34. req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
  35. min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
  36. else
  37. req_libgcrypt_api=0
  38. min_libgcrypt_version="$tmp"
  39. fi
  40. AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
  41. ok=no
  42. if test "$LIBGCRYPT_CONFIG" != "no" ; then
  43. req_major=`echo $min_libgcrypt_version | \
  44. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  45. req_minor=`echo $min_libgcrypt_version | \
  46. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  47. req_micro=`echo $min_libgcrypt_version | \
  48. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  49. libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
  50. major=`echo $libgcrypt_config_version | \
  51. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  52. minor=`echo $libgcrypt_config_version | \
  53. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  54. micro=`echo $libgcrypt_config_version | \
  55. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  56. if test "$major" -gt "$req_major"; then
  57. ok=yes
  58. else
  59. if test "$major" -eq "$req_major"; then
  60. if test "$minor" -gt "$req_minor"; then
  61. ok=yes
  62. else
  63. if test "$minor" -eq "$req_minor"; then
  64. if test "$micro" -ge "$req_micro"; then
  65. ok=yes
  66. fi
  67. fi
  68. fi
  69. fi
  70. fi
  71. fi
  72. if test $ok = yes; then
  73. AC_MSG_RESULT([yes ($libgcrypt_config_version)])
  74. else
  75. AC_MSG_RESULT(no)
  76. fi
  77. if test $ok = yes; then
  78. # If we have a recent libgcrypt, we should also check that the
  79. # API is compatible
  80. if test "$req_libgcrypt_api" -gt 0 ; then
  81. tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
  82. if test "$tmp" -gt 0 ; then
  83. AC_MSG_CHECKING([LIBGCRYPT API version])
  84. if test "$req_libgcrypt_api" -eq "$tmp" ; then
  85. AC_MSG_RESULT([okay])
  86. else
  87. ok=no
  88. AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
  89. fi
  90. fi
  91. fi
  92. fi
  93. if test $ok = yes; then
  94. LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
  95. LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
  96. ifelse([$2], , :, [$2])
  97. else
  98. LIBGCRYPT_CFLAGS=""
  99. LIBGCRYPT_LIBS=""
  100. ifelse([$3], , :, [$3])
  101. fi
  102. AC_SUBST(LIBGCRYPT_CFLAGS)
  103. AC_SUBST(LIBGCRYPT_LIBS)
  104. ])