changeset 14550:bc4c574ab3b6

Add configure check for isnan in fortran. * libcruft/slatec-fn/erfc.in.f: Rename from erfc.f. * libcruft/slatec-fn/derfc.in.f: Rename from derfc.f. * libcruft/slatec-fn/module.mk (slatec-fn/derfc.f, slatec-fn/erfc.f): New targets and rules. * m4/acinclude.m4 (OCTAVE_CHECK_FORTRAN_HAVE_ISNAN): New macro. * configure.ac: Use it. Substitute F77_ISNAN_MACRO. * build-aux/common.mk (F77_ISNAN_MACRO): New variable.
author Carlo de Falco <cdf@users.sourceforge.net>
date Wed, 11 Apr 2012 15:40:01 -0400
parents ad542fdd8c8f
children 60ed9260399a
files build-aux/common.mk configure.ac libcruft/slatec-fn/derfc.f libcruft/slatec-fn/derfc.in.f libcruft/slatec-fn/erfc.f libcruft/slatec-fn/erfc.in.f libcruft/slatec-fn/module.mk m4/acinclude.m4
diffstat 6 files changed, 44 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/common.mk
+++ b/build-aux/common.mk
@@ -90,6 +90,8 @@
 F77_APPEND_UNDERSCORE=@F77_TOLOWER@
 F77_APPEND_EXTRA_UNDERSCORE=@F77_TOLOWER@
 
+F77_ISNAN_MACRO=@F77_ISNAN_MACRO@
+
 X11_INCFLAGS = @X11_INCFLAGS@
 X11_LIBS = @X11_LIBS@
 
--- a/configure.ac
+++ b/configure.ac
@@ -593,6 +593,14 @@
   AC_MSG_ERROR([in order to build octave, you must have a compatible Fortran compiler or wrapper script for f2c that functions as a Fortran compiler installed and in your path.  See the file INSTALL for more information.])
 fi
 
+OCTAVE_CHECK_FORTRAN_HAVE_ISNAN
+F77_ISNAN_MACRO=
+if test "x$octave_cv_fortran_have_isnan" = xno; then
+   AC_MSG_NOTICE([substituting ISNAN(X) with X.NE.X in fortran sources])
+   F77_ISNAN_MACRO="s|ISNAN(\(@<:@^)@:>@*\))|(\1.NE.\1)|"
+fi
+AC_SUBST(F77_ISNAN_MACRO)
+
 OCTAVE_CHECK_FORTRAN_INTEGER_SIZE
 if test "x$octave_cv_fortran_integer_size" = xno; then
   if $USE_64_BIT_IDX_T; then
rename from libcruft/slatec-fn/derfc.f
rename to libcruft/slatec-fn/derfc.in.f
rename from libcruft/slatec-fn/erfc.f
rename to libcruft/slatec-fn/erfc.in.f
--- a/libcruft/slatec-fn/module.mk
+++ b/libcruft/slatec-fn/module.mk
@@ -1,4 +1,7 @@
-EXTRA_DIST += slatec-fn/module.mk
+EXTRA_DIST += \
+  slatec-fn/module.mk \
+  slatec-fn/derfc.in.f \
+  slatec-fn/erfc.in.f
 
 libcruft_la_SOURCES += \
   slatec-fn/albeta.f \
@@ -65,3 +68,11 @@
   slatec-fn/xsgmainc.f \
   slatec-fn/xgamma.f \
   slatec-fn/xbetai.f
+
+slatec-fn/erfc.f: slatec-fn/erfc.in.f Makefile
+	$(SED) -e "${F77_ISNAN_MACRO}" < $< > $@-t
+	mv $@-t $@
+
+slatec-fn/derfc.f: slatec-fn/derfc.in.f Makefile
+	$(SED) -e "${F77_ISNAN_MACRO}" < $< > $@-t
+	mv $@-t $@
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -329,6 +329,28 @@
   fi
 ])
 dnl
+dnl Check to see whether Fortran compiler has the intrinsic function ISNAN.
+dnl
+AC_DEFUN([OCTAVE_CHECK_FORTRAN_HAVE_ISNAN], [
+  AC_LANG_PUSH(Fortran 77)
+  AC_CACHE_CHECK([whether $F77 has the intrinsic function ISNAN],
+                 [octave_cv_fortran_have_isnan],
+[AC_COMPILE_IFELSE(
+[      program foo
+      implicit none
+      real x
+      double precision y
+      if (isnan(x)) then
+         print *, 'x is NaN'
+      end if
+      if (isnan(y)) then
+         print *, 'y is NaN'
+      end if
+      end program], [octave_cv_fortran_have_isnan=yes], [octave_cv_fortran_have_isnan=no]
+)])
+  AC_LANG_POP(Fortran 77)      
+])
+dnl
 dnl Check to see whether the default Fortran INTEGER is 64 bits wide.
 dnl
 AC_DEFUN([OCTAVE_CHECK_FORTRAN_INTEGER_SIZE], [