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

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