dnl Make sure we link both possible libraries here. Shame on gfortran!
AC_CHECK_LIB(g2c, e_wsfe, [ F77LIBS="$F77LIBS -lg2c" ])
- dnl TODO: Replace _gfortran_allocate by something really needed
- AC_CHECK_LIB(gfortran, _gfortran_allocate, [ F77LIBS="$F77LIBS -lgfortran" ])
+
+ dnl Check whether libgfortran contains certain symbols. We used
+ dnl to use _gfortran_allocate but that appears to have disappeared
+ dnl at one point in time so if we can't find it check other symbols
+ dnl till we find one we recognize
+ AC_CHECK_LIB(gfortran, _gfortran_allocate, [found=1])
+ AC_CHECK_LIB(gfortran, _gfortran_st_write_done, [found=1])
+
+ dnl libgfortran appears to exist. Link with it.
+ if test "x$found" = "x1" ; then
+ F77LIBS="$F77LIBS -lgfortran"
+ fi
;;
AIXF77)
F77LIBS="$F77LIBS -lg2c"
fi
- { echo "$as_me:$LINENO: checking for _gfortran_allocate in -lgfortran" >&5
+
+ { echo "$as_me:$LINENO: checking for _gfortran_allocate in -lgfortran" >&5
echo $ECHO_N "checking for _gfortran_allocate in -lgfortran... $ECHO_C" >&6; }
if test "${ac_cv_lib_gfortran__gfortran_allocate+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
{ echo "$as_me:$LINENO: result: $ac_cv_lib_gfortran__gfortran_allocate" >&5
echo "${ECHO_T}$ac_cv_lib_gfortran__gfortran_allocate" >&6; }
if test $ac_cv_lib_gfortran__gfortran_allocate = yes; then
- F77LIBS="$F77LIBS -lgfortran"
+ found=1
fi
+ { echo "$as_me:$LINENO: checking for _gfortran_st_write_done in -lgfortran" >&5
+echo $ECHO_N "checking for _gfortran_st_write_done in -lgfortran... $ECHO_C" >&6; }
+if test "${ac_cv_lib_gfortran__gfortran_st_write_done+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgfortran $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char _gfortran_st_write_done ();
+int
+main ()
+{
+return _gfortran_st_write_done ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_lib_gfortran__gfortran_st_write_done=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_gfortran__gfortran_st_write_done=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_gfortran__gfortran_st_write_done" >&5
+echo "${ECHO_T}$ac_cv_lib_gfortran__gfortran_st_write_done" >&6; }
+if test $ac_cv_lib_gfortran__gfortran_st_write_done = yes; then
+ found=1
+fi
+
+
+ if test "x$found" = "x1" ; then
+ F77LIBS="$F77LIBS -lgfortran"
+ fi
;;
AIXF77)