# HG changeset patch # User Carlo de Falco # Date 1334173201 14400 # Node ID bc4c574ab3b68188edb289c79c1e56ed48711374 # Parent ad542fdd8c8facc91ce844155b39c41505908c35 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. diff --git a/build-aux/common.mk b/build-aux/common.mk --- 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@ diff --git a/configure.ac b/configure.ac --- 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 diff --git a/libcruft/slatec-fn/derfc.f b/libcruft/slatec-fn/derfc.in.f rename from libcruft/slatec-fn/derfc.f rename to libcruft/slatec-fn/derfc.in.f diff --git a/libcruft/slatec-fn/erfc.f b/libcruft/slatec-fn/erfc.in.f rename from libcruft/slatec-fn/erfc.f rename to libcruft/slatec-fn/erfc.in.f diff --git a/libcruft/slatec-fn/module.mk b/libcruft/slatec-fn/module.mk --- 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 $@ diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 --- 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], [