summaryrefslogtreecommitdiff
path: root/m4/umfpack.m4
blob: 8fe4a02bc3f804a753edba7be28060d38aa75501 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
dnl
dnl Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
dnl Copyright (C) INRIA - 2008 - Sylvestre Ledru
dnl 
dnl This file must be used under the terms of the CeCILL.
dnl This source file is licensed as described in the file COPYING, which
dnl you should have received as part of this distribution.  The terms
dnl are also available at    
dnl http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
dnl
dnl UMFPACK detection
dnl ------------------------------------------------------
dnl Check if UMFPACK is usable and working
dnl
AC_DEFUN([AC_UMFPACK], [

BLAS_LIBS="$1"

UMFPACK_OK=no
SUITESPARSE=no

AC_ARG_WITH(umfpack_library,
		AC_HELP_STRING([--with-umfpack-library=DIR],[Set the path to the UMFPACK libraries]),
		[with_umfpack_library=$withval],
		[with_umfpack_library='yes']
		)

AC_ARG_WITH(umfpack_include,
		AC_HELP_STRING([--with-umfpack-include=DIR],[Set the path to the UMFPACK headers]),
		[with_umfpack_include=$withval],
		[with_umfpack_include='yes']
		)

# Include provided... check if you set it as -I/path/ if it can find the header
if test "x$with_umfpack_include" != "xyes"; then
	save_CFLAGS="$CFLAGS"
	CFLAGS="-I$with_umfpack_include"
	AC_CHECK_HEADER([suitesparse/umfpack.h],
	[UMFPACK_CFLAGS="$CFLAGS"; SUITESPARSE=yes],
	[AC_CHECK_HEADER(
				[umfpack.h],
				[UMFPACK_CFLAGS="$CFLAGS"; SUITESPARSE=no],
				[AC_MSG_ERROR([Cannot find headers (umfpack.h) of the library UMFPACK. Please install the dev package (Debian : libsuitesparse-dev)])
	])
	])
	CFLAGS="$save_CFLAGS"
fi

# Look in the default paths
if test "x$UMFPACK_INCLUDE" = "x" ; then
    if $WITH_DEVTOOLS; then # Scilab thirparties
        UMFPACK_CFLAGS="-I$DEVTOOLS_INCDIR"
    else
        AC_CHECK_HEADER([suitesparse/umfpack.h],
            [SUITESPARSE=yes],
            [AC_CHECK_HEADER(
                [umfpack.h],
                [SUITESPARSE=no],
                [AC_MSG_ERROR([Cannot find headers (umfpack.h) of the library UMFPACK. Please install the dev package (Debian : libsuitesparse-dev)])
                ])
            ])
    fi
fi

# --with-umfpack-library set then check in this dir
if test "x$with_umfpack_library" != "xyes"; then
	AC_MSG_CHECKING([for umfpack_di_solve in $with_umfpack_library])
	save_LIBS="$LIBS"
	LIBS="$BLAS_LIBS -L$with_umfpack_library -lm $LIBS"
	# We need -lm because sometime (ubuntu 7.10 for example) does not link libamd against lib math

	AC_CHECK_LIB([umfpack], [umfpack_di_solve],
			[UMFPACK_LIB="-L$with_umfpack_library -lumfpack $UMFPACK_LIB"; UMFPACK_OK=yes],
            [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)])]
			)

#	AC_TRY_LINK_FUNC(umfpack_di_solve, [UMFPACK_OK=yes; BLAS_TYPE="Using BLAS_LIBS environment variable"], [UMFPACK_LIBS=""])
	AC_MSG_RESULT($UMFPACK_OK)
	LIBS="$save_LIBS"
fi

# check in the default path
if test $UMFPACK_OK = no; then
    if $WITH_DEVTOOLS; then # Scilab thirparties
        UMFPACK_LIB="-L$DEVTOOLS_LIBDIR -lumfpack -lamd"
    else
        save_LIBS="$LIBS"
        LIBS="$BLAS_LIBS $LIBS -lm" # libamd* is mandatory to link umfpack
        # We need -lm because sometime (ubuntu 7.10 for example) does not link libamd against lib math

        AC_CHECK_LIB([amd], [amd_info],
            [UMFPACK_LIB="-lamd"],
            [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])]
            )
        LIBS="$UMFPACK_LIB $LIBS"
        AC_CHECK_LIB([umfpack], [umfpack_di_solve],
            [UMFPACK_LIB="-lumfpack $UMFPACK_LIB"; UMFPACK_OK=yes],
            [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)])]
            )
        LIBS="$save_LIBS"
    fi
fi

AC_SUBST(UMFPACK_LIB)
AC_SUBST(UMFPACK_CFLAGS)
if test $SUITESPARSE = yes; then
   AC_DEFINE_UNQUOTED([UMFPACK_SUITESPARSE],[] , [If it is UMFPACK/Suitesparse or UMFPACK standalone])
fi

AC_DEFINE([WITH_UMFPACK], [], [With the UMFPACK library])

])