(GNU Fortran): New.
* doc/autoconf.texi (Language Choice): Document.
* lib/autoconf/fortran.m4 (AC_FC_SRCEXT, AC_FC_FREEFORM): Assert
the current language is Fortran.
+2003-10-31 Akim Demaille <akim@epita.fr>
+
+ * tests/fortran.at (GNU Fortran 77): Don't run FC macros.
+ (GNU Fortran): New.
+ * doc/autoconf.texi (Language Choice): Document.
+ * lib/autoconf/fortran.m4 (AC_FC_SRCEXT, AC_FC_FREEFORM): Assert
+ the current language is Fortran.
+
2003-10-31 Akim Demaille <akim@epita.fr>
* bin/autom4te.in (&freeze): Use a less likely warning separator
** core.*
core.* files are no longer removed, as they may be valid user files.
+** New macros
+ AC_LANG_ASSERT.
+
* Major changes in Autoconf 2.57g
Released 2003-10-24, by Akim Demaille
Fortran standards, and have output variables like @code{FC},
@code{FCFLAGS}, and @code{FCLIBS}.
-Except for two new macros @code{AC_FC_SRCEXT} and @code{AC_FC_FREEFORM}
-(see below), the @code{FC} and @code{F77} macros behave almost identically, and so
-they are documented together in this section.
+Except for two new macros @code{AC_FC_SRCEXT} and
+@code{AC_FC_FREEFORM} (see below), the @code{FC} and @code{F77} macros
+behave almost identically, and so they are documented together in this
+section.
@defmac AC_PROG_F77 (@ovar{compiler-search-list})
calls @ovar{action-if-success} (defaults to nothing). If it fails, it
calls @ovar{action-if-failure} (defaults to exiting with an error
message).
-
@end defmac
@node System Services
Do compilation tests using @code{FC} and use extension @file{.f} (or
whatever has been set by @code{AC_FC_SRCEXT}) for test programs. Use
compilation flags: @code{FCFLAGS}.
-
-
@end table
@end defmac
@end example
@end defmac
+@defmac AC_LANG_ASSERT (@var{language})
+@acindex{LANG_ASSERT} Check statically that the current language is
+@var{language}. You should use this in your language specific macros
+to avoid that they be called with an inappropriate language.
+
+This macro runs only at @command{autoconf} time, and incurs no cost at
+@command{configure} time. Sadly enough and because Autoconf is a two
+layer language @footnote{Because M4 is not aware of Sh code,
+especially conditionals, some optimizations that look nice statically
+may produce incorrect results at runtime.}, the macros
+@code{AC_LANG_PUSH}/@code{AC_LANG_POP} cannot be ``optimizing'',
+therefore as much as possible you ought to avoid using them to wrap
+your code, rather, require from the user to run the macro with a
+correct current language, and check it with @code{AC_LANG_ASSERT}.
+And anyway, that may help the user understand she is running a Fortran
+macro while expecting a result about her Fortran 77 compiler...
+@end defmac
+
+
@defmac AC_REQUIRE_CPP
@acindex{REQUIRE_CPP}
Ensure that whichever preprocessor would currently be used for tests has
@bye
@c Local Variables:
+@c fill-column: 72
@c ispell-local-dictionary: "american"
@c End:
AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
])# _AC_FC_LIBRARY_LDFLAGS
+
# AC_F77_LIBRARY_LDFLAGS
# ----------------------
AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],
AC_LANG_POP(Fortran 77)dnl
])# AC_F77_LIBRARY_LDFLAGS
+
# AC_FC_LIBRARY_LDFLAGS
# ----------------------
AC_DEFUN([AC_FC_LIBRARY_LDFLAGS],
[AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])
])# _AC_FC_DUMMY_MAIN
+
# AC_F77_DUMMY_MAIN
# ----------------------
AC_DEFUN([AC_F77_DUMMY_MAIN],
AC_LANG_POP(Fortran 77)dnl
])# AC_F77_DUMMY_MAIN
+
# AC_FC_DUMMY_MAIN
# ----------------------
AC_DEFUN([AC_FC_DUMMY_MAIN],
called from a `main' in the Fortran libraries.])
])# _AC_FC_MAIN
+
# AC_F77_MAIN
-# ----------------------
+# -----------
AC_DEFUN([AC_F77_MAIN],
[AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
AC_LANG_PUSH(Fortran 77)dnl
AC_LANG_POP(Fortran 77)dnl
])# AC_F77_MAIN
+
# AC_FC_MAIN
-# ----------------------
+# ----------
AC_DEFUN([AC_FC_MAIN],
[AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
AC_LANG_PUSH(Fortran)dnl
# The replacement is empty.
AU_DEFUN([AC_F77_NAME_MANGLING], [])
+
# _AC_F77_NAME_MANGLING
# ----------------------
AC_DEFUN([_AC_F77_NAME_MANGLING],
AC_LANG_POP(Fortran 77)dnl
])# _AC_F77_NAME_MANGLING
+
# _AC_FC_NAME_MANGLING
# ----------------------
AC_DEFUN([_AC_FC_NAME_MANGLING],
esac
])# _AC_FC_WRAPPERS
+
# AC_F77_WRAPPERS
-# ----------------------
+# ---------------
AC_DEFUN([AC_F77_WRAPPERS],
[AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
AC_LANG_PUSH(Fortran 77)dnl
AC_LANG_POP(Fortran 77)dnl
])# AC_F77_WRAPPERS
+
# AC_FC_WRAPPERS
-# ----------------------
+# --------------
AC_DEFUN([AC_FC_WRAPPERS],
[AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
AC_LANG_PUSH(Fortran)dnl
# some versions), the $FCFLAGS_<EXT> variable *must* go immediately before
# the source file on the command line, unlike other $FCFLAGS. Ugh.
AC_DEFUN([AC_FC_SRCEXT],
-[AC_CACHE_CHECK([for Fortran flag to compile .$1 files],
+[AC_LANG_ASSERT(Fortran)dnl
+AC_CACHE_CHECK([for Fortran flag to compile .$1 files],
ac_cv_fc_srcext_$1,
-[AC_LANG_PUSH(Fortran)dnl
-ac_ext=$1
+[ac_ext=$1
ac_fc_srcext_FCFLAGS_SRCEXT_save=$FCFLAGS_SRCEXT
FCFLAGS_SRCEXT=""
ac_cv_fc_srcext_$1=unknown
done
rm -f conftest.$ac_objext conftest.$1
FCFLAGS_SRCEXT=$ac_fc_srcext_FCFLAGS_SRCEXT_save
-AC_LANG_POP(Fortran)dnl
])
if test "x$ac_cv_fc_srcext_$1" = xunknown; then
m4_default([$3],[AC_MSG_ERROR([Fortran could not compile .$1 files])])
# We try to test the "more popular" flags first, by some prejudiced
# notion of popularity.
AC_DEFUN_ONCE([AC_FC_FREEFORM],
-[AC_CACHE_CHECK([for Fortran flag needed to allow free-form source],
+[AC_LANG_ASSERT([Fortran])dnl
+AC_CACHE_CHECK([for Fortran flag needed to allow free-form source],
ac_cv_fc_freeform,
-[AC_LANG_PUSH(Fortran)dnl
-ac_cv_fc_freeform=unknown
+[ac_cv_fc_freeform=unknown
ac_fc_freeform_FCFLAGS_save=$FCFLAGS
for ac_flag in none -ffree-form -FR -free -qfree -Mfree -Mfreeform \
-freeform "-f free"
done
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
FCFLAGS=$ac_fc_freeform_FCFLAGS_save
-AC_LANG_POP(Fortran)dnl
])
if test "x$ac_cv_fc_freeform" = xunknown; then
m4_default([$2],
test "$G77" = yes &&
AC_MSG_ERROR([incorrectly recognized a GNU Fortran 77 compiler])
fi
+]])
+
+
+
+## ------------------ ##
+## Fortran Compiler. ##
+## ------------------ ##
+
+
+AT_CHECK_MACRO([GNU Fortran],
+[[AC_LANG(Fortran)
+AC_LANG_COMPILER
# No Fortran compiler is known not to support "*.f".
AC_FC_SRCEXT([f])
# GNU Fortran is known to support freeform.
AC_FC_FREEFORM([],
[AC_MSG_WARN([Fortran does not accept free-form source])])
-if test "$G77" = yes; then
+if test "$ac_compiler_gnu" = yes; then
case $FCFLAGS in
*-ffree-form*) ;;
- *) AC_MSG_ERROR([failed to recognize G77's -ffree-form option.]);;
+ *) AC_MSG_ERROR([failed to recognize GNU Fortran's -ffree-form option.]);;
esac
fi
]])