1 | # Check for GMP |
---|
2 | # Modified by Pascal Giorgi, 2003-12-03 |
---|
3 | |
---|
4 | dnl LB_CHECK_GMP ([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
---|
5 | dnl |
---|
6 | dnl Test for the GNU Multiprecision library and define GMP_CFLAGS and GMP_LIBS |
---|
7 | |
---|
8 | AC_DEFUN([LB_CHECK_GMP], |
---|
9 | [ |
---|
10 | DEFAULT_CHECKING_PATH="/usr /usr/local" |
---|
11 | |
---|
12 | AC_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 | |
---|
27 | min_gmp_version=ifelse([$1], ,3.1.1,$1) |
---|
28 | |
---|
29 | dnl Check for existence |
---|
30 | BACKUP_CFLAGS=${CFLAGS} |
---|
31 | BACKUP_LIBS=${LIBS} |
---|
32 | |
---|
33 | AC_MSG_CHECKING(for GMP >= $min_gmp_version) |
---|
34 | |
---|
35 | for 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" -a "x$GMP_HOME" != "x/usr/local"; then |
---|
40 | GMP_CFLAGS="-I${GMP_HOME}/include" |
---|
41 | GMP_LIBS="-L${GMP_HOME}/lib -lgmp" |
---|
42 | else |
---|
43 | GMP_CFLAGS= |
---|
44 | GMP_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 |
---|
106 | done |
---|
107 | |
---|
108 | if 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) |
---|
116 | fi |
---|
117 | |
---|
118 | |
---|
119 | CFLAGS=${BACKUP_CFLAGS} |
---|
120 | LIBS=${BACKUP_LIBS} |
---|
121 | #unset LD_LIBRARY_PATH |
---|
122 | |
---|
123 | ]) |
---|