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