source: git/m4/ntl-check.m4 @ 9c31e9

spielwiese
Last change on this file since 9c31e9 was 9c31e9, checked in by Timo Kaufmann <timokau@…>, 5 years ago
Fail hard when ntl is missing although it was specified
  • Property mode set to 100644
File size: 3.4 KB
Line 
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
11dnl LB_CHECK_NTL ([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
12dnl
13dnl Test for Victor Shoup's NTL (Number Theory Library) and define
14dnl NTL_CPPFLAGS and NTL_LIBS
15
16AC_DEFUN([LB_CHECK_NTL],
17[
18DEFAULT_CHECKING_PATH="/usr /usr/local /sw /opt/local"
19
20AC_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                        NTL_SHOULD_BE_PRESENT="yes"
33             fi],
34             [NTL_HOME_PATH="${DEFAULT_CHECKING_PATH}"])
35
36min_ntl_version=ifelse([$1], ,1.0,$1)
37
38
39dnl Check for existence
40BACKUP_CXXFLAGS=${CXXFLAGS}
41BACKUP_CFLAGS=${CFLAGS}
42BACKUP_LIBS=${LIBS}
43
44AC_LANG_PUSH(C++)
45
46if test -n "$NTL_HOME_PATH"; then
47AC_MSG_CHECKING(for NTL >= $min_ntl_version)
48fi
49
50for NTL_HOME in ${NTL_HOME_PATH}
51 do
52if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
53
54        if test "x$NTL_HOME" != "x/usr"; then
55                NTL_CPPFLAGS="-I${NTL_HOME}/include"
56                NTL_LIBS="-L${NTL_HOME}/lib -lntl"
57        else
58                NTL_CPPFLAGS=
59                NTL_LIBS="-lntl"
60        fi
61###     CFLAGS="${BACKUP_CFLAGS} ${NTL_CPPFLAGS} ${GMP_CPPFLAGS}"
62        CXXFLAGS="${BACKUP_CXXFLAGS} ${NTL_CPPFLAGS} ${GMP_CPPFLAGS}"
63        LIBS="${BACKUP_LIBS} ${NTL_LIBS} ${GMP_LIBS}"
64
65        AC_TRY_LINK(
66        [#include <NTL/ZZ.h>],
67        [NTL::ZZ a;],
68        [
69        AC_TRY_RUN(
70        [#include <NTL/version.h>
71        #include <NTL/config.h>
72        #ifndef NTL_GMP_LIP
73        int main() {return -1;}
74        #else
75        int main () { if (NTL_MAJOR_VERSION < 5) return -1; else return 0;}
76        #endif
77        ],[
78        ntl_found="yes"
79        break
80        ],[
81        ntl_problem="$problem $NTL_HOME"
82        unset NTL_CPPFLAGS
83        unset NTL_LIBS
84        ],[
85        ntl_found="yes"
86        ntl_cross="yes"
87        break
88        ])
89        ],
90        [
91        ntl_found="no"
92        ntl_checked="$checked $NTL_HOME"
93        unset NTL_CPPFLAGS
94        unset NTL_LIBS
95        ])
96else
97        ntl_found="no"
98fi
99done
100
101if test "x$ntl_found" = "xyes" ; then
102        AC_SUBST(NTL_CPPFLAGS)
103        AC_SUBST(NTL_LIBS)
104        AC_DEFINE(HAVE_NTL,1,[Define if NTL is installed])
105        HAVE_NTL=yes
106        if test "x$ntl_cross" != "xyes"; then
107                AC_MSG_RESULT(found)
108        else
109                AC_MSG_RESULT(unknown)
110                echo "WARNING: You appear to be cross compiling, so there is no way to determine"
111                echo "whether your NTL version is new enough. I am assuming it is."
112        fi
113        ifelse([$2], , :, [$2])
114elif test -n "$ntl_problem"; then
115        AC_MSG_RESULT(problem)
116        echo "Sorry, your NTL version is too old or not configured with NTL_GMP_LIP=on. Disabling."
117        ifelse([$3], , :, [$3])
118elif test   "x$ntl_found" = "xno";  then
119        if test "x$NTL_SHOULD_BE_PRESENT" = "xyes"; then
120                AC_MSG_ERROR([NTL support was requested but NTL could not be detected])
121        fi
122        AC_MSG_RESULT(not found)
123        ifelse([$3], , :, [$3])
124fi
125
126AC_LANG_POP
127
128AM_CONDITIONAL(SING_HAVE_NTL, test "x$HAVE_NTL" = "xyes")
129
130# TODO: The following seems to set CXXFLAGS even if it was not defined previously!!!!
131CXXFLAGS=${BACKUP_CXXFLAGS}
132LIBS=${BACKUP_LIBS}
133#unset LD_LIBRARY_PATH
134
135])
136
Note: See TracBrowser for help on using the repository browser.