libgcrypt.m4 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. dnl Autoconf macros for libgcrypt
  2. dnl Copyright (C) 2002, 2004, 2011 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_REQUIRE([AC_CANONICAL_HOST])
  23. AC_ARG_WITH(libgcrypt-prefix,
  24. AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
  25. [prefix where LIBGCRYPT is installed (optional)]),
  26. libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
  27. if test x$libgcrypt_config_prefix != x ; then
  28. if test x${LIBGCRYPT_CONFIG+set} != xset ; then
  29. LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config
  30. fi
  31. fi
  32. AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no)
  33. tmp=ifelse([$1], ,1:1.2.0,$1)
  34. if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
  35. req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
  36. min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
  37. else
  38. req_libgcrypt_api=0
  39. min_libgcrypt_version="$tmp"
  40. fi
  41. AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
  42. ok=no
  43. if test "$LIBGCRYPT_CONFIG" != "no" ; then
  44. req_major=`echo $min_libgcrypt_version | \
  45. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  46. req_minor=`echo $min_libgcrypt_version | \
  47. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  48. req_micro=`echo $min_libgcrypt_version | \
  49. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  50. libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
  51. major=`echo $libgcrypt_config_version | \
  52. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  53. minor=`echo $libgcrypt_config_version | \
  54. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  55. micro=`echo $libgcrypt_config_version | \
  56. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  57. if test "$major" -gt "$req_major"; then
  58. ok=yes
  59. else
  60. if test "$major" -eq "$req_major"; then
  61. if test "$minor" -gt "$req_minor"; then
  62. ok=yes
  63. else
  64. if test "$minor" -eq "$req_minor"; then
  65. if test "$micro" -ge "$req_micro"; then
  66. ok=yes
  67. fi
  68. fi
  69. fi
  70. fi
  71. fi
  72. fi
  73. if test $ok = yes; then
  74. AC_MSG_RESULT([yes ($libgcrypt_config_version)])
  75. else
  76. AC_MSG_RESULT(no)
  77. fi
  78. if test $ok = yes; then
  79. # If we have a recent libgcrypt, we should also check that the
  80. # API is compatible
  81. if test "$req_libgcrypt_api" -gt 0 ; then
  82. tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
  83. if test "$tmp" -gt 0 ; then
  84. AC_MSG_CHECKING([LIBGCRYPT API version])
  85. if test "$req_libgcrypt_api" -eq "$tmp" ; then
  86. AC_MSG_RESULT([okay])
  87. else
  88. ok=no
  89. AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
  90. fi
  91. fi
  92. fi
  93. fi
  94. if test $ok = yes; then
  95. LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
  96. LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
  97. ifelse([$2], , :, [$2])
  98. libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
  99. if test x"$libgcrypt_config_host" != xnone ; then
  100. if test x"$libgcrypt_config_host" != x"$host" ; then
  101. AC_MSG_WARN([[
  102. ***
  103. *** The config script $LIBGCRYPT_CONFIG was
  104. *** built for $libgcrypt_config_host and thus may not match the
  105. *** used host $host.
  106. *** You may want to use the configure option --with-libgcrypt-prefix
  107. *** to specify a matching config script.
  108. ***]])
  109. fi
  110. fi
  111. else
  112. LIBGCRYPT_CFLAGS=""
  113. LIBGCRYPT_LIBS=""
  114. ifelse([$3], , :, [$3])
  115. fi
  116. AC_SUBST(LIBGCRYPT_CFLAGS)
  117. AC_SUBST(LIBGCRYPT_LIBS)
  118. ])