libgcrypt.m4 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # libgcrypt.m4 - Autoconf macros to detect libgcrypt
  2. # Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH
  3. #
  4. # This file is free software; as a special exception the author gives
  5. # unlimited permission to copy and/or distribute it, with or without
  6. # modifications, as long as this notice is preserved.
  7. #
  8. # This file is distributed in the hope that it will be useful, but
  9. # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  10. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. #
  12. # Last-changed: 2014-10-02
  13. dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
  14. dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
  15. dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
  16. dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed
  17. dnl with the API version to also check the API compatibility. Example:
  18. dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed
  19. dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using
  20. dnl this features allows to prevent build against newer versions of libgcrypt
  21. dnl with a changed API.
  22. dnl
  23. dnl If a prefix option is not used, the config script is first
  24. dnl searched in $SYSROOT/bin and then along $PATH. If the used
  25. dnl config script does not match the host specification the script
  26. dnl is added to the gpg_config_script_warn variable.
  27. dnl
  28. AC_DEFUN([AM_PATH_LIBGCRYPT],
  29. [ AC_REQUIRE([AC_CANONICAL_HOST])
  30. tmp=ifelse([$1], ,1:1.2.0,$1)
  31. if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
  32. req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
  33. min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
  34. else
  35. req_libgcrypt_api=0
  36. min_libgcrypt_version="$tmp"
  37. fi
  38. PKG_CHECK_MODULES(LIBGCRYPT, [libgcrypt >= $min_libgcrypt_version], [ok=yes], [ok=no])
  39. if test $ok = yes; then
  40. # If we have a recent libgcrypt, we should also check that the
  41. # API is compatible
  42. if test "$req_libgcrypt_api" -gt 0 ; then
  43. tmp=`$PKG_CONFIG --variable=api_version libgcrypt`
  44. if test "$tmp" -gt 0 ; then
  45. AC_MSG_CHECKING([LIBGCRYPT API version])
  46. if test "$req_libgcrypt_api" -eq "$tmp" ; then
  47. AC_MSG_RESULT([okay])
  48. else
  49. ok=no
  50. AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
  51. fi
  52. fi
  53. fi
  54. fi
  55. if test $ok = yes; then
  56. ifelse([$2], , :, [$2])
  57. libgcrypt_config_host=`$PKG_CONFIG --variable=host libgcrypt`
  58. if test x"$libgcrypt_config_host" != xnone ; then
  59. if test x"$libgcrypt_config_host" != x"$host" ; then
  60. AC_MSG_WARN([[
  61. ***
  62. *** The config script $LIBGCRYPT_CONFIG was
  63. *** built for $libgcrypt_config_host and thus may not match the
  64. *** used host $host.
  65. *** You may want to use the configure option --with-libgcrypt-prefix
  66. *** to specify a matching config script or use \$SYSROOT.
  67. ***]])
  68. gpg_config_script_warn="$gpg_config_script_warn libgcrypt"
  69. fi
  70. fi
  71. else
  72. ifelse([$3], , :, [$3])
  73. fi
  74. AC_SUBST(LIBGCRYPT_CFLAGS)
  75. AC_SUBST(LIBGCRYPT_LIBS)
  76. ])