changeset 22986:21707d6a02c7

make --enable-64 the default * m4/octave_blas_f77_func.m4: Rename from ax_blas_f77_func.m4. Determine integer size used by BLAS library instead of checking to see whether it matches the default Fortran integer size. * m4/module.mk: Update. * acinclude.m4 (OCTAVE_CHECK_SIZEOF_FORTRAN_INTEGER): Determine size of Fortran INTEGER instead of checking to see whether it matches what we expect. * configure.ac: Make --enable-64 the default, but change it to mean setting the size of Octave's index type. Check for the size of the BLAS library integer type and ensure the Fortran compiler uses the same size for integers. * NEWS: Note change in --enable-64 default. * doc/interpreter/install.txi: Update.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Dec 2016 13:45:10 -0500
parents a8e83b0144fe
children 4643c8bce4e7
files NEWS configure.ac doc/interpreter/install.txi m4/acinclude.m4 m4/ax_blas_f77_func.m4 m4/module.mk m4/octave_blas_f77_func.m4
diffstat 7 files changed, 428 insertions(+), 427 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Dec 30 10:36:35 2016 -0500
+++ b/NEWS	Fri Dec 30 13:45:10 2016 -0500
@@ -1,6 +1,12 @@
 Summary of important user-visible changes for version 4.4:
 ---------------------------------------------------------
 
+ ** On systems with 64-bit pointers, --enable-64 is now the default and
+    Octave always uses 64-bit indexing.  However, if the configure
+    script determines that the BLAS library uses 32-bit integers, then
+    operations using the following libraries are limited to arrays with
+    dimensions that are smaller than 2^31 elements:
+
  ** Other new functions added in 4.4:
 
       gsvd
--- a/configure.ac	Fri Dec 30 10:36:35 2016 -0500
+++ b/configure.ac	Fri Dec 30 13:45:10 2016 -0500
@@ -333,34 +333,42 @@
 
 ### If possible, use a 64-bit integer type for array dimensions and indexing.
 
-ENABLE_64=no
-OCTAVE_IDX_TYPE=int
+AC_CHECK_SIZEOF([void *])
+if test $ac_cv_sizeof_void_p -ge 8; then
+  OCTAVE_IDX_TYPE=int64_t
+  ENABLE_64=yes
+else
+  OCTAVE_IDX_TYPE=int32_t
+  ENABLE_64=no
+fi
+     
 AC_ARG_ENABLE(64,
-  [AS_HELP_STRING([--enable-64],
-    [(EXPERIMENTAL) use 64-bit integers for array dimensions and indexing])],
-  [if test "$enableval" = yes; then ENABLE_64=yes; fi], [])
+  [AS_HELP_STRING([--disable-64],
+    [don't use 64-bit integers for array dimensions and indexing])],
+  [case $enableval in
+     yes) ENABLE_64=yes ;;
+     no) ENABLE_64=no ;;
+     *) AC_MSG_ERROR([bad value $enableval for --enable-64]) ;;
+   esac])
+
 if test $ENABLE_64 = yes; then
-  AC_CHECK_SIZEOF([void *])
-  if test $ac_cv_sizeof_void_p -eq 8; then
-    OCTAVE_IDX_TYPE=int64_t
-  else
-    warn_64_bit="pointers are not 64-bits wide; disabling 64-bit features"
+  if test $ac_cv_sizeof_void_p -lt 8; then
+    warn_64_bit="--enable-64 option given but pointers are less than 64-bits wide; disabling 64-bit indexing"
     OCTAVE_CONFIGURE_WARNING([warn_64_bit])
+    OCTAVE_IDX_TYPE=int32_t
     ENABLE_64=no
   fi
 fi
-AC_SUBST(OCTAVE_IDX_TYPE)
-AC_DEFINE_UNQUOTED(OCTAVE_IDX_TYPE, [$OCTAVE_IDX_TYPE],
-  [Define to the type of octave_idx_type (64 or 32 bit signed integer).])
-OCTAVE_F77_INT_TYPE=$OCTAVE_IDX_TYPE
-AC_SUBST(OCTAVE_F77_INT_TYPE)
-AC_DEFINE_UNQUOTED(OCTAVE_F77_INT_TYPE, [$OCTAVE_F77_INT_TYPE],
-  [Define to the type of octave_f77_int_type (64 or 32 bit signed integer).])
+
+AC_SUBST(ENABLE_64)
 if test $ENABLE_64 = yes; then
   AC_DEFINE(OCTAVE_ENABLE_64, 1,
     [Define to 1 if using 64-bit integers for array dimensions and indexing.])
 fi
-AC_SUBST(ENABLE_64)
+
+AC_SUBST(OCTAVE_IDX_TYPE)
+AC_DEFINE_UNQUOTED(OCTAVE_IDX_TYPE, [$OCTAVE_IDX_TYPE],
+  [Define to the type of octave_idx_type (64 or 32 bit signed integer).])
 
 ### It seems that there are some broken inline assembly functions in
 ### the GNU libc.  Since I'm not sure how to test whether we are using
@@ -940,9 +948,100 @@
 fi
 AC_SUBST(F77_ISNAN_MACRO)
 
