changeset 23980:eb6602171d59

configure: make SUNDIALS double precision test cross-compile-safe (bug #51904) * m4/acinclude.m4 (OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE): Rename macro, rewrite test to use AC_COMPILE_IFELSE to be cross-compile-safe. Rename internal variables for clarity. Delete unused HAVE_SUNDIALS_IDA_DOUBLE. * configure.ac: Use new macro and variable names.
author Mike Miller <mtmiller@octave.org>
date Thu, 31 Aug 2017 11:36:36 -0700
parents fb9b024a6041
children 6420142ff32c
files configure.ac m4/acinclude.m4
diffstat 2 files changed, 13 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Thu Aug 31 15:33:45 2017 -0400
+++ b/configure.ac	Thu Aug 31 11:36:36 2017 -0700
@@ -2212,7 +2212,7 @@
   [ida/ida.h ida.h], [IDAInit],
   [], [don't use Sundials IDA library, solvers ode15i and ode15s will be disabled],
   [warn_sundials_ida=
-   OCTAVE_CHECK_SIZEOF_SUNDIALS_IDA_REALTYPE
+   OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE
    OCTAVE_CHECK_SUNDIALS_IDAKLU])
 LIBS="$save_LIBS"
 
@@ -2220,7 +2220,7 @@
 ## the build features script will get the correct value.
 if test -n "$SUNDIALS_IDA_LIBS" \
     && test -n "$SUNDIALS_NVECSERIAL_LIBS" \
-    && test $octave_cv_sizeof_ida_double = yes; then
+    && test $octave_cv_sundials_realtype_is_double = yes; then
   AC_DEFINE(HAVE_SUNDIALS, 1, [Define Sundials is available.])
 fi
 
--- a/m4/acinclude.m4	Thu Aug 31 15:33:45 2017 -0400
+++ b/m4/acinclude.m4	Thu Aug 31 11:36:36 2017 -0700
@@ -1601,10 +1601,11 @@
 dnl Check whether Sundials IDA library is configured with double
 dnl precision realtype.
 dnl
-AC_DEFUN([OCTAVE_CHECK_SIZEOF_SUNDIALS_IDA_REALTYPE], [
+AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE], [
+  AC_CHECK_HEADERS([ida/ida.h ida.h])
   AC_CACHE_CHECK([whether Sundials IDA is configured with double precision realtype],
-    [octave_cv_sizeof_ida_double],
-    [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+    [octave_cv_sundials_realtype_is_double],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
         #if defined (HAVE_IDA_IDA_H)
         #include <ida/ida.h>
         #else
@@ -1612,17 +1613,15 @@
         #endif
         #include <assert.h>
         ]], [[
-        assert (sizeof (double) == sizeof (realtype));
+        static_assert (sizeof (realtype) == sizeof (double),
+                       "SUNDIALS is not configured for double precision");
       ]])],
-      octave_cv_sizeof_ida_double=yes,
-      octave_cv_sizeof_ida_double=no)
+      octave_cv_sundials_realtype_is_double=yes,
+      octave_cv_sundials_realtype_is_double=no)
   ])
-  if test $octave_cv_sizeof_ida_double = yes; then
-    AC_DEFINE(HAVE_SUNDIALS_IDA_DOUBLE, 1,
-      [Define to 1 if Sundials IDA is configured with realtype as double.])
-  else
-    warn_sundials_ida_double="Sundials IDA library not configured with double precision realtype, ode15i and ode15s will be disabled"
-    OCTAVE_CONFIGURE_WARNING([warn_sundials_ida_double])
+  if test $octave_cv_sundials_realtype_is_double = no; then
+    warn_sundials_realtype="Sundials IDA library not configured with double precision realtype, ode15i and ode15s will be disabled"
+    OCTAVE_CONFIGURE_WARNING([warn_sundials_realtype])
   fi
 ])
 dnl