Revert "* Bug #13585 fixed - suitesparse 4.3.1 was not supported."
[scilab.git] / scilab / m4 / umfpack.m4
1 dnl
2 dnl Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 dnl Copyright (C) INRIA - 2008 - Sylvestre Ledru
4 dnl 
5 dnl This file must be used under the terms of the CeCILL.
6 dnl This source file is licensed as described in the file COPYING, which
7 dnl you should have received as part of this distribution.  The terms
8 dnl are also available at    
9 dnl http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
10 dnl
11 dnl UMFPACK detection
12 dnl ------------------------------------------------------
13 dnl Check if UMFPACK is usable and working
14 dnl
15 AC_DEFUN([AC_UMFPACK], [
16
17 BLAS_LIBS="$1"
18
19 UMFPACK_OK=no
20 SUITESPARSE=no
21
22 AC_ARG_WITH(umfpack_library,
23                 AC_HELP_STRING([--with-umfpack-library=DIR],[Set the path to the UMFPACK libraries]),
24                 [with_umfpack_library=$withval],
25                 [with_umfpack_library='yes']
26                 )
27
28 AC_ARG_WITH(umfpack_include,
29                 AC_HELP_STRING([--with-umfpack-include=DIR],[Set the path to the UMFPACK headers]),
30                 [with_umfpack_include=$withval],
31                 [with_umfpack_include='yes']
32                 )
33
34 # Include provided... check if you set it as -I/path/ if it can find the header
35 if test "x$with_umfpack_include" != "xyes"; then
36         save_CFLAGS="$CFLAGS"
37         CFLAGS="-I$with_umfpack_include"
38         AC_CHECK_HEADER([suitesparse/umfpack.h],
39         [UMFPACK_CFLAGS="$CFLAGS"; SUITESPARSE=yes],
40         [AC_CHECK_HEADER(
41                                 [umfpack.h],
42                                 [UMFPACK_CFLAGS="$CFLAGS"; SUITESPARSE=no],
43                                 [AC_MSG_ERROR([Cannot find headers (umfpack.h) of the library UMFPACK. Please install the dev package (Debian : libsuitesparse-dev)])
44         ])
45         ])
46         CFLAGS="$save_CFLAGS"
47 fi
48
49 # Look in the default paths
50 if test "x$UMFPACK_INCLUDE" = "x" ; then 
51 AC_CHECK_HEADER([suitesparse/umfpack.h],
52         [SUITESPARSE=yes],
53         [AC_CHECK_HEADER(
54                                 [umfpack.h],
55                                 [SUITESPARSE=no],
56                                 [AC_MSG_ERROR([Cannot find headers (umfpack.h) of the library UMFPACK. Please install the dev package (Debian : libsuitesparse-dev)])
57         ])
58         ])
59 fi
60
61 # --with-umfpack-library set then check in this dir
62 if test "x$with_umfpack_library" != "xyes"; then
63         AC_MSG_CHECKING([for umf_divcomplex in $with_umfpack_library])
64         save_LIBS="$LIBS"
65         LIBS="$BLAS_LIBS -L$with_umfpack_library -lm $LIBS"
66         # We need -lm because sometime (ubuntu 7.10 for example) does not link libamd against lib math
67
68         AC_CHECK_LIB([umfpack], [umf_divcomplex],
69                         [UMFPACK_LIB="-L$with_umfpack_library -lumfpack $UMFPACK_LIB"; UMFPACK_OK=yes],
70             [AC_MSG_ERROR([libumfpack : Library missing. (Cannot find umf_divcomplex). Check if libumfpack is installed and if the version is correct (also called lib suitesparse)])]
71                         )
72
73 #       AC_TRY_LINK_FUNC(umf_divcomplex, [UMFPACK_OK=yes; BLAS_TYPE="Using BLAS_LIBS environment variable"], [UMFPACK_LIBS=""])
74         AC_MSG_RESULT($UMFPACK_OK)
75         LIBS="$save_LIBS"
76 fi
77
78 # check in the default path
79 if test $UMFPACK_OK = no; then
80         save_LIBS="$LIBS"
81         LIBS="$BLAS_LIBS $LIBS -lm" # libamd* is mandatory to link umfpack
82         # We need -lm because sometime (ubuntu 7.10 for example) does not link libamd against lib math
83
84         AC_CHECK_LIB([amd], [amd_info],
85                         [UMFPACK_LIB="-lamd"],
86             [AC_MSG_ERROR([libamd: Library missing (Cannot find symbol amd_info). Check if libamd (sparse matrix minimum degree ordering) is installed and if the version is correct])]
87                         )
88         LIBS="$UMFPACK_LIB $LIBS"
89         AC_CHECK_LIB([umfpack], [umf_divcomplex],
90                         [UMFPACK_LIB="-lumfpack $UMFPACK_LIB"; UMFPACK_OK=yes],
91             [AC_MSG_ERROR([libumfpack: Library missing. (Cannot find symbol umf_divcomplex). Check if libumfpack is installed and if the version is correct (also called lib suitesparse)])]
92                         )
93                 LIBS="$save_LIBS"
94 fi
95
96 AC_SUBST(UMFPACK_LIB)
97 AC_SUBST(UMFPACK_CFLAGS)
98 if test $SUITESPARSE = yes; then
99         AC_DEFINE_UNQUOTED([UMFPACK_SUITESPARSE],[] , [If it is UMFPACK/Suitesparse or UMFPACK standalone])
100 fi
101
102 AC_DEFINE([WITH_UMFPACK], [], [With the UMFPACK library])
103
104 ])