+### Check for BLAS and LAPACK libraries:
+
+## Need to adjust FFLAGS to include correct integer size.
+save_FFLAGS="$FFLAGS"
+FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"
+
+OCTAVE_BLAS_WITH_F77_FUNC([:], [:],
+  [ax_blas_ok=yes
+  AC_MSG_CHECKING([BLAS can be called from Fortran])
+  AC_MSG_RESULT([yes assumed for cross compilation])])
+AX_LAPACK([:], [:])
+
+## Restore FFLAGS.
+FFLAGS="$save_FFLAGS"
+
+## If necessary, try again with -ff2c in FFLAGS
+if test $ax_blas_ok = no; then
+  save_FFLAGS="$FFLAGS"
+  FFLAGS="-ff2c $FFLAGS $F77_INTEGER_8_FLAG"
+
+  OCTAVE_BLAS_WITH_F77_FUNC([:], [:])
+  AX_LAPACK([:], [:])
+
+  ## Restore FFLAGS, with -ff2c if that was helpful
+
+  if test $ax_blas_ok = yes; then
+    FFLAGS="-ff2c $save_FFLAGS"
+  else
+    FFLAGS="$save_FFLAGS"
+  fi
+fi
+
+## On OSX, try again with a wrapper library (without -ff2c!)
+if test $ax_blas_ok = no; then
+  case $host_os in
+    darwin*)
+      ## test if wrapper functions help
+      octave_blaswrap_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS -DUSE_BLASWRAP"
+      AC_LANG_PUSH(C)
+      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+          #include "liboctave/cruft/misc/blaswrap.c"
+        ]])],
+        [mv conftest.$ac_objext blaswrap.$ac_objext
+         octave_blaswrap_save_BLAS_LIBS="$BLAS_LIBS"
+         BLAS_LIBS="blaswrap.$ac_objext -framework vecLib"
+
+         save_FFLAGS="$FFLAGS"
+         FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"
+
+         OCTAVE_BLAS_WITH_F77_FUNC([:], [:])
+         AX_LAPACK([:], [:])
+
+         ## Restore FFLAGS.
+         FFLAGS="$save_FFLAGS"
+
+         ## remove temp file
+         rm -f blaswrap.$ac_objext],
+        [AC_MSG_FAILURE([cannot compile liboctave/cruft/misc/blaswrap.c])])
+      AC_LANG_POP(C)
+      CFLAGS="$octave_blaswrap_save_CFLAGS"
+
+      if test $ax_blas_ok = no; then
+        BLAS_LIBS="$octave_blaswrap_save_BLAS_LIBS"
+      else
+        ## wrapper in cruft, remove from BLAS_LIBS
+        BLAS_LIBS=`echo $BLAS_LIBS | $SED -e 's/blaswrap.[[^ ]]* //g'`
+        AC_DEFINE(USE_BLASWRAP, 1,
+          [Define to 1 if BLAS functions need to be wrapped (potentially needed for 64-bit OSX only).])
+      fi
+    ;;
+  esac
+fi
+
+if test $ax_blas_ok = no || test $ax_lapack_ok = no; then
+  AC_MSG_ERROR([BLAS and LAPACK libraries are required])
+fi
+
+case $ax_blas_integer_size in
+  4 | 8)
+  ;;
+  *)
+    AC_MSG_ERROR([unrecognized BLAS library integer size])
+  ;;
+esac
+
+if test $ENABLE_64 = yes && test $ax_blas_integer_size -ne 8; then
+  warn_blas_integer_size="Your BLAS library doesn't seem to use 64-bit integers.  Some matrix operations will be limited to arrays with dimensions smaller than 2^31 elements."
+  OCTAVE_CONFIGURE_WARNING([warn_blas_integer_size])
+fi
+
 OCTAVE_CHECK_SIZEOF_FORTRAN_INTEGER
-if test $octave_cv_sizeof_fortran_integer = no; then
-  if test $ENABLE_64 = yes; then
+if test $octave_cv_sizeof_fortran_integer -ne $ax_blas_integer_size; then
+  if test $ax_blas_integer_size -eq 8; then
     case $F77 in
       *gfortran*)
         case $F77_INTEGER_8_FLAG in
@@ -969,15 +1068,27 @@
     if test -z "$octave_cv_sizeof_fortran_integer"; then
       OCTAVE_CHECK_SIZEOF_FORTRAN_INTEGER
     fi
-    if test $octave_cv_sizeof_fortran_integer = no; then
-      AC_MSG_ERROR([to build Octave with 64-bit indexing support your Fortran compiler must have an option for setting the default integer size to 8 bytes.  See the file INSTALL for more information.])
-    fi
-  else
-    AC_MSG_ERROR([your Fortran compiler must have an option to make integers the same size as octave_idx_type ($OCTAVE_IDX_TYPE).  See the file INSTALL for more information.])
+  fi
+  ## We intentionally don't attempt to fix things up if the default
+  ## Fortran integer size is 8 but BLAS appears to use 4-byte integers.
+  if test $octave_cv_sizeof_fortran_integer -ne $ax_blas_integer_size; then
+    AC_MSG_ERROR([your Fortran compiler must have an option for setting the default integer size to be the same size as your BLAS library uses ($ax_blas_integer_size bytes).  See the file INSTALL for more information.])
   fi
 fi
 AC_SUBST(F77_INTEGER_8_FLAG)
 
