source: git/m4/ntl-check.m4 @ 8ac0543

spielwiese
Last change on this file since 8ac0543 was db225a, checked in by Hans Schoenemann <hannes@…>, 6 years ago
fix: ntl-test: try first without -std=c++11
  • 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[
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             fi],
33             [NTL_HOME_PATH="${DEFAULT_CHECKING_PATH}"])
34
35min_ntl_version=ifelse([$1], ,1.0,$1)
36
37
38dnl Check for existence
39BACKUP_CXXFLAGS=${CXXFLAGS}
40BACKUP_CFLAGS=${CFLAGS}
41BACKUP_LIBS=${LIBS}
42
43AC_LANG_PUSH(C++)
44
45if test -n "$NTL_HOME_PATH"; then
46AC_MSG_CHECKING(for NTL >= $min_ntl_version)
47fi
48
49for NTL_HOME in ${NTL_HOME_PATH}
50 do
51if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
52
53        if test "x$NTL_HOME" != "x/usr"; then
54                NTL_CPPFLAGS="-I${NTL_HOME}/include"
55                NTL_LIBS="-L${NTL_HOME}/lib -lntl"
56        else
57                NTL_CPPFLAGS=""
58                NTL_LIBS="-lntl"
59        fi
60###     CFLAGS="${BACKUP_CFLAGS} ${NTL_CPPFLAGS} ${GMP_CPPFLAGS}"
61        CXXFLAGS="${BACKUP_CXXFLAGS} ${NTL_CPPFLAGS} ${GMP_CPPFLAGS}"
62        LIBS="${BACKUP_LIBS} ${NTL_LIBS} ${GMP_LIBS}"
63
64        AC_TRY_LINK(
65        [#include <NTL/ZZ.h>],
66        [NTL::ZZ a;],
67        [
68        AC_TRY_RUN(
69        [#include <NTL/version.h>
70        #include <NTL/config.h>
71        #ifndef NTL_GMP_LIP
72        int main() {return -1;}
73        #else
74        int main () { if (NTL_MAJOR_VERSION < 5) return -1; else return 0;}
75        #endif
76        ],[
77        ntl_found="yes"
78        break
79        ],[
80        ntl_problem="$problem $NTL_HOME"
81        unset NTL_CPPFLAGS
82        unset NTL_LIBS
83        ],[
84        ntl_found="yes"
85        ntl_cross="yes"
86        break
87        ])
88        ],
89        [
90        ntl_found="no"
91        ntl_checked="$checked $NTL_HOME"
92        unset NTL_CPPFLAGS
93        unset NTL_LIBS
94        ])
95dnl try again with -std=c++11 (for NTL >=10 with threads)
96        if test "x$NTL_HOME" != "x/usr"; then
97                NTL_CPPFLAGS="-std=c++11 -I${NTL_HOME}/include"
98                NTL_LIBS="-L${NTL_HOME}/lib -lntl"
99        else
100                NTL_CPPFLAGS="-std=c++11"
101                NTL_LIBS="-lntl"
102        fi
103###     CFLAGS="${BACKUP_CFLAGS} ${NTL_CPPFLAGS} ${GMP_CPPFLAGS}"
104        CXXFLAGS="${BACKUP_CXXFLAGS} ${NTL_CPPFLAGS} ${GMP_CPPFLAGS}"
105        LIBS="${BACKUP_LIBS} ${NTL_LIBS} ${GMP_LIBS}"
106
107        AC_TRY_LINK(
108        [#include <NTL/ZZ.h>],
109        [NTL::ZZ a;],
110        [
111        AC_TRY_RUN(
112        [#include <NTL/version.h>
113        #include <NTL/config.h>
114        #ifndef NTL_GMP_LIP
115        int main() {return -1;}
116        #else
117        int main () { if (NTL_MAJOR_VERSION < 5) return -1; else return 0;}
118        #endif
119        ],[
120        ntl_found="yes"
121        break
122        ],[
123        ntl_problem="$problem $NTL_HOME"
124        unset NTL_CPPFLAGS
125        unset NTL_LIBS
126        ],[
127        ntl_found="yes"
128        ntl_cross="yes"
129        break
130        ])
131        ],
132        [
133        ntl_found="no"
134        ntl_checked="$checked $NTL_HOME"
135        unset NTL_CPPFLAGS
136        unset NTL_LIBS
137        ])
138else
139        ntl_found="no"
140fi
141done
142
143if test "x$ntl_found" = "xyes" ; then
144        AC_SUBST(NTL_CPPFLAGS)
145        AC_SUBST(NTL_LIBS)
146        AC_DEFINE(HAVE_NTL,1,[Define if NTL is installed])
147        HAVE_NTL=yes
148        if test "x$ntl_cross" != "xyes"; then
149                AC_MSG_RESULT(found)
150        else
151                AC_MSG_RESULT(unknown)
152                echo "WARNING: You appear to be cross compiling, so there is no way to determine"
153                echo "whether your NTL version is new enough. I am assuming it is."
154        fi
155        ifelse([$2], , :, [$2])
156elif test -n "$ntl_problem"; then
157        AC_MSG_RESULT(problem)
158        echo "Sorry, your NTL version is too old or not configured with NTL_GMP_LIP=on. Disabling."
159        ifelse([$3], , :, [$3])
160elif test   "x$ntl_found" = "xno";  then
161        AC_MSG_RESULT(not found)
162        ifelse([$3], , :, [$3])
163fi
164
165AC_LANG_POP
166
167AM_CONDITIONAL(SING_HAVE_NTL, test "x$HAVE_NTL" = "xyes")
168
169# TODO: The following seems to set CXXFLAGS even if it was not defined previously!!!!
170CXXFLAGS=${BACKUP_CXXFLAGS}
171LIBS=${BACKUP_LIBS}
172#unset LD_LIBRARY_PATH
173
174])
175
Note: See TracBrowser for help on using the repository browser.