source: git/m4/gmp-check.m4 @ ab4f17

spielwiese
Last change on this file since ab4f17 was ab4f17, checked in by Mohamed Barakat <mohamed.barakat@…>, 12 years ago
added an autoconf macro to check for GMP
  • Property mode set to 100644
File size: 3.1 KB
Line 
1# Check for GMP
2# Modified by Pascal Giorgi, 2003-12-03
3
4dnl LB_CHECK_GMP ([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
5dnl
6dnl Test for the GNU Multiprecision library and define GMP_CFLAGS and GMP_LIBS
7
8AC_DEFUN([LB_CHECK_GMP],
9[
10AC_ARG_WITH(gmp,
11[  --with-gmp= <path>|yes Use GMP library. This library is mandatory for Singular
12                         compilation. If argument is yes or <empty> that means
13                         the library is reachable with the standard search path
14                         "/usr" or "/usr/local" (set as default). Otherwise you
15                         give the <path> to the directory which contain the
16                         library.
17],
18                [if test "$withval" = yes ; then
19                        GMP_HOME_PATH="${DEFAULT_CHECKING_PATH}"
20                 elif test "$withval" != no ; then
21                        GMP_HOME_PATH="$withval ${DEFAULT_CHECKING_PATH}"
22                fi],
23                [GMP_HOME_PATH="${DEFAULT_CHECKING_PATH}"])
24
25min_gmp_version=ifelse([$1], ,3.1.1,$1)
26
27dnl Check for existence
28BACKUP_CFLAGS=${CFLAGS}
29BACKUP_LIBS=${LIBS}
30
31AC_MSG_CHECKING(for GMP >= $min_gmp_version)
32
33for GMP_HOME in ${GMP_HOME_PATH}
34  do   
35        if test -r "$GMP_HOME/include/gmp.h"; then
36
37                if test "x$GMP_HOME" != "x/usr" -a "x$GMP_HOME" != "x/usr/local"; then
38                        GMP_CFLAGS="-I${GMP_HOME}/include"
39                        GMP_LIBS="-L${GMP_HOME}/lib -lgmp"     
40                else
41                        GMP_CFLAGS=
42                        GMP_LIBS="-lgmp"               
43                fi
44       
45                CFLAGS="${CFLAGS} ${GMP_CFLAGS}"
46                LIBS="${LIBS} ${GMP_LIBS}"
47
48                AC_TRY_LINK(
49                [#include <gmp.h>],
50                [mpz_t a; mpz_init (a);],
51                [
52                        AC_TRY_RUN(
53                        [#include <gmp.h>
54                         int main () {  if (__GNU_MP_VERSION < 3) return -1; else return 0; }
55                        ],[
56                                AC_MSG_RESULT(found)
57                                AC_SUBST(GMP_CFLAGS)
58                                AC_SUBST(GMP_LIBS)
59                                AC_DEFINE(HAVE_GMP,1,[Define if GMP is installed])
60                                # See if we are running GMP 4.0
61                                AC_MSG_CHECKING(whether GMP is 4.0 or greater)
62                                AC_TRY_RUN(
63                                [#include <gmp.h>
64                                int main () { if (__GNU_MP_VERSION < 4) return -1; else return 0; }
65                                ],[
66                                        gmp_found="yes"
67                                        AC_MSG_RESULT(yes)
68                                        GMP_VERSION=""
69                                        AC_SUBST(GMP_VERSION)
70                                ],[
71                                        AC_MSG_RESULT(no)
72                                        AC_DEFINE(GMP_VERSION_3,1,[Define if GMP is version 3.xxx])
73                                        GMP_VERSION="-DGMP_VERSION_3"
74                                        AC_SUBST(GMP_VERSION)
75                                ],[
76                                        dnl This should never happen
77                                        AC_MSG_RESULT(no)
78                                ])
79                                ifelse([$2], , :, [$2])
80                                break
81                        ],[                     
82                                gmp_problem="$gmp_problem $GMP_HOME"
83                                unset GMP_CFLAGS
84                                unset GMP_LIBS 
85                        ],[
86                                AC_MSG_RESULT(unknown)
87                                echo "WARNING: You appear to be cross compiling, so there is no way to determine"
88                                echo "whether your GMP version is new enough. I am assuming it is."
89                                AC_SUBST(GMP_CFLAGS)
90                                AC_SUBST(GMP_LIBS)
91                                AC_DEFINE(HAVE_GMP,1,[Define if GMP is installed])     
92                                ifelse([$2], , :, [$2])
93                                break
94                        ])     
95                ],[
96                gmp_found="no" 
97                unset GMP_CFLAGS
98                unset GMP_LIBS 
99                ])
100
101        else
102                gmp_found="no" 
103        fi
104done
105
106if test "x$gmp_found" != "xyes"; then
107        if test -n "$gmp_problem"; then
108                AC_MSG_RESULT(problem)
109                echo "Sorry, your GMP version is too old. Disabling."
110        elif test "x$gmp_found" != "xno"; then
111                AC_MSG_RESULT(not found)
112        fi
113        ifelse($3, , :, $3)
114fi
115
116
117CFLAGS=${BACKUP_CFLAGS}
118LIBS=${BACKUP_LIBS}
119#unset LD_LIBRARY_PATH
120
121])
Note: See TracBrowser for help on using the repository browser.