+case $octave_cv_sizeof_fortran_integer in
+  8)
+    OCTAVE_F77_INT_TYPE=int64_t
+  ;;
+  4)
+    OCTAVE_F77_INT_TYPE=int32_t
+  ;;
+esac
+AC_SUBST(OCTAVE_F77_INT_TYPE)
+AC_DEFINE_UNQUOTED(OCTAVE_F77_INT_TYPE, [$OCTAVE_F77_INT_TYPE],
+  [Define to the type of octave_f77_int_type (64 or 32 bit signed integer).])
+
 OCTAVE_F77_FLAG([-ffloat-store], [
   AC_MSG_RESULT([setting F77_FLOAT_STORE_FLAG to -ffloat-store])
   F77_FLOAT_STORE_FLAG=-ffloat-store
@@ -1924,93 +2035,6 @@
   opengl_graphics=yes
 fi
 
-### Check for BLAS and LAPACK libraries:
-
-## Need to adjust FFLAGS to include correct integer size.
-save_FFLAGS="$FFLAGS"
-FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"
-
-AX_BLAS_WITH_F77_FUNC([:], [:],
-  [ax_blas_ok=yes
-  AC_MSG_CHECKING([BLAS can be called from Fortran])
-  AC_MSG_RESULT([yes assumed for cross compilation])])
-AX_LAPACK([:], [:])
-
-## Restore FFLAGS.
-FFLAGS="$save_FFLAGS"
-
-## If necessary, try again with -ff2c in FFLAGS
-if test $ax_blas_ok = no; then
-  save_FFLAGS="$FFLAGS"
-  FFLAGS="-ff2c $FFLAGS $F77_INTEGER_8_FLAG"
-
-  AX_BLAS_WITH_F77_FUNC([:], [:])
-  AX_LAPACK([:], [:])
-
-  ## Restore FFLAGS, with -ff2c if that was helpful
-
-  if test $ax_blas_ok = yes; then
-    FFLAGS="-ff2c $save_FFLAGS"
-  else
-    FFLAGS="$save_FFLAGS"
-  fi
-fi
-
-## On OSX, try again with a wrapper library (without -ff2c!)
-if test $ax_blas_ok = no; then
-  case $host_os in
-    darwin*)
-      ## test if wrapper functions help
-      octave_blaswrap_save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -DUSE_BLASWRAP"
-      AC_LANG_PUSH(C)
-      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
-          #include "liboctave/cruft/misc/blaswrap.c"
-        ]])],
-        [mv conftest.$ac_objext blaswrap.$ac_objext
-         octave_blaswrap_save_BLAS_LIBS="$BLAS_LIBS"
-         BLAS_LIBS="blaswrap.$ac_objext -framework vecLib"
-
-         save_FFLAGS="$FFLAGS"
-         FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"
-
-         AX_BLAS_WITH_F77_FUNC([:], [:])
-         AX_LAPACK([:], [:])
-
-         ## Restore FFLAGS.
-         FFLAGS="$save_FFLAGS"
-
-         ## remove temp file
-         rm -f blaswrap.$ac_objext],
-        [AC_MSG_FAILURE([cannot compile liboctave/cruft/misc/blaswrap.c])])
-      AC_LANG_POP(C)
-      CFLAGS="$octave_blaswrap_save_CFLAGS"
-
-      if test $ax_blas_ok = no; then
-        BLAS_LIBS="$octave_blaswrap_save_BLAS_LIBS"
-      else
-        ## wrapper in cruft, remove from BLAS_LIBS
-        BLAS_LIBS=`echo $BLAS_LIBS | $SED -e 's/blaswrap.[[^ ]]* //g'`
-        AC_DEFINE(USE_BLASWRAP, 1,
-          [Define to 1 if BLAS functions need to be wrapped (potentially needed for 64-bit OSX only).])
-      fi
-    ;;
-  esac
-fi
-
-if test $ax_blas_ok = no; then
-  if test $ENABLE_64 = yes && test $ax_blas_integer_size_ok = no; then
-    ## Attempt to be more informative.
-    AC_MSG_ERROR([BLAS doesn't seem to support 64-bit integers.  This is incompatible with --enable-64.])
-  else
-    AC_MSG_ERROR([A BLAS library was detected but found incompatible with your Fortran 77 compiler settings.])
-  fi
-fi
-
-if test $ax_blas_ok = no || test $ax_lapack_ok = no; then
-  AC_MSG_ERROR([BLAS and LAPACK libraries are required])
-fi
-
 ### Check for the qrupdate library
 
 ## No need to adjust FFLAGS because only link is attempted.
@@ -3369,22 +3393,6 @@
   fi
 fi
 
-if test $ENABLE_64 = yes; then
-  AC_MSG_WARN([])
-  AC_MSG_WARN([You used the EXPERIMENTAL --enable-64 option.])
-  AC_MSG_WARN([Are you sure that is what you want to do?])
-  AC_MSG_WARN([])
-  AC_MSG_WARN([Your Fortran compiler must have an option to generate])
-  AC_MSG_WARN([code with 8 byte signed INTEGER values.  This option])
-  AC_MSG_WARN([should be specified in the F77_INTEGER_8_FLAG variable])
-  AC_MSG_WARN([Make.  This should work automatically for gfortran.  If])
-  AC_MSG_WARN([you use another compiler, you will need to set this])
-  AC_MSG_WARN([variable on the configure command line.  You must also])
-  AC_MSG_WARN([compile the ARPACK, BLAS, LAPACK, QRUPDATE, and SuiteSparse])
-  AC_MSG_WARN([libraries to use 8 byte signed integers for array indexing.])
-  warn_msg_printed=true
-fi
-
 if test $opengl_graphics = no; then
   AC_MSG_WARN([])
   AC_MSG_WARN([I didn't find the libraries needed to compile Octave])
--- a/doc/interpreter/install.txi	Fri Dec 30 10:36:35 2016 -0500
+++ b/doc/interpreter/install.txi	Fri Dec 30 13:45:10 2016 -0500
@@ -344,12 +344,32 @@
 @item --srcdir=@var{dir}
 Look for Octave sources in the directory @var{dir}.
 
-@item --enable-64
-This is an @strong{experimental} option to enable Octave to use 64-bit
-integers for array dimensions and indexing on 64-bit platforms.  You
-probably don't want to use this option unless you know what you are
-doing.  @xref{Compiling Octave with 64-bit Indexing}, for more details
-about building Octave with this option.
+@item --disable-64
+Disable using 64-bit integers for indexing arrays and use 32-bit
+integers instead.  On systems with 32-bit pointers, this option is
+always disabled.  If he configure script determines that your BLAS
+library uses 32-bit integers, then operations using the following
+libraries are limited to arrays with dimensions that are smaller than
+@math{2^{31}} elements:
+
+@itemize @bullet
+@item @sc{blas}
+@item @sc{lapack}
+@item QRUPDATE
+@item SuiteSparse
+@item @sc{arpack}
+@end itemize
+
+Additionally, the following libraries use @code{int} internally, so
+maximum problem sizes are always limited:
+
+@itemize @bullet
+@item @sc{glpk}
+@item Qhull
+@end itemize
+
+@xref{Compiling Octave with 64-bit Indexing}, for more details
+about building Octave with more complete support for large arrays.
 
 @item --enable-bounds-check
 Enable bounds checking for indexing operators in the internal array
@@ -595,53 +615,37 @@
 Configuring Octave with @option{--enable-64} cannot magically make a
 32-bit system have a 64-bit address space.
 
-On 64-bit systems, Octave is limited to (approximately) the following
-array sizes when using the default 32-bit indexing mode:
-
-@example
-@group
-double:         16 GB
-single:          8 GB
-uint64, int64:  16 GB
-uint32, int32:   8 GB
-uint16, int16:   4 GB
-uint8, int8:     2 GB
-@end group
-@end example
-
-In each case, the limit is really (approximately) @math{2^{31}} elements
-because of the default type of the value used for indexing arrays
-(signed 32-bit integer, corresponding to the size of a Fortran INTEGER
-value).
-
-Trying to create larger arrays will produce the following error:
+On 64-bit systems, Octave uses 64-bit integers for indexing arrays
+by default.  If he configure script determines that your BLAS
+library uses 32-bit integers, then operations using the following
+libraries are limited to arrays with dimensions that are smaller than
+@math{2^{31}} elements:
 
-@example
-@group
-octave:1> a = zeros (1024*1024*1024*3, 1, 'int8');
-error: memory exhausted or requested size too large
-       for range of Octave's index type --
-       trying to return to prompt
-@end group
-@end example
+@itemize @bullet
+@item @sc{blas}
+@item @sc{lapack}
+@item QRUPDATE
+@item SuiteSparse
+@item @sc{arpack}
+@end itemize
 
-@noindent
-You will obtain this error even if your system has enough memory to
-create this array (4 GB in the above case).
+Additionally, the following libraries use @code{int} internally, so
+maximum problem sizes are always limited:
 
-To use arrays larger than 2 GB, Octave has to be configured with the
-option @option{--enable-64}.  This option is experimental and you are
-encouraged to submit bug reports if you find a problem.  With this
-option, Octave will use 64-bit integers internally for array dimensions
-and indexing.  However, all numerical libraries used by Octave will
-@strong{also} need to use 64-bit integers for array dimensions and
-indexing.  In most cases, this means they will need to be compiled from
-source since most (all?) distributions which package these libraries
-compile them with the default Fortran integer size, which is normally
-32-bits wide.
+@itemize @bullet
+@item @sc{glpk}
+@item Qhull
+@end itemize
+
+Except for @sc{glpk} and Qhull, these libraries may also be configured
+to use 64-bit integers, but most systems do not provide packages built
+this way.  If you wish to experiment with large arrays, the following
+information may be helpful.
 
 The following instructions were tested with the development version of
-Octave and GCC 4.3.4 on an x86_64 Debian system.
+Octave and GCC 4.3.4 on an x86_64 Debian system and may be out of date
+now.  Please report any problems or corrections on the Octave bug
+tracker.
 
 The versions listed below are the versions used for testing.  If newer
 versions of these packages are available, you should try to use them,
--- a/m4/acinclude.m4	Fri Dec 30 10:36:35 2016 -0500
+++ b/m4/acinclude.m4	Fri Dec 30 13:45:10 2016 -0500
@@ -1645,57 +1645,33 @@
 ])
 dnl
 dnl Check if the default Fortran INTEGER is 64 bits wide.
+dnl If cross-compiling, assume 4 bytes unless the cache value
+dnl is already set.
 dnl
 AC_DEFUN([OCTAVE_CHECK_SIZEOF_FORTRAN_INTEGER], [
-  AC_CACHE_CHECK([whether $F77 generates correct size integers],
+  AC_CACHE_CHECK([default size of Fortran INTEGER],
     [octave_cv_sizeof_fortran_integer],
     [ac_octave_save_FFLAGS="$FFLAGS"
-    FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"
-    AC_LANG_PUSH(Fortran 77)
-    AC_COMPILE_IFELSE([[
-      subroutine foo(n, in, out)
-      integer n, in(n), out(n)
-      integer i
-      do 10 i = 1, n
-        out(i) = in(i)
-   10 continue
-      return
-      end
-      ]],
-      [mv conftest.$ac_objext fintsize.$ac_objext
-      ac_octave_save_LIBS="$LIBS"
-      LIBS="fintsize.$ac_objext $[]_AC_LANG_PREFIX[]LIBS"
-      AC_LANG_PUSH(C)
-      AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-          #include <assert.h>
-          #include <stdint.h>
-          #if defined (OCTAVE_ENABLE_64)
-            typedef int64_t octave_idx_type;
-          #else
-            typedef int octave_idx_type;
-          #endif
-          void F77_FUNC(foo,FOO) (octave_idx_type*, octave_idx_type**, octave_idx_type**);
-          ]], [[
-          octave_idx_type n = 2;
-          octave_idx_type in[2];
-          octave_idx_type out[2];
-          in[0] = 13;
-          in[0] = 42;
-          F77_FUNC(foo,FOO) (&n, &in, &out);
-          assert (in[0] == out[0] && in[1] == out[1]);
-        ]])],
-        octave_cv_sizeof_fortran_integer=yes,
-        octave_cv_sizeof_fortran_integer=no,
-        octave_cv_sizeof_fortran_integer=yes)
-      AC_LANG_POP(C)
-      LIBS="$ac_octave_save_LIBS"
-      rm -f conftest.$ac_objext fintsize.$ac_objext],
-      [rm -f conftest.$ac_objext
-      AC_MSG_FAILURE([cannot compile a simple Fortran program])
-      octave_cv_sizeof_fortran_integer=no])
-    AC_LANG_POP(Fortran 77)
-    FFLAGS="$ac_octave_save_FFLAGS"
+     FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"
+     AC_LANG_PUSH(Fortran 77)
+     AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
+      integer*8 n8
+      integer n
+c Generate -2**33 + 1.
+      n8 = 2
+      n8 = -4 * (n8 ** 30)
+      n8 = n8 + 1
+c Convert to default integer type.  If the values are no longer equal,
+c assume the default integer size is 32-bits.
+      n = n8
+      if (n .ne. n8) stop 1
+       ]])],
+       octave_cv_sizeof_fortran_integer=8,
+       octave_cv_sizeof_fortran_integer=4,
+       octave_cv_sizeof_fortran_integer=4)
   ])
