f03e6b46ffc7a84c355cb86d37b8eae89f66d586
[scilab.git] / scilab / modules / dynamic_link / src / scripts / m4 / eigen.m4
1 dnl Because this macro is used by AC_PROG_GCC_TRADITIONAL, which must
2 dnl come early, it is not included in AC_BEFORE checks.
3 dnl AC_GREP_CPP(PATTERN, PROGRAM, [ACTION-IF-FOUND [,
4 dnl              ACTION-IF-NOT-FOUND]])
5 AC_DEFUN([AC_GREP_CPP],
6 [AC_REQUIRE_CPP()dnl
7 cat > conftest.$ac_ext <<EOF
8 [#]line __oline__ "configure"
9 #include "confdefs.h"
10 [$2]
11 EOF
12 dnl eval is necessary to expand ac_cpp.
13 dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
14 if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
15 dnl Prevent m4 from eating character classes:
16 changequote(, )dnl
17   grep "$1" >/dev/null 2>&1; then
18 changequote([, ])dnl
19   ifelse([$3], , :, [rm -rf conftest*
20   $3])
21 ifelse([$4], , , [else
22   rm -rf conftest*
23   $4
24 ])dnl
25 fi
26 rm -f conftest*
27 ])
28
29 dnl
30 dnl Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
31 dnl Copyright (C) INRIA - 2008 - Sylvestre Ledru
32 dnl 
33 dnl This file must be used under the terms of the CeCILL.
34 dnl This source file is licensed as described in the file COPYING, which
35 dnl you should have received as part of this distribution.  The terms
36 dnl are also available at    
37 dnl http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
38 dnl
39 dnl AC_EIGEN
40 dnl ------------------------------------------------------
41 dnl Check if EIGEN is usable and working
42 dnl
43 AC_DEFUN([AC_EIGEN], [
44 AC_LANG_PUSH([C++])
45
46 AC_ARG_WITH(eigen_include,
47                 AC_HELP_STRING([--with-eigen-include=DIR],[Set the path to the EIGEN headers]),
48                 [with_eigen_include=$withval],
49                 [with_eigen_include='yes']
50                 )
51
52
53 save_CPPFLAGS="$CPPFLAGS"
54
55 if test "x$with_eigen_include" != "xyes"; then
56         CPPFLAGS="-I$with_eigen_include"
57         AC_CHECK_HEADER([Eigen/Sparse],
58                 [EIGEN_CPPFLAGS="$CPPFLAGS"],
59                 [AC_MSG_ERROR([Cannot find headers (Eigen/Sparse) of the library EIGEN in $with_eigen_include. Please install the dev package (Debian : libeigen3-dev)])]
60         )
61     PATH_TO_EIGEN=$with_eigen_include
62 else
63         AC_CHECK_HEADER([Eigen/Sparse],
64                 [EIGEN_CPPFLAGS=""],
65                 [       $as_unset ac_cv_header_Eigen_Sparse 
66                 CPPFLAGS="-I/usr/include/eigen3/"
67                 AC_CHECK_HEADER([Eigen/Sparse],
68                                 [EIGEN_CPPFLAGS=$CPPFLAGS],
69                                 AC_MSG_ERROR([Cannot find headers (Eigen/Sparse) of the library eigen. Please install the dev package (Debian : libeigen3-dev)])
70                 )
71          ])
72     PATH_TO_EIGEN="/usr/include/eigen3/"
73 fi
74 CPPFLAGS="$save_CPPFLAGS"
75
76 CHK_EIGEN_WORLD=3
77 CHK_EIGEN_MAJOR=1
78 CHK_EIGEN_MINOR=0
79
80 AC_MSG_CHECKING([if Eigen is version $CHK_EIGEN_WORLD.$CHK_EIGEN_MAJOR.$CHK_EIGEN_MINOR or later])
81 AC_GREP_CPP(EIGEN_VERSION_OK,
82 [
83 #include "$PATH_TO_EIGEN/Eigen/Sparse"
84 #if EIGEN_VERSION_AT_LEAST(3,1,0)
85 EIGEN_VERSION_OK
86 #endif
87 ],\
88 EIGEN_VERSION_OK=1,\
89 EIGEN_VERSION_OK=0 )
90 if test $EIGEN_VERSION_OK = 0; then
91    AC_MSG_ERROR([Version $CHK_EIGEN_WORLD.$CHK_EIGEN_MAJOR.$CHK_EIGEN_MINOR of Eigen expected (at least)])
92 else
93    AC_MSG_RESULT([yes])
94 fi
95 AC_SUBST(EIGEN_CPPFLAGS)
96
97 AC_DEFINE([WITH_EIGEN], [], [With the EIGEN library])
98 AC_LANG_POP([C++])
99 ])