diff m4/acinclude.m4 @ 21160:b5b531ba93ce

build: Use configure-time test to check CXSparse version. * configure.ac: Call OCTAVE_CHECK_CXSPARSE_VERSION_OK macro and error out of configure if version is < 2.2. * acinclude.m4 (OCTAVE_CHECK_CXSPARSE_VERSION_OK) : New macro. * oct-sparse.h: Remove compie-time test for CXSparse version.
author Rik <rik@octave.org>
date Sat, 30 Jan 2016 20:48:21 -0800
parents f090661930ba
children e7fda94aec6b
line wrap: on
line diff
--- a/m4/acinclude.m4	Tue Jan 19 12:31:06 2016 +1100
+++ b/m4/acinclude.m4	Sat Jan 30 20:48:21 2016 -0800
@@ -180,6 +180,45 @@
   fi
 ])
 dnl
+dnl Check whether CXSparse is version 2.2 or later
+dnl FIXME: This test uses a version number.  It potentially could
+dnl        be re-written to actually call a function, but is it worth it?
+dnl
+AC_DEFUN([OCTAVE_CHECK_CXSPARSE_VERSION_OK], [
+  AC_CACHE_CHECK([whether CXSparse is version 2.2 or later],
+    [octave_cv_cxsparse_version_ok],
+    [AC_LANG_PUSH(C++)
+    ac_octave_save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS"
+    AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
+        #if defined (HAVE_SUITESPARSE_CS_H)
+        #include <suitesparse/cs.h>
+        #elif defined (HAVE_UFSPARSE_CS_H)
+        #include <ufsparse/cs.h>
+        #elif defined (HAVE_CXSPARSE_CS_H)
+        #include <cxsparse/cs.h>
+        #elif defined (HAVE_CS_H)
+        #include <cs.h>
+        #endif
+        ]], [[
+        #if (defined (HAVE_CXSPARSE) \
+             && (! defined (CS_VER) \
+                 || CS_VER < 2 \
+                 || (CS_VER == 2 && CS_SUBVER < 2)))
+        #error "Octave requires CXSparse version 2.2 or later"
+        #endif
+        ]])],
+      octave_cv_cxsparse_version_ok=yes,
+      octave_cv_cxsparse_version_ok=no)
+    CPPFLAGS="$ac_octave_save_CPPFLAGS"
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_cxsparse_version_ok = yes; then
+    AC_DEFINE(HAVE_CXSPARSE_VERSION_OK, 1,
+      [Define to 1 if CXSparse is version 2.2 or later.])
+  fi
+])
+dnl
 dnl Check whether the FFTW library supports multi-threading. This macro
 dnl should be called once per FFTW precision passing in the library
 dnl variant (e.g. "fftw3") and a function in the thread support API