+  AC_LANG_POP(Fortran 77)
+  FFLAGS="$ac_octave_save_FFLAGS"
 ])
 dnl
 dnl Check whether sundials_ida library is configured with double precision realtype
--- a/m4/ax_blas_f77_func.m4	Fri Dec 30 10:36:35 2016 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-# ===========================================================================
-#     http://www.gnu.org/software/autoconf-archive/ax_blas_f77_func.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_BLAS_F77_FUNC([ACTION-IF-PASS[, ACTION-IF-FAIL[, ACTION-IF-CROSS-COMPILING]])
-#   AX_BLAS_WITH_F77_FUNC([ACTION-IF-FOUND-AND-PASS[, ACTION-IF-NOT-FOUND-OR-FAIL]])
-#
-# DESCRIPTION
-#
-#   These macros are intended as a supplement to the AX_BLAS macro, to
-#   verify that BLAS functions are properly callable from Fortran. This is
-#   necessary, for example, if you want to build the LAPACK library on top
-#   of the BLAS.
-#
-#   AX_BLAS_F77_FUNC uses the defined BLAS_LIBS and Fortran environment to
-#   check for compatibility, and takes a specific action in case of success,
-#   resp. failure, resp. cross-compilation.
-#
-#   AX_BLAS_WITH_F77_FUNC is a drop-in replacement wrapper for AX_BLAS that
-#   calls AX_BLAS_F77_FUNC after detecting a BLAS library and rejects it on
-#   failure (i.e. pretends that no library was found).
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Jaroslav Hajek <highegg@gmail.com>
-#
-#   This program is free software: you can redistribute it and/or modify it
-#   under the terms of the GNU General Public License as published by the
-#   Free Software Foundation, either version 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program is distributed in the hope that it will be useful, but
-#   WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-#   Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License along
-#   with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 8
-
-AU_ALIAS([ACX_BLAS_F77_FUNC], [AX_BLAS_F77_FUNC])
-AC_DEFUN([AX_BLAS_F77_FUNC], [
-AC_PREREQ(2.50)
-AC_REQUIRE([AX_BLAS])
-
-# F77 call-compatibility checks
-if test "$cross_compiling" = yes ; then
-	ifelse($3, ,$1,$3)
-elif test x"$ax_blas_ok" = xyes; then
-	save_ax_blas_f77_func_LIBS="$LIBS"
-	LIBS="$BLAS_LIBS $LIBS"
-	AC_LANG_PUSH(Fortran 77)
-# LSAME check (LOGICAL return values)
-	AC_MSG_CHECKING([whether LSAME is called correctly from Fortran])
-	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      logical lsame,w
-      external lsame
-      character c1,c2
-      c1 = 'A'
-      c2 = 'B'
-      w = lsame(c1,c2)
-      if (w) stop 1
-      w = lsame(c1,c1)
-      if (.not. w) stop 1
-      ]]),[ax_blas_lsame_fcall_ok=yes],
-	[ax_blas_lsame_fcall_ok=no])
-	AC_MSG_RESULT([$ax_blas_lsame_fcall_ok])
-# ISAMAX check (INTEGER return values)
-	AC_MSG_CHECKING([whether ISAMAX is called correctly from Fortran])
-	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      integer isamax,i
-      external isamax
-      real a(2)
-      a(1) = 1e0
-      a(2) = -2e0
-      i = isamax(2,a,1)
-      if (i.ne.2) stop 1
-      ]]),[ax_blas_isamax_fcall_ok=yes],
-	[ax_blas_isamax_fcall_ok=no])
-	AC_MSG_RESULT([$ax_blas_isamax_fcall_ok])
-# SDOT check (REAL return values)
-	AC_MSG_CHECKING([whether SDOT is called correctly from Fortran])
-	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      real sdot,a(1),b(1),w
-      external sdot
-      a(1) = 1e0
-      b(1) = 2e0
-      w = sdot(1,a,1,b,1)
-      if (w .ne. a(1)*b(1)) stop 1
-      ]]),[ax_blas_sdot_fcall_ok=yes],
-	[ax_blas_sdot_fcall_ok=no])
-	AC_MSG_RESULT([$ax_blas_sdot_fcall_ok])
-# DDOT check (DOUBLE return values)
-	AC_MSG_CHECKING([whether DDOT is called correctly from Fortran])
-	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      double precision ddot,a(1),b(1),w
-      external ddot
-      a(1) = 1d0
-      b(1) = 2d0
-      w = ddot(1,a,1,b,1)
-      if (w .ne. a(1)*b(1)) stop 1
-      ]]),[ax_blas_ddot_fcall_ok=yes],
-	[ax_blas_ddot_fcall_ok=no])
-	AC_MSG_RESULT([$ax_blas_ddot_fcall_ok])
-# CDOTU check (COMPLEX return values)
-	AC_MSG_CHECKING([whether CDOTU is called correctly from Fortran])
-	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      complex cdotu,a(1),b(1),w
-      external cdotu
-      a(1) = cmplx(1e0,1e0)
-      b(1) = cmplx(1e0,2e0)
-      w = cdotu(1,a,1,b,1)
-      if (w .ne. a(1)*b(1)) stop 1
-      ]]),[ax_blas_cdotu_fcall_ok=yes],
-	[ax_blas_cdotu_fcall_ok=no])
-	AC_MSG_RESULT([$ax_blas_cdotu_fcall_ok])
-# ZDOTU check (DOUBLE COMPLEX return values)
-	AC_MSG_CHECKING([whether ZDOTU is called correctly from Fortran])
-	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      double complex zdotu,a(1),b(1),w
-      external zdotu
-      a(1) = dcmplx(1d0,1d0)
-      b(1) = dcmplx(1d0,2d0)
-      w = zdotu(1,a,1,b,1)
-      if (w .ne. a(1)*b(1)) stop 1
-      ]]),[ax_blas_zdotu_fcall_ok=yes],
-	[ax_blas_zdotu_fcall_ok=no])
-	AC_MSG_RESULT([$ax_blas_zdotu_fcall_ok])
-# Check for correct integer size
-# FIXME: this may fail with things like -ftrapping-math.
-        AC_MSG_CHECKING([whether the integer size is correct])
-        AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      integer n,nn(3)
-      real s,a(1),b(1),sdot
-      a(1) = 1.0
-      b(1) = 1.0
-c Generate -2**33 + 1, if possible
-      n = 2
-      n = -4 * (n ** 30)
-      n = n + 1
-      if (n >= 0) goto 1
-c This means we're on 64-bit integers. Check whether the BLAS is, too.
-      s = sdot(n,a,1,b,1)
-      if (s .ne. 0.0) stop 1
-    1 continue
-c We may be on 32-bit integers, and the BLAS on 64 bits. This is almost bound
-c to have already failed, but just in case, we'll check.
-      nn(1) = -1
-      nn(2) = 1
-      nn(3) = -1
-      s = sdot(nn(2),a,1,b,1)
-      if (s .ne. 1.0) stop 1
-       ]]),[ax_blas_integer_size_ok=yes],
-	[ax_blas_integer_size_ok=no])
-	AC_MSG_RESULT([$ax_blas_integer_size_ok])
-
-	AC_LANG_POP(Fortran 77)
-
-# if any of the tests failed, reject the BLAS library
-	if test $ax_blas_lsame_fcall_ok = yes \
-		-a $ax_blas_sdot_fcall_ok = yes \
-		-a $ax_blas_ddot_fcall_ok = yes \
-		-a $ax_blas_cdotu_fcall_ok = yes \
-		-a $ax_blas_zdotu_fcall_ok = yes \
-		-a $ax_blas_integer_size_ok = yes; then
-		ax_blas_f77_func_ok=yes;
-		$1
-	else
-		ax_blas_f77_func_ok=no;
-		$2
-	fi
-	LIBS="$save_ax_blas_f77_func_LIBS"
-fi
-
-])dnl AX_BLAS_F77_FUNC
-
-AC_DEFUN([AX_BLAS_WITH_F77_FUNC], [
-AC_PREREQ(2.50)
-AX_BLAS([# disable special action], [])
-if test x$ax_blas_ok = xyes ; then
-	AX_BLAS_F77_FUNC(
-	[ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])],
-	[ax_blas_ok=no; BLAS_LIBS=])
-fi
-if test x$ax_blas_ok = xno ; then
-	$2
-fi
-])dnl AX_BLAS_WITH_F77_FUNC
--- a/m4/module.mk	Fri Dec 30 10:36:35 2016 -0500
+++ b/m4/module.mk	Fri Dec 30 13:45:10 2016 -0500
@@ -1,7 +1,6 @@
 EXTRA_DIST += \
   m4/module.mk \
   m4/ax_blas.m4 \
