The problem is a conflict between the REQUIRE and the LANG mechanisms.
It is a grave bug (oops, sorry, I meant serious :), and must be fixed.
Basically if you have two macros, AC_F77_1 and AC_F77_2, requiring to
be run with a Fortran context, then with
AC_DEFUN([AC_F77_1],
[AC_LANG_PUSH([Fortran 77])
# Blah blah 1
AC_LANG_POP
])
AC_DEFUN([AC_F77_2],
[AC_LANG_PUSH([Fortran 77])
AC_REQUIRE([AC_F77_1])
# Blah blah 2
AC_LANG_POP
])
and you call the latter, then it sets the current LANG to F77, then
requires AC_F77_1 which will be expanded *before* the code currently
emitted, and in particular *before* the code that has just been
emitted for F77, i.e., ac_ext=f etc.
But when expanding AC_F77_1, it sees it should switch to the Fortran
77 language, which is useless since the current language is precisely
Fortran 77. So the ac_ext=f code is not emitted, which results in
AC_PROG_F77 being run in a C sh context.
Sure, removing the AC_LANG optimization is one way. I'd like to take
a couple of days thinking more about this.
Nevertheless, this is an excellent candidate for the test suite!
Thanks!
Oh, BTW, the `right workaround' definitely consists in wrapping your
Fortran 77 section with AC_LANG_PUSH(Fortran 77)/AC_LANG_POP.