source: git/m4/gmp-check.m4 @ 08a955

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