]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
1998-10-03 Ben Elliston <bje@cygnus.com>
authorBen Elliston <bje+keyword+gnu.7caf74@air.net.au>
Fri, 2 Oct 1998 21:25:58 +0000 (21:25 +0000)
committerBen Elliston <bje+keyword+gnu.7caf74@air.net.au>
Fri, 2 Oct 1998 21:25:58 +0000 (21:25 +0000)
* acconfig.h (FC_NO_MINUS_C_MINUS_O): Add to complete the Fortran
77 support.
Tue Sep  8 14:06:04 1998  Matthew D. Langston  <langston@SLAC.Stanford.EDU>
* acgeneral.m4: Make the following macros Fortran 77 aware
(i.e. conditionalize whether to `#include "confdefs.h"', etc.):
(AC_TRY_COMPILE)
(AC_TRY_LINK)
(AC_CHECK_LIB)
* acgeneral.m4 (AC_LANG_FORTRAN77): Rename `AC_LANG_FORTRAN' to
`AC_LANG_FORTRAN77'.  Change the Fortran 77 language macro from
`FORTRAN' to `FORTRAN77'.
(AC_LANG_RESTORE): Change the Fortran 77 language macro from
`FORTRAN' to `FORTRAN77'
* autoconf.texi: Updated Fortran 77 documentation, particularly
for `AC_TRY_COMPILE', `AC_TRY_LINK' and `AC_CHECK_LIB'.
Thu Sep  3 09:34:39 1998  Matthew D. Langston  <langston@SLAC.Stanford.EDU>
* autoconf.texi: Added Fortran 77 documentation.
* acspecific.m4 (AC_PROG_FC): New macro.  Determine a Fortran
compiler to use.
(AC_PROG_FC_WORKS): New macro.
(AC_PROG_FC_GNU): New macro.
(AC_PROG_FC_G): New macro.
(AC_PROG_FC_C_O): New macro.
* acgeneral.m4: Add FFLAGS (Fortran 77 flags).
(AC_LANG_FORTRAN): New macro.
(AC_LANG_RESTORE): Make Fortran 77 aware.
(AC_TRY_COMPILER): Make Fortran 77 aware (i.e. conditionalize
whether to `#include "confdefs.h"').

ChangeLog
acconfig.h
acgeneral.m4
acspecific.m4
autoconf.texi
doc/autoconf.texi
lib/autoconf/general.m4
lib/autoconf/specific.m4

index a8b696fe9fb17599eae90b4439f493843192df79..d22494fcdee360f6be9904c20c0f2a37bc514a64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 1998-10-03  Ben Elliston  <bje@cygnus.com>
 
+       * acconfig.h (FC_NO_MINUS_C_MINUS_O): Add to complete the Fortran
+       77 support.
+
        * README: Update bug reporting address. Include maintainer info.
 
 1998-10-02  Ben Elliston  <bje@cygnus.com>
@@ -87,7 +90,41 @@ Sat Sep 12 16:25:00 1998  Aaron Crane  <aaronc@pobox.com>
        * acgeneral.m4 (AC_CHECK_TYPE): Changed the egrep regex to avoid
        incorrectly assuming that if foobar_t is defined, then so is
        bar_t.
-       
+
+Tue Sep  8 14:06:04 1998  Matthew D. Langston  <langston@SLAC.Stanford.EDU>
+
+        * acgeneral.m4: Make the following macros Fortran 77 aware
+        (i.e. conditionalize whether to `#include "confdefs.h"', etc.):
+        (AC_TRY_COMPILE)
+        (AC_TRY_LINK)
+        (AC_CHECK_LIB)
+
+        * acgeneral.m4 (AC_LANG_FORTRAN77): Rename `AC_LANG_FORTRAN' to
+        `AC_LANG_FORTRAN77'.  Change the Fortran 77 language macro from
+        `FORTRAN' to `FORTRAN77'.
+        (AC_LANG_RESTORE): Change the Fortran 77 language macro from
+        `FORTRAN' to `FORTRAN77'
+
+        * autoconf.texi: Updated Fortran 77 documentation, particularly
+        for `AC_TRY_COMPILE', `AC_TRY_LINK' and `AC_CHECK_LIB'.
+
+Thu Sep  3 09:34:39 1998  Matthew D. Langston  <langston@SLAC.Stanford.EDU>
+
+        * autoconf.texi: Added Fortran 77 documentation.
+
+        * acspecific.m4 (AC_PROG_FC): New macro.  Determine a Fortran
+        compiler to use.
+        (AC_PROG_FC_WORKS): New macro.
+        (AC_PROG_FC_GNU): New macro.
+        (AC_PROG_FC_G): New macro.
+        (AC_PROG_FC_C_O): New macro.
+
+        * acgeneral.m4: Add FFLAGS (Fortran 77 flags).
+        (AC_LANG_FORTRAN): New macro.
+        (AC_LANG_RESTORE): Make Fortran 77 aware.
+        (AC_TRY_COMPILER): Make Fortran 77 aware (i.e. conditionalize
+        whether to `#include "confdefs.h"').
+
 Thu Jun 18 12:13:27 1998  Ian Lance Taylor  <ian@cygnus.com>
 
        * acspecific.m4 (AC_EXEEXT): Correct setting of ac_exeext when
index dd3a66501f9f4cb73a55520ae7cc92aa1f0f2269..4a816ccafe70a730d957d7dfd68e03d830ddb6f4 100644 (file)
 /* Define if your C compiler doesn't accept -c and -o together.  */
 #undef NO_MINUS_C_MINUS_O
 
+/* Define if your Fortran 77 compiler doesn't accept -c and -o together. */
+#undef FC_NO_MINUS_C_MINUS_O
+
 /* Define to `long' if <sys/types.h> doesn't define.  */
 #undef off_t
 
index 608b58820869cecfebbe23dca55c15c0d7ea390f..61ad88cbc23d318a231964b871cb6f54f00ca66e 100644 (file)
@@ -700,6 +700,7 @@ AC_SUBST(SHELL)dnl
 AC_SUBST(CFLAGS)dnl
 AC_SUBST(CPPFLAGS)dnl
 AC_SUBST(CXXFLAGS)dnl
+AC_SUBST(FFLAGS)dnl
 AC_SUBST(DEFS)dnl
 AC_SUBST(LDFLAGS)dnl
 AC_SUBST(LIBS)dnl
@@ -1244,6 +1245,15 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
 cross_compiling=$ac_cv_prog_cxx_cross
 ])
 
+dnl AC_LANG_FORTRAN77()
+AC_DEFUN([AC_LANG_FORTRAN77],
+[define([AC_LANG], [FORTRAN77])dnl
+ac_ext=f
+ac_compile='$FC $FFLAGS -c conftest.$ac_ext 1>&AC_FD_CC'
+ac_link='$FC $FFLAGS $LDFLAGS -c conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC'
+cross_compiling=$ac_cv_prog_fc_cross
+])
+
 dnl Push the current language on a stack.
 dnl AC_LANG_SAVE()
 define(AC_LANG_SAVE,
@@ -1251,8 +1261,10 @@ define(AC_LANG_SAVE,
 
 dnl Restore the current language from the stack.
 dnl AC_LANG_RESTORE()
-define(AC_LANG_RESTORE,
-[ifelse(AC_LANG_STACK, C, [ifelse(AC_LANG, C, , [AC_LANG_C])], [ifelse(AC_LANG, CPLUSPLUS, , [AC_LANG_CPLUSPLUS])])[]popdef([AC_LANG_STACK])])
+pushdef([AC_LANG_RESTORE],
+[ifelse(AC_LANG_STACK, [C], [AC_LANG_C],dnl
+AC_LANG_STACK, [CPLUSPLUS], [AC_LANG_CPLUSPLUS],dnl
+AC_LANG_STACK, [FORTRAN77], [MDL_LANG_FORTRAN77])[]popdef([AC_LANG_STACK])])
 
 
 dnl ### Compiler-running mechanics
@@ -1479,14 +1491,21 @@ fi
 undefine([AC_VAR_NAME])dnl
 ])
 
-dnl Sets WORKING_VAR to yes if the current compiler works, else no;
-dnl sets CROSS-VAR to yes if it produces non-native executables, else no.
-dnl Before calling this, call AC_LANG_* to set the right language.
+dnl Try to compile, link and execute TEST-PROGRAM.  Set WORKING-VAR to
+dnl `yes' if the current compiler works, otherwise set it ti `no'.  Set
+dnl CROSS-VAR to `yes' if the compiler and linker produce non-native
+dnl executables, otherwise set it to `no'.  Before calling
+dnl `AC_TRY_COMPILER()', call `AC_LANG_*' to set-up for the right
+dnl language.
+dnl 
 dnl AC_TRY_COMPILER(TEST-PROGRAM, WORKING-VAR, CROSS-VAR)
 AC_DEFUN(AC_TRY_COMPILER,
-[cat > conftest.$ac_ext <<EOF
+[cat > conftest.$ac_ext << EOF
+ifelse(AC_LANG, [FORTRAN77], ,
+[
 [#]line __oline__ "configure"
 #include "confdefs.h"
+])
 [$1]
 EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
@@ -1546,6 +1565,7 @@ AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
 [ac_save_LIBS="$LIBS"
 LIBS="-l$1 $5 $LIBS"
 AC_TRY_LINK(dnl
+ifelse(AC_LANG, [FORTRAN77], ,
 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
 [/* Override any gcc2 internal prototype to avoid an error.  */
 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
@@ -1555,7 +1575,7 @@ extern "C"
 [/* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char $2();
-]),
+])),
            [$2()],
            eval "ac_cv_lib_$ac_lib_var=yes",
            eval "ac_cv_lib_$ac_lib_var=no")
@@ -1681,7 +1701,11 @@ dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY,
 dnl             [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 AC_DEFUN(AC_TRY_COMPILE,
 [cat > conftest.$ac_ext <<EOF
-dnl This sometimes fails to find confdefs.h, for some reason.
+ifelse(AC_LANG, [FORTRAN77],
+[      program main
+[$2]
+      end],
+[dnl This sometimes fails to find confdefs.h, for some reason.
 dnl [#]line __oline__ "[$]0"
 [#]line __oline__ "configure"
 #include "confdefs.h"
@@ -1689,7 +1713,7 @@ dnl [#]line __oline__ "[$]0"
 int main() {
 [$2]
 ; return 0; }
-EOF
+])EOF
 if AC_TRY_EVAL(ac_compile); then
   ifelse([$3], , :, [rm -rf conftest*
   $3])
@@ -1719,7 +1743,13 @@ dnl AC_TRY_LINK(INCLUDES, FUNCTION-BODY,
 dnl             [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 AC_DEFUN(AC_TRY_LINK,
 [cat > conftest.$ac_ext <<EOF
-dnl This sometimes fails to find confdefs.h, for some reason.
+ifelse(AC_LANG, [FORTRAN77],
+[
+      program main
+      call [$2]
+      end
+],
+[dnl This sometimes fails to find confdefs.h, for some reason.
 dnl [#]line __oline__ "[$]0"
 [#]line __oline__ "configure"
 #include "confdefs.h"
@@ -1727,7 +1757,7 @@ dnl [#]line __oline__ "[$]0"
 int main() {
 [$2]
 ; return 0; }
-EOF
+])EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
   ifelse([$3], , :, [rm -rf conftest*
   $3])
index a99aa60fd8719d9626eb29de32ac3cef07dea4f2..53ede277b2cc87620e7a30fc2e0264da099bf0c8 100644 (file)
@@ -154,6 +154,56 @@ else
 fi
 ])
 
+dnl Determine a Fortran compiler to use.  If `FC' is not already set in
+dnl the environment, check for `g77', `f77' and `f2c', in that order.
+dnl See the output variable `FC' to the name of the compiler found.
+dnl 
+dnl If using `g77' (the GNU Fortran compiler), then `AC_PROG_FC' will
+dnl set the shell variable `G77' to `yes', and empty otherwise.  If the
+dnl output variable `FFLAGS' was not already set in the environment,
+dnl then set it to `-g -02' for `g77' (or `-O2' where `g77' does not
+dnl accept `-g').  Otherwise, set `FFLAGS' to `-g' for all other Fortran
+dnl compilers.
+dnl 
+dnl AC_PROG_FC()
+AC_DEFUN(AC_PROG_FC,
+[AC_BEFORE([$0], [AC_PROG_CPP])dnl
+if test -z "$FC"; then
+  AC_CHECK_PROG(FC, g77, g77)
+  if test -z "$FC"; then
+    AC_CHECK_PROG(FC, f77, f77)
+    if test -z "$FC"; then
+      AC_CHECK_PROG(FC, f2c, f2c)
+    fi
+    test -z "$FC" && AC_MSG_ERROR([no acceptable Fortran compiler found in \$PATH])
+  fi
+fi
+
+AC_PROG_FC_WORKS
+AC_PROG_FC_GNU
+
+if test $ac_cv_prog_g77 = yes; then
+  G77=yes
+dnl Check whether -g works, even if FFLAGS is set, in case the package
+dnl plays around with FFLAGS (such as to build both debugging and
+dnl normal versions of a library), tasteless as that idea is.
+  ac_test_FFLAGS="${FFLAGS+set}"
+  ac_save_FFLAGS="$FFLAGS"
+  FFLAGS=
+  AC_PROG_FC_G
+  if test "$ac_test_FFLAGS" = set; then
+    FFLAGS="$ac_save_FFLAGS"
+  elif test $ac_cv_prog_fc_g = yes; then
+    FFLAGS="-g -O2"
+  else
+    FFLAGS="-O2"
+  fi
+else
+  G77=
+  test "${FFLAGS+set}" = set || FFLAGS="-g"
+fi
+])
+
 AC_DEFUN(AC_PROG_CC_WORKS,
 [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) works])
 AC_LANG_SAVE
@@ -184,6 +234,30 @@ AC_MSG_RESULT($ac_cv_prog_cxx_cross)
 cross_compiling=$ac_cv_prog_cxx_cross
 ])
 
+dnl Test whether the Fortran compiler can compile and link a trivial
+dnl Fortran program.  Also, test whether the Fortran compiler is a
+dnl cross-compiler (which may realistically be the case if the Fortran
+dnl compiler is `g77').
+dnl 
+dnl AC_PROG_FC_WORKS()
+AC_DEFUN(AC_PROG_FC_WORKS,
+[AC_MSG_CHECKING([whether the Fortran compiler ($FC $FFLAGS $LDFLAGS) works])
+AC_LANG_SAVE
+AC_LANG_FORTRAN77
+AC_TRY_COMPILER(dnl
+[       program conftest
+       end
+], ac_cv_prog_fc_works, ac_cv_prog_fc_cross)
+AC_LANG_RESTORE
+AC_MSG_RESULT($ac_cv_prog_fc_works)
+if test $ac_cv_prog_fc_works = no; then
+  AC_MSG_ERROR([installation or configuration problem: Fortran compiler cannot create executables.])
+fi
+AC_MSG_CHECKING([whether the Fortran compiler ($FC $FFLAGS $LDFLAGS) is a cross-compiler])
+AC_MSG_RESULT($ac_cv_prog_fc_cross)
+cross_compiling=$ac_cv_prog_fc_cross
+])
+
 AC_DEFUN(AC_PROG_CC_GNU,
 [AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
 [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
@@ -212,6 +286,24 @@ else
   ac_cv_prog_gxx=no
 fi])])
 
+dnl Test whether for Fortran compiler is `g77' (the GNU Fortran
+dnl Compiler).  This test depends on whether the Fortran compiler can do
+dnl CPP pre-processing.
+dnl 
+dnl AC_PROG_FC_GNU()
+AC_DEFUN(AC_PROG_FC_GNU,
+[AC_CACHE_CHECK(whether we are using GNU Fortran, ac_cv_prog_g77,
+[cat > conftest.fpp <<EOF
+#ifdef __GNUC__
+  yes
+#endif
+EOF
+if AC_TRY_COMMAND($FC -E conftest.fpp) | egrep yes >/dev/null 2>&1; then
+  ac_cv_prog_g77=yes
+else
+  ac_cv_prog_g77=no
+fi])])
+
 AC_DEFUN(AC_PROG_CC_G,
 [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,
 [echo 'void f(){}' > conftest.c
@@ -234,6 +326,24 @@ fi
 rm -f conftest*
 ])])
 
+dnl Test whether the Fortran compiler can accept the `-g' option to
+dnl enable debugging.
+dnl 
+dnl AC_PROG_FC_G()
+AC_DEFUN(AC_PROG_FC_G,
+[AC_CACHE_CHECK(whether $FC accepts -g, ac_cv_prog_fc_g,
+[cat > conftest.f << EOF
+       program conftest
+       end
+EOF
+if test -z "`$FC -g -c conftest.f 2>&1`"; then
+  ac_cv_prog_fc_g=yes
+else
+  ac_cv_prog_fc_g=no
+fi
+rm -f conftest*
+])])
+
 AC_DEFUN(AC_PROG_GCC_TRADITIONAL,
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_PROG_CPP])dnl
@@ -304,6 +414,45 @@ else
 fi
 ])
 
+dnl Test if the Fortran compiler accepts the options `-c' and `-o'
+dnl simultaneously, and define `FC_NO_MINUS_C_MINUS_O' if it does not.
+dnl
+dnl The usefulness of this macro is questionable, as I can't really see
+dnl why anyone would use it.  The only reason I include it is for
+dnl completeness, since a similar test exists for the C compiler.
+dnl 
+dnl AC_PROG_FC_C_O
+AC_DEFUN(AC_PROG_FC_C_O,
+[AC_BEFORE([$0], [AC_PROG_FC])dnl
+AC_MSG_CHECKING(whether $FC understand -c and -o together)
+set dummy $FC; ac_fc="`echo [$]2 |
+changequote(, )dnl
+sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
+changequote([, ])dnl
+AC_CACHE_VAL(ac_cv_prog_fc_${ac_fc}_c_o,
+[cat > conftest.f << EOF
+       program conftest
+       end
+EOF
+# We do the `AC_TRY_EVAL' test twice because some compilers refuse to
+# overwrite an existing `.o' file with `-o', although they will create
+# one.
+ac_try='$FC $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC'
+if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
+  eval ac_cv_prog_fc_${ac_fc}_c_o=yes
+else
+  eval ac_cv_prog_fc_${ac_fc}_c_o=no
+fi
+rm -f conftest*
+])dnl
+if eval "test \"`echo '$ac_cv_prog_fc_'${ac_fc}_c_o`\" = yes"; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+  AC_DEFINE(FC_NO_MINUS_C_MINUS_O)
+fi
+])
+
 dnl Define SET_MAKE to set ${MAKE} if make doesn't.
 AC_DEFUN(AC_PROG_MAKE_SET,
 [AC_MSG_CHECKING(whether ${MAKE-make} sets \${MAKE})
index d0ba46df5f060e9a153941a4ca3ac05f0b580d2c..021cced3a9fd91c2c3a38f19f2b4f8896b5c71b6 100644 (file)
@@ -1048,6 +1048,15 @@ set when you call @code{AC_PROG_CXX} (or empty if you don't).
 C++ features.
 @end defvar
 
+@defvar FFLAGS
+@ovindex FFLAGS
+Debugging and optimization options for the Fortran 77 compiler.  If it
+is not set in the environment when @code{configure} runs, the default
+value is set when you call @code{AC_PROG_FC} (or empty if you don't).
+@code{configure} uses this variable when compiling programs to test for
+Fortran 77 features.
+@end defvar
+
 @defvar DEFS
 @ovindex DEFS
 @samp{-D} options to pass to the C compiler.  If @code{AC_CONFIG_HEADER}
@@ -1609,6 +1618,32 @@ calling @code{AC_TRY_CPP}, @code{AC_CHECK_HEADER},
 @code{AC_EGREP_HEADER}, or @code{AC_EGREP_CPP}.
 @end defmac
 
+@defmac  AC_PROG_FC
+@maindex PROG_FORTRAN
+@ovindex FC
+@ovindex FFLAGS
+Determine a Fortran 77 compiler to use.  If @code{FC} is not already set
+in the environment, check for @code{g77}, @code{f77} and @code{f2c}, in
+that order.  Set the output variable @code{FC} to the name of the
+compiler found.
+
+If using @code{g77} (the GNU Fortran 77 compiler), then
+@code{AC_PROG_FC} will set the shell variable @code{G77} to @samp{yes},
+and empty otherwise.  If the output variable @code{FFLAGS} was not
+already set in the environment, then set it to @samp{-g -02} for
+@code{g77} (or @samp{-O2} where @code{g77} does not accept @samp{-g}).
+Otherwise, set @code{FFLAGS} to @samp{-g} for all other Fortran 77
+compilers.
+@end defmac
+
+@defmac AC_PROG_FC_C_O
+@maindex PROG_FC_C_O
+@cvindex FC_NO_MINUS_C_MINUS_O
+Test if the Fortran 77 compiler accepts the options @samp{-c} and
+@samp{-o} simultaneously, and define @code{FC_NO_MINUS_C_MINUS_O} if it
+does not.
+@end defmac
+
 @defmac AC_PROG_GCC_TRADITIONAL
 @maindex PROG_GCC_TRADITIONAL
 @ovindex CC
@@ -1774,15 +1809,17 @@ found.
 @node Libraries, Library Functions, Alternative Programs, Existing Tests
 @section Library Files
 
-The following macros check for the presence of certain C library archive
-files.
+The following macros check for the presence of certain C, C++ or Fortran
+77 library archive files.
 
 @defmac AC_CHECK_LIB (@var{library}, @var{function} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
 @maindex CHECK_LIB
-Try to ensure that C function @var{function} is available by checking
-whether a test C program can be linked with the library @var{library} to
-get the function.  @var{library} is the base name of the library; e.g.,
-to check for @samp{-lmp}, use @samp{mp} as the @var{library} argument.
+Depending on the current language(@pxref{Language Choice}), try to
+ensure that the C, C++ or Fortran 77 function @var{function} is
+available by checking whether a test program can be linked with the
+library @var{library} to get the function.  @var{library} is the base
+name of the library; e.g., to check for @samp{-lmp}, use @samp{mp} as
+the @var{library} argument.
 
 @var{action-if-found} is a list of shell commands to run if the link
 with the library succeeds; @var{action-if-not-found} is a list of shell
@@ -2883,22 +2920,31 @@ been called already.
 @node Examining Syntax, Examining Libraries, Examining Declarations, Writing Tests
 @section Examining Syntax
 
-To check for a syntax feature of the C or C++ compiler, such as whether
-it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to try to
-compile a small program that uses that feature.  You can also use it to
-check for structures and structure members that are not present on all
-systems.
+To check for a syntax feature of the C, C++ or Fortran 77 compiler, such
+as whether it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to
+try to compile a small program that uses that feature.  You can also use
+it to check for structures and structure members that are not present on
+all systems.
 
 @defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
 @maindex TRY_COMPILE
-Create a test C program to see whether a function whose body consists of
-@var{function-body} can be compiled; @var{includes} is any
-@code{#include} statements needed by the code in @var{function-body}.
+Create a C, C++ or Fortran 77 test program (depending on which language
+is current, @pxref{Language Choice}), to see whether a function whose
+body consists of @var{function-body} can be compiled.
+
+For C and C++, @var{includes} is any @code{#include} statements needed
+by the code in @var{function-body} (@var{includes} will be ignored if
+the currently selected language is Fortran 77).  This macro also uses
+@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently
+selected language, as well as @code{CPPFLAGS}, when compiling.  If
+Fortran 77 is the currently selected language then @code{FFLAGS} will be
+used when compiling.
+
 If the file compiles successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.  This
-macro uses @code{CFLAGS} or @code{CXXFLAGS}, and @code{CPPFLAGS}, when
-compiling.  It does not try to link; use @code{AC_TRY_LINK} if you need
-to do that (@pxref{Examining Libraries}).
+@var{action-if-found}, otherwise run @var{action-if-not-found}.
+
+This macro does not try to link; use @code{AC_TRY_LINK} if you need to
+do that (@pxref{Examining Libraries}).
 @end defmac
 
 @node Examining Libraries, Run Time, Examining Syntax, Writing Tests
@@ -2925,28 +2971,37 @@ solve it by setting @code{LDFLAGS} in the environment to pass whatever
 options the linker needs (for example, @samp{-Wl,-dn} on MIPS RISC/OS).
 
 @code{AC_TRY_LINK} is used to compile test programs to test for
-functions and global variables.  It is also used (by
-@code{AC_CHECK_LIB}) to check for libraries, by adding the library being
+functions and global variables.  It is also used by @code{AC_CHECK_LIB}
+to check for libraries (@pxref{Libraries}), by adding the library being
 checked for to @code{LIBS} temporarily and trying to link a small
 program.
 
 @defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
 @maindex TRY_LINK
-Create a test C program to see whether a function whose body consists of
-@var{function-body} can be compiled and linked; @var{includes} is any
-@code{#include} statements needed by the code in @var{function-body}.
+Depending on the current language (@pxref{Language Choice}), create a
+test program to see whether a function whose body consists of
+@var{function-body} can be compiled and linked.
+
+For C and C++, @var{includes} is any @code{#include} statements needed
+by the code in @var{function-body} (@var{includes} will be ignored if
+the currently selected language is Fortran 77).  This macro also uses
+@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently
+selected language, as well as @code{CPPFLAGS}, when compiling.  If
+Fortran 77 is the currently selected language then @code{FFLAGS} will be
+used when compiling.  However, both @code{LDFLAGS} and @code{LIBS} will
+be used during linking in all cases.
+
 If the file compiles and links successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.  This
-macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS},
-@code{LDFLAGS}, and @code{LIBS} when compiling.
+@var{action-if-found}, otherwise run @var{action-if-not-found}.
 @end defmac
 
 @defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
 @maindex COMPILE_CHECK
-This is an obsolete version of @code{AC_TRY_LINK}, with the addition that it
-prints @samp{checking for @var{echo-text}} to the standard output first,
-if @var{echo-text} is non-empty.  Use @code{AC_MSG_CHECKING} and
-@code{AC_MSG_RESULT} instead to print messages (@pxref{Printing Messages}).
+This is an obsolete version of @code{AC_TRY_LINK}, with the addition
+that it prints @samp{checking for @var{echo-text}} to the standard
+output first, if @var{echo-text} is non-empty.  Use
+@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT} instead to print
+messages (@pxref{Printing Messages}).
 @end defmac
 
 @node Run Time, Portable Shell, Examining Libraries, Writing Tests
@@ -3224,21 +3279,29 @@ extension @file{.C} for test programs.  Set the shell variable
 it has been run, empty otherwise.
 @end defmac
 
+@defmac AC_LANG_FORTRAN77
+@maindex LANG_FORTRAN77
+Do compilation tests using @code{FC} and use extension @file{.f} for
+test programs.  Set the shell variable @code{cross_compiling} to the
+value computed by @code{AC_PROG_FC} if it has been run, empty otherwise.
+@end defmac
+
 @defmac AC_LANG_SAVE
 @maindex LANG_SAVE
-Remember the current language (as set by @code{AC_LANG_C} or
-@code{AC_LANG_CPLUSPLUS}) on a stack.  Does not change which language is
-current.  Use this macro and @code{AC_LANG_RESTORE} in macros that need
-to temporarily switch to a particular language.
+Remember the current language (as set by @code{AC_LANG_C},
+@code{AC_LANG_CPLUSPLUS} or @code{AC_LANG_FORTRAN77}) on a stack.  Does
+not change which language is current.  Use this macro and
+@code{AC_LANG_RESTORE} in macros that need to temporarily switch to a
+particular language.
 @end defmac
 
 @defmac AC_LANG_RESTORE
 @maindex LANG_RESTORE
 Select the language that is saved on the top of the stack, as set by
 @code{AC_LANG_SAVE}, and remove it from the stack.  This macro is
-equivalent to either @code{AC_LANG_C} or @code{AC_LANG_CPLUSPLUS},
-whichever had been run most recently when @code{AC_LANG_SAVE} was last
-called.
+equivalent to either @code{AC_LANG_C}, @code{AC_LANG_CPLUSPLUS} or
+@code{AC_LANG_FORTRAN77}, whichever had been run most recently when
+@code{AC_LANG_SAVE} was last called.
 
 Do not call this macro more times than @code{AC_LANG_SAVE}.
 @end defmac
index d0ba46df5f060e9a153941a4ca3ac05f0b580d2c..021cced3a9fd91c2c3a38f19f2b4f8896b5c71b6 100644 (file)
@@ -1048,6 +1048,15 @@ set when you call @code{AC_PROG_CXX} (or empty if you don't).
 C++ features.
 @end defvar
 
+@defvar FFLAGS
+@ovindex FFLAGS
+Debugging and optimization options for the Fortran 77 compiler.  If it
+is not set in the environment when @code{configure} runs, the default
+value is set when you call @code{AC_PROG_FC} (or empty if you don't).
+@code{configure} uses this variable when compiling programs to test for
+Fortran 77 features.
+@end defvar
+
 @defvar DEFS
 @ovindex DEFS
 @samp{-D} options to pass to the C compiler.  If @code{AC_CONFIG_HEADER}
@@ -1609,6 +1618,32 @@ calling @code{AC_TRY_CPP}, @code{AC_CHECK_HEADER},
 @code{AC_EGREP_HEADER}, or @code{AC_EGREP_CPP}.
 @end defmac
 
+@defmac  AC_PROG_FC
+@maindex PROG_FORTRAN
+@ovindex FC
+@ovindex FFLAGS
+Determine a Fortran 77 compiler to use.  If @code{FC} is not already set
+in the environment, check for @code{g77}, @code{f77} and @code{f2c}, in
+that order.  Set the output variable @code{FC} to the name of the
+compiler found.
+
+If using @code{g77} (the GNU Fortran 77 compiler), then
+@code{AC_PROG_FC} will set the shell variable @code{G77} to @samp{yes},
+and empty otherwise.  If the output variable @code{FFLAGS} was not
+already set in the environment, then set it to @samp{-g -02} for
+@code{g77} (or @samp{-O2} where @code{g77} does not accept @samp{-g}).
+Otherwise, set @code{FFLAGS} to @samp{-g} for all other Fortran 77
+compilers.
+@end defmac
+
+@defmac AC_PROG_FC_C_O
+@maindex PROG_FC_C_O
+@cvindex FC_NO_MINUS_C_MINUS_O
+Test if the Fortran 77 compiler accepts the options @samp{-c} and
+@samp{-o} simultaneously, and define @code{FC_NO_MINUS_C_MINUS_O} if it
+does not.
+@end defmac
+
 @defmac AC_PROG_GCC_TRADITIONAL
 @maindex PROG_GCC_TRADITIONAL
 @ovindex CC
@@ -1774,15 +1809,17 @@ found.
 @node Libraries, Library Functions, Alternative Programs, Existing Tests
 @section Library Files
 
-The following macros check for the presence of certain C library archive
-files.
+The following macros check for the presence of certain C, C++ or Fortran
+77 library archive files.
 
 @defmac AC_CHECK_LIB (@var{library}, @var{function} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
 @maindex CHECK_LIB
-Try to ensure that C function @var{function} is available by checking
-whether a test C program can be linked with the library @var{library} to
-get the function.  @var{library} is the base name of the library; e.g.,
-to check for @samp{-lmp}, use @samp{mp} as the @var{library} argument.
+Depending on the current language(@pxref{Language Choice}), try to
+ensure that the C, C++ or Fortran 77 function @var{function} is
+available by checking whether a test program can be linked with the
+library @var{library} to get the function.  @var{library} is the base
+name of the library; e.g., to check for @samp{-lmp}, use @samp{mp} as
+the @var{library} argument.
 
 @var{action-if-found} is a list of shell commands to run if the link
 with the library succeeds; @var{action-if-not-found} is a list of shell
@@ -2883,22 +2920,31 @@ been called already.
 @node Examining Syntax, Examining Libraries, Examining Declarations, Writing Tests
 @section Examining Syntax
 
-To check for a syntax feature of the C or C++ compiler, such as whether
-it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to try to
-compile a small program that uses that feature.  You can also use it to
-check for structures and structure members that are not present on all
-systems.
+To check for a syntax feature of the C, C++ or Fortran 77 compiler, such
+as whether it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to
+try to compile a small program that uses that feature.  You can also use
+it to check for structures and structure members that are not present on
+all systems.
 
 @defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
 @maindex TRY_COMPILE
-Create a test C program to see whether a function whose body consists of
-@var{function-body} can be compiled; @var{includes} is any
-@code{#include} statements needed by the code in @var{function-body}.
+Create a C, C++ or Fortran 77 test program (depending on which language
+is current, @pxref{Language Choice}), to see whether a function whose
+body consists of @var{function-body} can be compiled.
+
+For C and C++, @var{includes} is any @code{#include} statements needed
+by the code in @var{function-body} (@var{includes} will be ignored if
+the currently selected language is Fortran 77).  This macro also uses
+@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently
+selected language, as well as @code{CPPFLAGS}, when compiling.  If
+Fortran 77 is the currently selected language then @code{FFLAGS} will be
+used when compiling.
+
 If the file compiles successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.  This
-macro uses @code{CFLAGS} or @code{CXXFLAGS}, and @code{CPPFLAGS}, when
-compiling.  It does not try to link; use @code{AC_TRY_LINK} if you need
-to do that (@pxref{Examining Libraries}).
+@var{action-if-found}, otherwise run @var{action-if-not-found}.
+
+This macro does not try to link; use @code{AC_TRY_LINK} if you need to
+do that (@pxref{Examining Libraries}).
 @end defmac
 
 @node Examining Libraries, Run Time, Examining Syntax, Writing Tests
@@ -2925,28 +2971,37 @@ solve it by setting @code{LDFLAGS} in the environment to pass whatever
 options the linker needs (for example, @samp{-Wl,-dn} on MIPS RISC/OS).
 
 @code{AC_TRY_LINK} is used to compile test programs to test for
-functions and global variables.  It is also used (by
-@code{AC_CHECK_LIB}) to check for libraries, by adding the library being
+functions and global variables.  It is also used by @code{AC_CHECK_LIB}
+to check for libraries (@pxref{Libraries}), by adding the library being
 checked for to @code{LIBS} temporarily and trying to link a small
 program.
 
 @defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
 @maindex TRY_LINK
-Create a test C program to see whether a function whose body consists of
-@var{function-body} can be compiled and linked; @var{includes} is any
-@code{#include} statements needed by the code in @var{function-body}.
+Depending on the current language (@pxref{Language Choice}), create a
+test program to see whether a function whose body consists of
+@var{function-body} can be compiled and linked.
+
+For C and C++, @var{includes} is any @code{#include} statements needed
+by the code in @var{function-body} (@var{includes} will be ignored if
+the currently selected language is Fortran 77).  This macro also uses
+@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently
+selected language, as well as @code{CPPFLAGS}, when compiling.  If
+Fortran 77 is the currently selected language then @code{FFLAGS} will be
+used when compiling.  However, both @code{LDFLAGS} and @code{LIBS} will
+be used during linking in all cases.
+
 If the file compiles and links successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.  This
-macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS},
-@code{LDFLAGS}, and @code{LIBS} when compiling.
+@var{action-if-found}, otherwise run @var{action-if-not-found}.
 @end defmac
 
 @defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
 @maindex COMPILE_CHECK
-This is an obsolete version of @code{AC_TRY_LINK}, with the addition that it
-prints @samp{checking for @var{echo-text}} to the standard output first,
-if @var{echo-text} is non-empty.  Use @code{AC_MSG_CHECKING} and
-@code{AC_MSG_RESULT} instead to print messages (@pxref{Printing Messages}).
+This is an obsolete version of @code{AC_TRY_LINK}, with the addition
+that it prints @samp{checking for @var{echo-text}} to the standard
+output first, if @var{echo-text} is non-empty.  Use
+@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT} instead to print
+messages (@pxref{Printing Messages}).
 @end defmac
 
 @node Run Time, Portable Shell, Examining Libraries, Writing Tests
@@ -3224,21 +3279,29 @@ extension @file{.C} for test programs.  Set the shell variable
 it has been run, empty otherwise.
 @end defmac
 
+@defmac AC_LANG_FORTRAN77
+@maindex LANG_FORTRAN77
+Do compilation tests using @code{FC} and use extension @file{.f} for
+test programs.  Set the shell variable @code{cross_compiling} to the
+value computed by @code{AC_PROG_FC} if it has been run, empty otherwise.
+@end defmac
+
 @defmac AC_LANG_SAVE
 @maindex LANG_SAVE
-Remember the current language (as set by @code{AC_LANG_C} or
-@code{AC_LANG_CPLUSPLUS}) on a stack.  Does not change which language is
-current.  Use this macro and @code{AC_LANG_RESTORE} in macros that need
-to temporarily switch to a particular language.
+Remember the current language (as set by @code{AC_LANG_C},
+@code{AC_LANG_CPLUSPLUS} or @code{AC_LANG_FORTRAN77}) on a stack.  Does
+not change which language is current.  Use this macro and
+@code{AC_LANG_RESTORE} in macros that need to temporarily switch to a
+particular language.
 @end defmac
 
 @defmac AC_LANG_RESTORE
 @maindex LANG_RESTORE
 Select the language that is saved on the top of the stack, as set by
 @code{AC_LANG_SAVE}, and remove it from the stack.  This macro is
-equivalent to either @code{AC_LANG_C} or @code{AC_LANG_CPLUSPLUS},
-whichever had been run most recently when @code{AC_LANG_SAVE} was last
-called.
+equivalent to either @code{AC_LANG_C}, @code{AC_LANG_CPLUSPLUS} or
+@code{AC_LANG_FORTRAN77}, whichever had been run most recently when
+@code{AC_LANG_SAVE} was last called.
 
 Do not call this macro more times than @code{AC_LANG_SAVE}.
 @end defmac
index 608b58820869cecfebbe23dca55c15c0d7ea390f..61ad88cbc23d318a231964b871cb6f54f00ca66e 100644 (file)
@@ -700,6 +700,7 @@ AC_SUBST(SHELL)dnl
 AC_SUBST(CFLAGS)dnl
 AC_SUBST(CPPFLAGS)dnl
 AC_SUBST(CXXFLAGS)dnl
+AC_SUBST(FFLAGS)dnl
 AC_SUBST(DEFS)dnl
 AC_SUBST(LDFLAGS)dnl
 AC_SUBST(LIBS)dnl
@@ -1244,6 +1245,15 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
 cross_compiling=$ac_cv_prog_cxx_cross
 ])
 
+dnl AC_LANG_FORTRAN77()
+AC_DEFUN([AC_LANG_FORTRAN77],
+[define([AC_LANG], [FORTRAN77])dnl
+ac_ext=f
+ac_compile='$FC $FFLAGS -c conftest.$ac_ext 1>&AC_FD_CC'
+ac_link='$FC $FFLAGS $LDFLAGS -c conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC'
+cross_compiling=$ac_cv_prog_fc_cross
+])
+
 dnl Push the current language on a stack.
 dnl AC_LANG_SAVE()
 define(AC_LANG_SAVE,
@@ -1251,8 +1261,10 @@ define(AC_LANG_SAVE,
 
 dnl Restore the current language from the stack.
 dnl AC_LANG_RESTORE()
-define(AC_LANG_RESTORE,
-[ifelse(AC_LANG_STACK, C, [ifelse(AC_LANG, C, , [AC_LANG_C])], [ifelse(AC_LANG, CPLUSPLUS, , [AC_LANG_CPLUSPLUS])])[]popdef([AC_LANG_STACK])])
+pushdef([AC_LANG_RESTORE],
+[ifelse(AC_LANG_STACK, [C], [AC_LANG_C],dnl
+AC_LANG_STACK, [CPLUSPLUS], [AC_LANG_CPLUSPLUS],dnl
+AC_LANG_STACK, [FORTRAN77], [MDL_LANG_FORTRAN77])[]popdef([AC_LANG_STACK])])
 
 
 dnl ### Compiler-running mechanics
@@ -1479,14 +1491,21 @@ fi
 undefine([AC_VAR_NAME])dnl
 ])
 
-dnl Sets WORKING_VAR to yes if the current compiler works, else no;
-dnl sets CROSS-VAR to yes if it produces non-native executables, else no.
-dnl Before calling this, call AC_LANG_* to set the right language.
+dnl Try to compile, link and execute TEST-PROGRAM.  Set WORKING-VAR to
+dnl `yes' if the current compiler works, otherwise set it ti `no'.  Set
+dnl CROSS-VAR to `yes' if the compiler and linker produce non-native
+dnl executables, otherwise set it to `no'.  Before calling
+dnl `AC_TRY_COMPILER()', call `AC_LANG_*' to set-up for the right
+dnl language.
+dnl 
 dnl AC_TRY_COMPILER(TEST-PROGRAM, WORKING-VAR, CROSS-VAR)
 AC_DEFUN(AC_TRY_COMPILER,
-[cat > conftest.$ac_ext <<EOF
+[cat > conftest.$ac_ext << EOF
+ifelse(AC_LANG, [FORTRAN77], ,
+[
 [#]line __oline__ "configure"
 #include "confdefs.h"
+])
 [$1]
 EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
@@ -1546,6 +1565,7 @@ AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
 [ac_save_LIBS="$LIBS"
 LIBS="-l$1 $5 $LIBS"
 AC_TRY_LINK(dnl
+ifelse(AC_LANG, [FORTRAN77], ,
 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
 [/* Override any gcc2 internal prototype to avoid an error.  */
 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
@@ -1555,7 +1575,7 @@ extern "C"
 [/* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char $2();
-]),
+])),
            [$2()],
            eval "ac_cv_lib_$ac_lib_var=yes",
            eval "ac_cv_lib_$ac_lib_var=no")
@@ -1681,7 +1701,11 @@ dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY,
 dnl             [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 AC_DEFUN(AC_TRY_COMPILE,
 [cat > conftest.$ac_ext <<EOF
-dnl This sometimes fails to find confdefs.h, for some reason.
+ifelse(AC_LANG, [FORTRAN77],
+[      program main
+[$2]
+      end],
+[dnl This sometimes fails to find confdefs.h, for some reason.
 dnl [#]line __oline__ "[$]0"
 [#]line __oline__ "configure"
 #include "confdefs.h"
@@ -1689,7 +1713,7 @@ dnl [#]line __oline__ "[$]0"
 int main() {
 [$2]
 ; return 0; }
-EOF
+])EOF
 if AC_TRY_EVAL(ac_compile); then
   ifelse([$3], , :, [rm -rf conftest*
   $3])
@@ -1719,7 +1743,13 @@ dnl AC_TRY_LINK(INCLUDES, FUNCTION-BODY,
 dnl             [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 AC_DEFUN(AC_TRY_LINK,
 [cat > conftest.$ac_ext <<EOF
-dnl This sometimes fails to find confdefs.h, for some reason.
+ifelse(AC_LANG, [FORTRAN77],
+[
+      program main
+      call [$2]
+      end
+],
+[dnl This sometimes fails to find confdefs.h, for some reason.
 dnl [#]line __oline__ "[$]0"
 [#]line __oline__ "configure"
 #include "confdefs.h"
@@ -1727,7 +1757,7 @@ dnl [#]line __oline__ "[$]0"
 int main() {
 [$2]
 ; return 0; }
-EOF
+])EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
   ifelse([$3], , :, [rm -rf conftest*
   $3])
index a99aa60fd8719d9626eb29de32ac3cef07dea4f2..53ede277b2cc87620e7a30fc2e0264da099bf0c8 100644 (file)
@@ -154,6 +154,56 @@ else
 fi
 ])
 
+dnl Determine a Fortran compiler to use.  If `FC' is not already set in
+dnl the environment, check for `g77', `f77' and `f2c', in that order.
+dnl See the output variable `FC' to the name of the compiler found.
+dnl 
+dnl If using `g77' (the GNU Fortran compiler), then `AC_PROG_FC' will
+dnl set the shell variable `G77' to `yes', and empty otherwise.  If the
+dnl output variable `FFLAGS' was not already set in the environment,
+dnl then set it to `-g -02' for `g77' (or `-O2' where `g77' does not
+dnl accept `-g').  Otherwise, set `FFLAGS' to `-g' for all other Fortran
+dnl compilers.
+dnl 
+dnl AC_PROG_FC()
+AC_DEFUN(AC_PROG_FC,
+[AC_BEFORE([$0], [AC_PROG_CPP])dnl
+if test -z "$FC"; then
+  AC_CHECK_PROG(FC, g77, g77)
+  if test -z "$FC"; then
+    AC_CHECK_PROG(FC, f77, f77)
+    if test -z "$FC"; then
+      AC_CHECK_PROG(FC, f2c, f2c)
+    fi
+    test -z "$FC" && AC_MSG_ERROR([no acceptable Fortran compiler found in \$PATH])
+  fi
+fi
+
+AC_PROG_FC_WORKS
+AC_PROG_FC_GNU
+
+if test $ac_cv_prog_g77 = yes; then
+  G77=yes
+dnl Check whether -g works, even if FFLAGS is set, in case the package
+dnl plays around with FFLAGS (such as to build both debugging and
+dnl normal versions of a library), tasteless as that idea is.
+  ac_test_FFLAGS="${FFLAGS+set}"
+  ac_save_FFLAGS="$FFLAGS"
+  FFLAGS=
+  AC_PROG_FC_G
+  if test "$ac_test_FFLAGS" = set; then
+    FFLAGS="$ac_save_FFLAGS"
+  elif test $ac_cv_prog_fc_g = yes; then
+    FFLAGS="-g -O2"
+  else
+    FFLAGS="-O2"
+  fi
+else
+  G77=
+  test "${FFLAGS+set}" = set || FFLAGS="-g"
+fi
+])
+
 AC_DEFUN(AC_PROG_CC_WORKS,
 [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) works])
 AC_LANG_SAVE
@@ -184,6 +234,30 @@ AC_MSG_RESULT($ac_cv_prog_cxx_cross)
 cross_compiling=$ac_cv_prog_cxx_cross
 ])
 
+dnl Test whether the Fortran compiler can compile and link a trivial
+dnl Fortran program.  Also, test whether the Fortran compiler is a
+dnl cross-compiler (which may realistically be the case if the Fortran
+dnl compiler is `g77').
+dnl 
+dnl AC_PROG_FC_WORKS()
+AC_DEFUN(AC_PROG_FC_WORKS,
+[AC_MSG_CHECKING([whether the Fortran compiler ($FC $FFLAGS $LDFLAGS) works])
+AC_LANG_SAVE
+AC_LANG_FORTRAN77
+AC_TRY_COMPILER(dnl
+[       program conftest
+       end
+], ac_cv_prog_fc_works, ac_cv_prog_fc_cross)
+AC_LANG_RESTORE
+AC_MSG_RESULT($ac_cv_prog_fc_works)
+if test $ac_cv_prog_fc_works = no; then
+  AC_MSG_ERROR([installation or configuration problem: Fortran compiler cannot create executables.])
+fi
+AC_MSG_CHECKING([whether the Fortran compiler ($FC $FFLAGS $LDFLAGS) is a cross-compiler])
+AC_MSG_RESULT($ac_cv_prog_fc_cross)
+cross_compiling=$ac_cv_prog_fc_cross
+])
+
 AC_DEFUN(AC_PROG_CC_GNU,
 [AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
 [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
@@ -212,6 +286,24 @@ else
   ac_cv_prog_gxx=no
 fi])])
 
+dnl Test whether for Fortran compiler is `g77' (the GNU Fortran
+dnl Compiler).  This test depends on whether the Fortran compiler can do
+dnl CPP pre-processing.
+dnl 
+dnl AC_PROG_FC_GNU()
+AC_DEFUN(AC_PROG_FC_GNU,
+[AC_CACHE_CHECK(whether we are using GNU Fortran, ac_cv_prog_g77,
+[cat > conftest.fpp <<EOF
+#ifdef __GNUC__
+  yes
+#endif
+EOF
+if AC_TRY_COMMAND($FC -E conftest.fpp) | egrep yes >/dev/null 2>&1; then
+  ac_cv_prog_g77=yes
+else
+  ac_cv_prog_g77=no
+fi])])
+
 AC_DEFUN(AC_PROG_CC_G,
 [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,
 [echo 'void f(){}' > conftest.c
@@ -234,6 +326,24 @@ fi
 rm -f conftest*
 ])])
 
+dnl Test whether the Fortran compiler can accept the `-g' option to
+dnl enable debugging.
+dnl 
+dnl AC_PROG_FC_G()
+AC_DEFUN(AC_PROG_FC_G,
+[AC_CACHE_CHECK(whether $FC accepts -g, ac_cv_prog_fc_g,
+[cat > conftest.f << EOF
+       program conftest
+       end
+EOF
+if test -z "`$FC -g -c conftest.f 2>&1`"; then
+  ac_cv_prog_fc_g=yes
+else
+  ac_cv_prog_fc_g=no
+fi
+rm -f conftest*
+])])
+
 AC_DEFUN(AC_PROG_GCC_TRADITIONAL,
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_PROG_CPP])dnl
@@ -304,6 +414,45 @@ else
 fi
 ])
 
+dnl Test if the Fortran compiler accepts the options `-c' and `-o'
+dnl simultaneously, and define `FC_NO_MINUS_C_MINUS_O' if it does not.
+dnl
+dnl The usefulness of this macro is questionable, as I can't really see
+dnl why anyone would use it.  The only reason I include it is for
+dnl completeness, since a similar test exists for the C compiler.
+dnl 
+dnl AC_PROG_FC_C_O
+AC_DEFUN(AC_PROG_FC_C_O,
+[AC_BEFORE([$0], [AC_PROG_FC])dnl
+AC_MSG_CHECKING(whether $FC understand -c and -o together)
+set dummy $FC; ac_fc="`echo [$]2 |
+changequote(, )dnl
+sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
+changequote([, ])dnl
+AC_CACHE_VAL(ac_cv_prog_fc_${ac_fc}_c_o,
+[cat > conftest.f << EOF
+       program conftest
+       end
+EOF
+# We do the `AC_TRY_EVAL' test twice because some compilers refuse to
+# overwrite an existing `.o' file with `-o', although they will create
+# one.
+ac_try='$FC $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC'
+if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
+  eval ac_cv_prog_fc_${ac_fc}_c_o=yes
+else
+  eval ac_cv_prog_fc_${ac_fc}_c_o=no
+fi
+rm -f conftest*
+])dnl
+if eval "test \"`echo '$ac_cv_prog_fc_'${ac_fc}_c_o`\" = yes"; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+  AC_DEFINE(FC_NO_MINUS_C_MINUS_O)
+fi
+])
+
 dnl Define SET_MAKE to set ${MAKE} if make doesn't.
 AC_DEFUN(AC_PROG_MAKE_SET,
 [AC_MSG_CHECKING(whether ${MAKE-make} sets \${MAKE})