/m4/ntl-check.m4

https://github.com/malex984/malex984Sources · m4 · 132 lines · 99 code · 17 blank · 16 comment · 0 complexity · d3d5f29aa2677f3ac27011716a20e7ef MD5 · raw file

  1. # Check for NTL
  2. # Bradford Hovinen, 2001-06-13
  3. # Modified by Pascal Giorgi, 2003-12-03
  4. # Inspired by gnome-bonobo-check.m4 by Miguel de Icaza, 99-04-12
  5. # Stolen from Chris Lahey 99-2-5
  6. # stolen from Manish Singh again
  7. # stolen back from Frank Belew
  8. # stolen from Manish Singh
  9. # Shamelessly stolen from Owen Taylor
  10. dnl LB_CHECK_NTL ([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  11. dnl
  12. dnl Test for Victor Shoup's NTL (Number Theory Library) and define
  13. dnl NTL_CFLAGS and NTL_LIBS
  14. AC_DEFUN([LB_CHECK_NTL],
  15. [
  16. DEFAULT_CHECKING_PATH="/usr /usr/local /sw /opt/local"
  17. AC_ARG_WITH(ntl,
  18. [ --with-ntl=<path>|yes|no Use NTL library. If argument is no, you do not have
  19. the library installed on your machine (set as
  20. default). If argument is yes or <empty> that means
  21. the library is reachable with the standard search
  22. path (/usr or /usr/local). Otherwise you give the
  23. <path> to the directory which contain the library.
  24. ],
  25. [if test "$withval" = yes ; then
  26. NTL_HOME_PATH="${DEFAULT_CHECKING_PATH}"
  27. elif test "$withval" != no ; then
  28. NTL_HOME_PATH="$withval"
  29. fi],
  30. [NTL_HOME_PATH="${DEFAULT_CHECKING_PATH}"])
  31. min_ntl_version=ifelse([$1], ,1.0,$1)
  32. dnl Check for existence
  33. BACKUP_CXXFLAGS=${CXXFLAGS}
  34. BACKUP_CFLAGS=${CFLAGS}
  35. BACKUP_LIBS=${LIBS}
  36. AC_LANG_PUSH(C++)
  37. if test -n "$NTL_HOME_PATH"; then
  38. AC_MSG_CHECKING(for NTL >= $min_ntl_version)
  39. fi
  40. for NTL_HOME in ${NTL_HOME_PATH}
  41. do
  42. if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
  43. if test "x$NTL_HOME" != "x/usr"; then
  44. NTL_CFLAGS="-I${NTL_HOME}/include"
  45. NTL_LIBS="-L${NTL_HOME}/lib -lntl"
  46. else
  47. NTL_CFLAGS=
  48. NTL_LIBS="-lntl"
  49. fi
  50. ### CFLAGS="${BACKUP_CFLAGS} ${NTL_CFLAGS} ${GMP_CFLAGS}"
  51. CXXFLAGS="${BACKUP_CFLAGS} ${BACKUP_CXXFLAGS} ${NTL_CFLAGS} ${GMP_CFLAGS}"
  52. LIBS="${BACKUP_LIBS} ${NTL_LIBS} ${GMP_LIBS}"
  53. AC_TRY_LINK(
  54. [#include <NTL/ZZ.h>],
  55. [NTL::ZZ a;],
  56. [
  57. AC_TRY_RUN(
  58. [#include <NTL/version.h>
  59. #include <NTL/config.h>
  60. #ifndef NTL_GMP_LIP
  61. int main() {return -1;}
  62. #else
  63. int main () { if (NTL_MAJOR_VERSION < 5) return -1; else return 0;}
  64. #endif
  65. ],[
  66. ntl_found="yes"
  67. break
  68. ],[
  69. ntl_problem="$problem $NTL_HOME"
  70. unset NTL_CFLAGS
  71. unset NTL_LIBS
  72. ],[
  73. ntl_found="yes"
  74. ntl_cross="yes"
  75. break
  76. ])
  77. ],
  78. [
  79. ntl_found="no"
  80. ntl_checked="$checked $NTL_HOME"
  81. unset NTL_CFLAGS
  82. unset NTL_LIBS
  83. ])
  84. else
  85. ntl_found="no"
  86. fi
  87. done
  88. if test "x$ntl_found" = "xyes" ; then
  89. AC_SUBST(NTL_CFLAGS)
  90. AC_SUBST(NTL_LIBS)
  91. AC_DEFINE(HAVE_NTL,1,[Define if NTL is installed])
  92. HAVE_NTL=yes
  93. if test "x$ntl_cross" != "xyes"; then
  94. AC_MSG_RESULT(found)
  95. else
  96. AC_MSG_RESULT(unknown)
  97. echo "WARNING: You appear to be cross compiling, so there is no way to determine"
  98. echo "whether your NTL version is new enough. I am assuming it is."
  99. fi
  100. ifelse([$2], , :, [$2])
  101. elif test -n "$ntl_problem"; then
  102. AC_MSG_RESULT(problem)
  103. echo "Sorry, your NTL version is too old or not configured with NTL_GMP_LIP=on. Disabling."
  104. ifelse([$3], , :, [$3])
  105. elif test "x$ntl_found" = "xno"; then
  106. AC_MSG_RESULT(not found)
  107. ifelse([$3], , :, [$3])
  108. fi
  109. AC_LANG_POP
  110. AM_CONDITIONAL(SING_HAVE_NTL, test "x$HAVE_NTL" = "xyes")
  111. # TODO: The following seems to set CXXFLAGS even if it was not defined previously!!!!
  112. CXXFLAGS=${BACKUP_CXXFLAGS}
  113. LIBS=${BACKUP_LIBS}
  114. #unset LD_LIBRARY_PATH
  115. ])