Fixed a few typos
[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 Copyright (C) 2012 - 2016 - Scilab Enterprises
6 dnl
7 dnl This file is hereby licensed under the terms of the GNU GPL v2.0,
8 dnl pursuant to article 5.3.4 of the CeCILL v.2.1.
9 dnl This file was originally licensed under the terms of the CeCILL v2.1,
10 dnl and continues to be available under such terms.
11 dnl For more information, see the COPYING file which you should have received
12 dnl along with this program.
13 dnl
14 dnl UMFPACK detection
15 dnl ------------------------------------------------------
16 dnl Check if UMFPACK is usable and working
17 dnl
18 AC_DEFUN([AC_UMFPACK], [
19
20 BLAS_LIBS="$1"
21
22 UMFPACK_OK=no
23 SUITESPARSE=no
24
25 AC_ARG_WITH(umfpack_library,
26                 AC_HELP_STRING([--with-umfpack-library=DIR],[Set the path to the UMFPACK libraries]),
27                 [with_umfpack_library=$withval],
28                 [with_umfpack_library='yes']
29                 )
30
31 AC_ARG_WITH(umfpack_include,
32                 AC_HELP_STRING([--with-umfpack-include=DIR],[Set the path to the UMFPACK headers]),
33                 [with_umfpack_include=$withval],
34                 [with_umfpack_include='yes']
35                 )
36
37 # Include provided... check if you set it as -I/path/ if it can find the header
38 if test "x$with_umfpack_include" != "xyes"; then
39         save_CFLAGS="$CFLAGS"
40         CFLAGS="-I$with_umfpack_include"
41         AC_CHECK_HEADER([suitesparse/umfpack.h],
42         [UMFPACK_CFLAGS="$CFLAGS"; SUITESPARSE=yes],
43         [AC_CHECK_HEADER(
44                                 [umfpack.h],
45                                 [UMFPACK_CFLAGS="$CFLAGS"; SUITESPARSE=no],
46                                 [AC_MSG_ERROR([Cannot find headers (umfpack.h) of the library UMFPACK. Please install the dev package (Debian : libsuitesparse-dev)])
47         ])
48         ])
49         CFLAGS="$save_CFLAGS"
50 fi
51
52 # Look in the default paths
53 if test "x$UMFPACK_INCLUDE" = "x" ; then
54     if $WITH_DEVTOOLS; then # Scilab thirparties
55         UMFPACK_CFLAGS="-I$DEVTOOLS_INCDIR"
56     else
57         AC_CHECK_HEADER([suitesparse/umfpack.h],
58             [SUITESPARSE=yes],
59             [AC_CHECK_HEADER(
60                 [umfpack.h],
61                 [SUITESPARSE=no],
62                 [AC_MSG_ERROR([Cannot find headers (umfpack.h) of the library UMFPACK. Please install the dev package (Debian : libsuitesparse-dev)])
63                 ])
64             ])
65     fi
66 fi
67
68 # --with-umfpack-library set then check in this dir
69 if test "x$with_umfpack_library" != "xyes"; then
70         AC_MSG_CHECKING([for umfpack_di_solve in $with_umfpack_library])
71         save_LIBS="$LIBS"
72         LIBS="$BLAS_LIBS -L$with_umfpack_library -lm $LIBS"
73         # We need -lm because sometimes (ubuntu 7.10 for example) does not link libamd against lib math
74
75         AC_CHECK_LIB([umfpack], [umfpack_di_solve],
76                         [UMFPACK_LIB="-L$with_umfpack_library -lumfpack $UMFPACK_LIB"; UMFPACK_OK=yes],
77             [AC_MSG_ERROR([libumfpack : Library missing. (Cannot find umfpack_di_solve). Check if libumfpack is installed and if the version is correct (also called lib suitesparse)])]
78                         )
79
80 #       AC_TRY_LINK_FUNC(umfpack_di_solve, [UMFPACK_OK=yes; BLAS_TYPE="Using BLAS_LIBS environment variable"], [UMFPACK_LIBS=""])
81         AC_MSG_RESULT($UMFPACK_OK)
82         LIBS="$save_LIBS"
83 fi
84
85 # check in the default path
86 if test $UMFPACK_OK = no; then
87     if $WITH_DEVTOOLS; then # Scilab thirparties
88         UMFPACK_LIB="-L$DEVTOOLS_LIBDIR -lumfpack -lamd"
89     else
90         save_LIBS="$LIBS"
91         LIBS="$BLAS_LIBS $LIBS -lm" # libamd* is mandatory to link umfpack
92         # We need -lm because sometimes (ubuntu 7.10 for example) does not link libamd against lib math
93
94         AC_CHECK_LIB([amd], [amd_info],
95             [UMFPACK_LIB="-lamd"],
96             [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])]
97             )
98         LIBS="$UMFPACK_LIB $LIBS"
99         AC_CHECK_LIB([umfpack], [umfpack_di_solve],
100             [UMFPACK_LIB="-lumfpack $UMFPACK_LIB"; UMFPACK_OK=yes],
101             [AC_MSG_ERROR([libumfpack: Library missing. (Cannot find symbol umfpack_di_solve). Check if libumfpack is installed and if the version is correct (also called lib suitesparse)])]
102             )
103         LIBS="$save_LIBS"
104     fi
105 fi
106
107 AC_SUBST(UMFPACK_LIB)
108 AC_SUBST(UMFPACK_CFLAGS)
109 if test $SUITESPARSE = yes; then
110    AC_DEFINE_UNQUOTED([UMFPACK_SUITESPARSE],[] , [If it is UMFPACK/Suitesparse or UMFPACK standalone])
111 fi
112
113 AC_DEFINE([WITH_UMFPACK], [], [With the UMFPACK library])
114
115 ])