1 | # Check for FLINT |
---|
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 | |
---|
11 | dnl LB_CHECK_FLINT ([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
---|
12 | dnl |
---|
13 | dnl Test for FLINT and define |
---|
14 | dnl FLINT_CFLAGS and FLINT_LIBS |
---|
15 | |
---|
16 | AC_DEFUN([LB_CHECK_FLINT], |
---|
17 | [ |
---|
18 | DEFAULT_CHECKING_PATH="/usr /usr/local /sw /opt/local" |
---|
19 | |
---|
20 | AC_ARG_WITH(flint, |
---|
21 | [ --with-flint=<path>|yes|no Use FLINT library. If argument is no, you do not have |
---|
22 | the library installed on your machine (set as |
---|
23 | default). If argument is yes or <empty> that means |
---|
24 | the library is reachable with the standard search |
---|
25 | path (/usr or /usr/local). Otherwise you give the |
---|
26 | <path> to the directory which contain the library. |
---|
27 | ], |
---|
28 | [if test "$withval" = yes ; then |
---|
29 | FLINT_HOME_PATH="${DEFAULT_CHECKING_PATH}" |
---|
30 | elif test "$withval" != no ; then |
---|
31 | FLINT_HOME_PATH="$withval" |
---|
32 | fi], |
---|
33 | [FLINT_HOME_PATH="${DEFAULT_CHECKING_PATH}"]) |
---|
34 | |
---|
35 | min_flint_version=ifelse([$1], ,2.3,$1) |
---|
36 | |
---|
37 | |
---|
38 | dnl Check for existence |
---|
39 | BACKUP_CFLAGS=${CFLAGS} |
---|
40 | BACKUP_LIBS=${LIBS} |
---|
41 | |
---|
42 | AC_LANG_PUSH(C) |
---|
43 | |
---|
44 | if test -n "$FLINT_HOME_PATH"; then |
---|
45 | AC_MSG_CHECKING(for FLINT >= $min_flint_version) |
---|
46 | fi |
---|
47 | |
---|
48 | for FLINT_HOME in ${FLINT_HOME_PATH} |
---|
49 | do |
---|
50 | if test -r "$FLINT_HOME/include/fmpz.h"; then |
---|
51 | |
---|
52 | if test "x$FLINT_HOME" != "x/usr"; then |
---|
53 | FLINT_CFLAGS="-I${FLINT_HOME}/include" |
---|
54 | FLINT_LIBS="-L${FLINT_HOME}/lib -lflint -lmpfr -lmpir" |
---|
55 | else |
---|
56 | FLINT_CFLAGS= |
---|
57 | FLINT_LIBS="-lflint" |
---|
58 | fi |
---|
59 | CFLAGS="${BACKUP_CFLAGS} ${FLINT_CFLAGS}" |
---|
60 | LIBS="${BACKUP_LIBS} ${FLINT_LIBS}" |
---|
61 | |
---|
62 | AC_TRY_LINK( |
---|
63 | [#include <fmpz.h>], |
---|
64 | [fmpz_t a; fmpz_init (a);], |
---|
65 | [ |
---|
66 | AC_TRY_RUN( |
---|
67 | [#include <flint.h> |
---|
68 | int main () { if ((int) version[0] < 2) return -1; else return 0; } |
---|
69 | ],[ |
---|
70 | flint_found="yes" |
---|
71 | break |
---|
72 | ],[ |
---|
73 | flint_problem="$problem $FLINT_HOME" |
---|
74 | unset FLINT_CFLAGS |
---|
75 | unset FLINT_LIBS |
---|
76 | ],[ |
---|
77 | flint_found="yes" |
---|
78 | flint_cross="yes" |
---|
79 | break |
---|
80 | ]) |
---|
81 | ], |
---|
82 | [ |
---|
83 | flint_found="no" |
---|
84 | flint_checked="$checked $FLINT_HOME" |
---|
85 | unset FLINT_CFLAGS |
---|
86 | unset FLINT_LIBS |
---|
87 | ]) |
---|
88 | else |
---|
89 | flint_found="no" |
---|
90 | fi |
---|
91 | done |
---|
92 | |
---|
93 | if test "x$flint_found" = "xyes" ; then |
---|
94 | AC_SUBST(FLINT_CFLAGS) |
---|
95 | AC_SUBST(FLINT_LIBS) |
---|
96 | AC_SUBST(FLINT_HOME) |
---|
97 | AC_DEFINE(HAVE_FLINT,1,[Define if FLINT is installed]) |
---|
98 | HAVE_FLINT=yes |
---|
99 | if test "x$flint_cross" != "xyes"; then |
---|
100 | AC_MSG_RESULT(found) |
---|
101 | else |
---|
102 | AC_MSG_RESULT(unknown) |
---|
103 | echo "WARNING: You appear to be cross compiling, so there is no way to determine" |
---|
104 | echo "whether your FLINT version is new enough. I am assuming it is." |
---|
105 | fi |
---|
106 | ifelse([$2], , :, [$2]) |
---|
107 | elif test -n "$flint_problem"; then |
---|
108 | AC_MSG_RESULT(problem) |
---|
109 | echo "Sorry, your FLINT version is too old. Disabling." |
---|
110 | ifelse([$3], , :, [$3]) |
---|
111 | elif test "x$flint_found" = "xno"; then |
---|
112 | AC_MSG_RESULT(not found) |
---|
113 | ifelse([$3], , :, [$3]) |
---|
114 | fi |
---|
115 | |
---|
116 | AC_LANG_POP |
---|
117 | |
---|
118 | AM_CONDITIONAL(SING_HAVE_FLINT, test "x$HAVE_FLINT" = "xyes") |
---|
119 | |
---|
120 | CFLAGS=${BACKUP_CFLAGS} |
---|
121 | LIBS=${BACKUP_LIBS} |
---|
122 | #unset LD_LIBRARY_PATH |
---|
123 | |
---|
124 | ]) |
---|
125 | |
---|