source: git/m4/gmp-check.m4 @ 1101a8

spielwiese
Last change on this file since 1101a8 was f30df9, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
More fixes/improvements to BS (m4/*.m4)
  • Property mode set to 100644
File size: 3.4 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
35AC_LANG_PUSH([C])
36
37for GMP_HOME in ${GMP_HOME_PATH}
38  do   
39#       if test -r "$GMP_HOME/include/gmp.h"; then
40
41                if test "x$GMP_HOME" != "x/usr"; then
42                        GMP_CFLAGS="-I${GMP_HOME}/include"
43                        GMP_LIBS="-L${GMP_HOME}/lib -lgmp"     
44                else
45                        GMP_CFLAGS=""
46                        GMP_LIBS="-lgmp"
47                fi
48       
49                CFLAGS="${BACKUP_CFLAGS} ${GMP_CFLAGS}"
50                LIBS="${BACKUP_LIBS} ${GMP_LIBS}"
51
52    # According to C. Fieker this would link but would not RUN
53    # (AC_TRY_RUN) due to missing SHARED libgmp.so :(
54    # TODO: set LD_LIBRARY_PATH???
55                AC_TRY_LINK(
56                [#include <gmp.h>],
57                [mpz_t a; mpz_init (a);],
58                [
59                        AC_TRY_RUN(
60                        [#include <gmp.h>
61                         int main () {  if (__GNU_MP_VERSION < 3) return -1; else return 0; }
62                        ],[
63                                AC_MSG_RESULT(found)
64                                AC_SUBST(GMP_CFLAGS)
65                                AC_SUBST(GMP_LIBS)
66                                AC_DEFINE(HAVE_GMP,1,[Define if GMP is installed])
67                                # See if we are running GMP 4.0
68                                AC_MSG_CHECKING(whether GMP is 4.0 or greater)
69                                AC_TRY_RUN(
70                                [#include <gmp.h>
71                                int main () { if (__GNU_MP_VERSION < 4) return -1; else return 0; }
72                                ],[
73                                        gmp_found="yes"
74                                        AC_MSG_RESULT(yes)
75                                        GMP_VERSION=""
76                                        AC_SUBST(GMP_VERSION)
77                                ],[
78                                        AC_MSG_RESULT(no)
79                                        AC_DEFINE(GMP_VERSION_3,1,[Define if GMP is version 3.xxx])
80                                        GMP_VERSION="-DGMP_VERSION_3"
81                                        AC_SUBST(GMP_VERSION)
82                                ],[
83                                        dnl This should never happen
84                                        AC_MSG_RESULT(no)
85                                ])
86                                ifelse([$2], , :, [$2])
87                                break
88                        ],[                     
89                                gmp_problem="$gmp_problem $GMP_HOME"
90                                unset GMP_CFLAGS
91                                unset GMP_LIBS 
92                        ],[
93                                AC_MSG_RESULT(unknown)
94                                echo "WARNING: You appear to be cross compiling, so there is no way to determine"
95                                echo "whether your GMP version is new enough. I am assuming it is."
96                                AC_SUBST(GMP_CFLAGS)
97                                AC_SUBST(GMP_LIBS)
98                                AC_SUBST(GMP_HOME)
99                                HAVE_GMP=yes
100                                AC_DEFINE(HAVE_GMP,1,[Define if GMP is installed])     
101                                ifelse([$2], , :, [$2])
102                                break
103                        ])     
104                ],[
105                gmp_found="no" 
106                unset GMP_CFLAGS
107                unset GMP_LIBS 
108                ])
109
110#       else
111#               gmp_found="no" 
112#       fi
113done
114AC_LANG_POP([C])
115
116CFLAGS=${BACKUP_CFLAGS}
117LIBS=${BACKUP_LIBS}
118#unset LD_LIBRARY_PATH
119
120
121if test "x$gmp_found" != "xyes"; then
122        if test -n "$gmp_problem"; then
123                AC_MSG_RESULT(problem)
124                echo "Sorry, your GMP version is too old. Disabling."
125        elif test "x$gmp_found" != "xno"; then
126                AC_MSG_RESULT(not found)
127        fi
128        ifelse($3, , :, $3)
129fi
130
131AM_CONDITIONAL(SING_HAVE_GMP, test "x$HAVE_GMP" = "xyes")
132])
Note: See TracBrowser for help on using the repository browser.