-  m4/ax_blas_f77_func.m4 \
   m4/ax_compare_version.m4 \
   m4/ax_lapack.m4 \
   m4/ax_openmp.m4 \
@@ -12,4 +11,5 @@
   m4/ltsugar.m4 \
   m4/ltversion.m4 \
   m4/lt~obsolete.m4 \
+  m4/octave_blas_f77_func.m4 \
   m4/pkg.m4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/octave_blas_f77_func.m4	Fri Dec 30 13:45:10 2016 -0500
@@ -0,0 +1,211 @@
+# OCTAVE_BLAS_F77_FUNC
+#
+# The same as AX_BLAS_F77_FUNC (described below) except attempt to
+# determine whether the BLAS library uses 32- or 64-bit integers instead
+# of failing if the default size of Fortran integers does not appear to
+# match the size of integers used by the BLAS library.
+
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_blas_f77_func.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_BLAS_F77_FUNC([ACTION-IF-PASS[, ACTION-IF-FAIL[, ACTION-IF-CROSS-COMPILING]])
+#   AX_BLAS_WITH_F77_FUNC([ACTION-IF-FOUND-AND-PASS[, ACTION-IF-NOT-FOUND-OR-FAIL]])
+#
+# DESCRIPTION
+#
+#   These macros are intended as a supplement to the AX_BLAS macro, to
+#   verify that BLAS functions are properly callable from Fortran. This is
+#   necessary, for example, if you want to build the LAPACK library on top
+#   of the BLAS.
+#
+#   AX_BLAS_F77_FUNC uses the defined BLAS_LIBS and Fortran environment to
+#   check for compatibility, and takes a specific action in case of success,
+#   resp. failure, resp. cross-compilation.
+#
+#   AX_BLAS_WITH_F77_FUNC is a drop-in replacement wrapper for AX_BLAS that
+#   calls AX_BLAS_F77_FUNC after detecting a BLAS library and rejects it on
+#   failure (i.e. pretends that no library was found).
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Jaroslav Hajek <highegg@gmail.com>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 8
+
+## Derived from 
+AC_DEFUN([OCTAVE_BLAS_F77_FUNC], [
+AC_PREREQ(2.50)
+AC_REQUIRE([AX_BLAS])
+
+# F77 call-compatibility checks
+if test "$cross_compiling" = yes ; then
+	ifelse($3, ,$1,$3)
+elif test x"$ax_blas_ok" = xyes; then
+	save_ax_blas_f77_func_LIBS="$LIBS"
+	LIBS="$BLAS_LIBS $LIBS"
+	AC_LANG_PUSH(Fortran 77)
+# LSAME check (LOGICAL return values)
+	AC_MSG_CHECKING([whether LSAME is called correctly from Fortran])
+	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      logical lsame,w
+      external lsame
+      character c1,c2
+      c1 = 'A'
+      c2 = 'B'
+      w = lsame(c1,c2)
+      if (w) stop 1
+      w = lsame(c1,c1)
+      if (.not. w) stop 1
+      ]]),[ax_blas_lsame_fcall_ok=yes],
+	[ax_blas_lsame_fcall_ok=no])
+	AC_MSG_RESULT([$ax_blas_lsame_fcall_ok])
+# ISAMAX check (INTEGER return values)
+	AC_MSG_CHECKING([whether ISAMAX is called correctly from Fortran])
+	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      integer isamax,i
+      external isamax
+      real a(2)
+      a(1) = 1e0
+      a(2) = -2e0
+      i = isamax(2,a,1)
+      if (i.ne.2) stop 1
+      ]]),[ax_blas_isamax_fcall_ok=yes],
+	[ax_blas_isamax_fcall_ok=no])
+	AC_MSG_RESULT([$ax_blas_isamax_fcall_ok])
+# SDOT check (REAL return values)
+	AC_MSG_CHECKING([whether SDOT is called correctly from Fortran])
+	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      real sdot,a(1),b(1),w
+      external sdot
+      a(1) = 1e0
+      b(1) = 2e0
+      w = sdot(1,a,1,b,1)
+      if (w .ne. a(1)*b(1)) stop 1
+      ]]),[ax_blas_sdot_fcall_ok=yes],
+	[ax_blas_sdot_fcall_ok=no])
+	AC_MSG_RESULT([$ax_blas_sdot_fcall_ok])
+# DDOT check (DOUBLE return values)
+	AC_MSG_CHECKING([whether DDOT is called correctly from Fortran])
+	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      double precision ddot,a(1),b(1),w
+      external ddot
+      a(1) = 1d0
+      b(1) = 2d0
+      w = ddot(1,a,1,b,1)
+      if (w .ne. a(1)*b(1)) stop 1
+      ]]),[ax_blas_ddot_fcall_ok=yes],
+	[ax_blas_ddot_fcall_ok=no])
+	AC_MSG_RESULT([$ax_blas_ddot_fcall_ok])
+# CDOTU check (COMPLEX return values)
+	AC_MSG_CHECKING([whether CDOTU is called correctly from Fortran])
+	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      complex cdotu,a(1),b(1),w
+      external cdotu
+      a(1) = cmplx(1e0,1e0)
+      b(1) = cmplx(1e0,2e0)
+      w = cdotu(1,a,1,b,1)
+      if (w .ne. a(1)*b(1)) stop 1
+      ]]),[ax_blas_cdotu_fcall_ok=yes],
+	[ax_blas_cdotu_fcall_ok=no])
+	AC_MSG_RESULT([$ax_blas_cdotu_fcall_ok])
+# ZDOTU check (DOUBLE COMPLEX return values)
+	AC_MSG_CHECKING([whether ZDOTU is called correctly from Fortran])
+	AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      double complex zdotu,a(1),b(1),w
+      external zdotu
+      a(1) = dcmplx(1d0,1d0)
+      b(1) = dcmplx(1d0,2d0)
+      w = zdotu(1,a,1,b,1)
+      if (w .ne. a(1)*b(1)) stop 1
+      ]]),[ax_blas_zdotu_fcall_ok=yes],
+	[ax_blas_zdotu_fcall_ok=no])
+	AC_MSG_RESULT([$ax_blas_zdotu_fcall_ok])
+# Check BLAS library integer size.  If it does not appear to be
+# 8 bytes, we assume it is 4 bytes.
+# FIXME: this may fail with things like -ftrapping-math.
+        AC_MSG_CHECKING([BLAS library integer size])
+        AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      integer*8 n
+      integer*4 n4
+      real s,a(1),b(1),sdot
+      a(1) = 1.0
+      b(1) = 1.0
+c Generate -2**33 + 1.  With BLAS compiled to use 64-bit integers, SDOT
+c will return early, setting the result to 0.  With BLAS compiled to use
+c 32-bit integers, this value should be interpreted as 1 and SDOT will
+c return 1.
+      n = 2
+      n = -4 * (n ** 30)
+      n = n + 1
+c Check that our expectation about the type conversion is correct.
+      n4 = n
+      if (n4 .ne. 1) then
+        print *, 'invalid assumption about integer type conversion'
+        stop 2
+      endif
+      s = sdot(n,a,1,b,1)
+      if (s .ne. 0.0) stop 1
+       ]]),[ax_blas_integer_size=8],
+	[ax_blas_integer_size=4])
+	AC_MSG_RESULT([$ax_blas_integer_size])
+
+	AC_LANG_POP(Fortran 77)
+
+# if any of the tests failed, reject the BLAS library
+	if test $ax_blas_lsame_fcall_ok = yes \
+		-a $ax_blas_sdot_fcall_ok = yes \
+		-a $ax_blas_ddot_fcall_ok = yes \
+		-a $ax_blas_cdotu_fcall_ok = yes \
+		-a $ax_blas_zdotu_fcall_ok = yes ; then
+		ax_blas_f77_func_ok=yes;
+		$1
+	else
+		ax_blas_f77_func_ok=no;
+		$2
+	fi
+	LIBS="$save_ax_blas_f77_func_LIBS"
+fi
+
+])dnl AX_BLAS_F77_FUNC
+
+AC_DEFUN([OCTAVE_BLAS_WITH_F77_FUNC], [
+AC_PREREQ(2.50)
+AX_BLAS([# disable special action], [])
+if test x$ax_blas_ok = xyes ; then
+	OCTAVE_BLAS_F77_FUNC(
+	[ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])],
+	[ax_blas_ok=no; BLAS_LIBS=])
+fi
+if test x$ax_blas_ok = xno ; then
+	$2
+fi
+])dnl AX_BLAS_WITH_F77_FUNC