source: git/m4/ntl-check.m4 @ c65e07

spielwiese
Last change on this file since c65e07 was 7615a7, checked in by Hans Schoenemann <hannes@…>, 3 years ago
libcddgmp: AC_MSG_ERROR ->AC_MSG_WARN
  • Property mode set to 100644
File size: 4.1 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[
18AC_REQUIRE([SING_DEFAULT_CHECKING_PATH])
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="DEFAULTS ${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="DEFAULTS ${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
52        if test "$NTL_HOME" != "DEFAULTS"; then
53                NTL_CPPFLAGS="-I${NTL_HOME}/include"
54                NTL_LIBS="-L${NTL_HOME}/lib -lntl"
55        else
56                NTL_CPPFLAGS=""
57                NTL_LIBS="-lntl"
58        fi
59        CXXFLAGS="${NTL_CPPFLAGS} ${GMP_CPPFLAGS} ${BACKUP_CXXFLAGS}"
60        LIBS="${NTL_LIBS} ${GMP_LIBS} ${BACKUP_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        #include <NTL/config.h>
69        #ifndef NTL_GMP_LIP
70        int main() {return -1;}
71        #else
72        int main () { if (NTL_MAJOR_VERSION < 5) return -1; else return 0;}
73        #endif
74        ],[
75        ntl_found="yes"
76        break
77        ],[
78        ntl_problem="$problem $NTL_HOME"
79        unset NTL_CPPFLAGS
80        unset NTL_LIBS
81        ],[
82        ntl_found="yes"
83        ntl_cross="yes"
84        break
85        ])
86        ],
87        [
88        ntl_found="no"
89        unset NTL_CPPFLAGS
90        unset NTL_LIBS
91        ])
92dnl try again with -std=c++11 (for NTL >=10 with threads)
93        if test "$NTL_HOME" != "DEFAULTS"; then
94                NTL_CPPFLAGS="-std=c++11 -I${NTL_HOME}/include"
95                NTL_LIBS="-L${NTL_HOME}/lib -lntl"
96        else
97                NTL_CPPFLAGS="-std=c++11"
98                NTL_LIBS="-lntl"
99        fi
100        CXXFLAGS="${NTL_CPPFLAGS} ${BACKUP_CXXFLAGS} ${GMP_CPPFLAGS}"
101        LIBS="${NTL_LIBS} ${GMP_LIBS} ${BACKUP_LIBS}"
102
103        AC_TRY_LINK(
104        [#include <NTL/ZZ.h>],
105        [NTL::ZZ a;],
106        [
107        AC_TRY_RUN(
108        [#include <NTL/version.h>
109        #include <NTL/config.h>
110        #ifndef NTL_GMP_LIP
111        int main() {return -1;}
112        #else
113        int main () { if (NTL_MAJOR_VERSION < 5) return -1; else return 0;}
114        #endif
115        ],[
116        ntl_found="yes"
117        break
118        ],[
119        ntl_problem="$problem $NTL_HOME"
120        unset NTL_CPPFLAGS
121        unset NTL_LIBS
122        ],[
123        ntl_found="yes"
124        ntl_cross="yes"
125        break
126        ])
127        ],
128        [
129        ntl_found="no"
130        unset NTL_CPPFLAGS
131        unset NTL_LIBS
132        ])
133done
134
135if test "x$ntl_found" = "xyes" ; then
136        AC_SUBST(NTL_CPPFLAGS)
137        AC_SUBST(NTL_LIBS)
138        AC_DEFINE(HAVE_NTL,1,[Define if NTL is installed])
139        HAVE_NTL=yes
140        if test "x$ntl_cross" != "xyes"; then
141                AC_MSG_RESULT(found)
142        else
143                AC_MSG_RESULT(unknown)
144                AC_MSG_WARN("WARNING: You appear to be cross compiling, so there is no way to determine")
145                AC_MSG_WARN("whether your NTL version is new enough. I am assuming it is.")
146        fi
147        ifelse([$2], , :, [$2])
148elif test -n "$ntl_problem"; then
149        AC_MSG_RESULT(problem)
150        echo "Sorry, your NTL version is too old or not configured with NTL_GMP_LIP=on. Disabling."
151        ifelse([$3], , :, [$3])
152elif test   "x$ntl_found" = "xno";  then
153        if test "x$NTL_SHOULD_BE_PRESENT" = "xyes"; then
154                AC_MSG_ERROR([NTL support was requested but NTL could not be detected])
155        fi
156        AC_MSG_RESULT(not found)
157        ifelse([$3], , :, [$3])
158fi
159
160AC_LANG_POP
161
162AM_CONDITIONAL(SING_HAVE_NTL, test "x$HAVE_NTL" = "xyes")
163
164# TODO: The following seems to set CXXFLAGS even if it was not defined previously!!!!
165CXXFLAGS=${BACKUP_CXXFLAGS}
166LIBS=${BACKUP_LIBS}
167#unset LD_LIBRARY_PATH
168
169])
170
Note: See TracBrowser for help on using the repository browser.