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

spielwiese
Last change on this file since ad35b5 was ad35b5, checked in by Bradford Hovinen <hovinen@…>, 13 years ago
Add M4-macro to check for NTL and to set NTL_CFLAGS, NTL_LIBS, and macro HAVE_NTL accordingly
  • Property mode set to 100644
File size: 3.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_CFLAGS and NTL_LIBS
15
16AC_DEFUN([LB_CHECK_NTL],
17[
18
19AC_ARG_WITH(ntl,
20[  --with-ntl=<path>|yes|no  Use NTL library. If argument is no, you do not have
21                            the library installed on your machine (set as
22                            default). If argument is yes or <empty> that means
23                            the library is reachable with the standard search
24                            path (/usr or /usr/local). Otherwise you give the
25                            <path> to the directory which contain the library.
26             ],
27             [if test "$withval" = yes ; then
28                        NTL_HOME_PATH="${DEFAULT_CHECKING_PATH}"
29              elif test "$withval" != no ; then
30                        NTL_HOME_PATH="$withval"
31             fi],
32             [])
33
34min_ntl_version=ifelse([$1], ,5.0,$1)
35
36
37dnl Check for existence
38BACKUP_CXXFLAGS=${CXXFLAGS}
39BACKUP_LIBS=${LIBS}
40
41if test -n "$NTL_HOME_PATH"; then
42AC_MSG_CHECKING(for NTL >= $min_ntl_version)
43fi
44
45for NTL_HOME in ${NTL_HOME_PATH}
46 do     
47if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
48
49        if test "x$NTL_HOME" != "x/usr" -a "x$NTL_HOME" != "x/usr/local"; then
50                NTL_CFLAGS="-I${NTL_HOME}/include"
51                NTL_LIBS="-L${NTL_HOME}/lib -lntl"
52        else
53                NTL_CFLAGS=
54                NTL_LIBS="-lntl"               
55        fi     
56        CXXFLAGS="${BACKUP_CXXFLAGS} ${NTL_CFLAGS} ${GMP_CFLAGS}"
57        LIBS="${BACKUP_LIBS} ${NTL_LIBS} ${GMP_LIBS}"
58
59        AC_TRY_LINK(
60        [#include <NTL/ZZ.h>],
61        [NTL::ZZ a;],
62        [
63        AC_TRY_RUN(
64        [#include <NTL/version.h>
65        int main () { if (NTL_MAJOR_VERSION < 5) return -1; else return 0; }   
66        ],[
67        ntl_found="yes"
68        break
69        ],[     
70        ntl_problem="$problem $NTL_HOME"       
71        unset NTL_CFLAGS
72        unset NTL_LIBS 
73        ],[
74        ntl_found="yes"
75        ntl_cross="yes"
76        break
77        ])     
78        ],
79        [
80        ntl_found="no"
81        ntl_checked="$checked $NTL_HOME"
82        unset NTL_CFLAGS
83        unset NTL_LIBS 
84        ])
85else
86        ntl_found="no"
87fi
88done
89
90if test "x$ntl_found" = "xyes" ; then           
91        AC_SUBST(NTL_CFLAGS)
92        AC_SUBST(NTL_LIBS)
93        AC_DEFINE(HAVE_NTL,1,[Define if NTL is installed])
94        HAVE_NTL=yes
95        if test "x$ntl_cross" != "xyes"; then
96                AC_MSG_RESULT(found)
97        else
98                AC_MSG_RESULT(unknown)
99                echo "WARNING: You appear to be cross compiling, so there is no way to determine"
100                echo "whether your NTL version is new enough. I am assuming it is."
101        fi
102        ifelse([$2], , :, [$2])
103elif test -n "$ntl_problem"; then
104        AC_MSG_RESULT(problem)
105        echo "Sorry, your NTL version is too old. Disabling."
106        ifelse([$3], , :, [$3])
107elif test   "x$ntl_found" = "xno";  then
108        AC_MSG_RESULT(not found)
109        if test "x$NTL_HOME" != "x/usr" -a "x$NTL_HOME" != "x/usr/local" ; then
110                AC_MSG_WARN(NTL >= $min_ntl_version was not found. LinBox also requires the NTL namespace to be enabled.  Please make sure NTL is compiled correctly.)
111        fi
112        ifelse([$3], , :, [$3])
113fi     
114
115
116
117AM_CONDITIONAL(SING_HAVE_NTL, test "x$HAVE_NTL" = "xyes")
118
119CXXFLAGS=${BACKUP_CXXFLAGS}
120LIBS=${BACKUP_LIBS}
121#unset LD_LIBRARY_PATH
122
123])
124
Note: See TracBrowser for help on using the repository browser.