summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--NEWS3
-rw-r--r--doc/autoconf.texi30
-rw-r--r--lib/autoconf/fortran.m432
-rw-r--r--tests/fortran.at16
5 files changed, 69 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 54d5f2cd..ef41b0b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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
than `\n\n', so that `\n\n\n' is valid in warnings.
Reported by Steve Huston.
diff --git a/NEWS b/NEWS
index af82355d..8fdecf25 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@
** 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
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 4d3a2076..8ff48656 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -5624,9 +5624,10 @@ are for newer programs that can (or must) compile under the newer
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})
@@ -5957,7 +5958,6 @@ If @code{AC_FC_FREEFORM} succeeds in compiling free-form source, it
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
@@ -6186,8 +6186,6 @@ test programs. Use compilation flags: @code{FFLAGS}.
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
@@ -6215,6 +6213,25 @@ AC_LANG_POP(Fortran 77)
@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
@@ -15707,5 +15724,6 @@ introduced in this document.
@bye
@c Local Variables:
+@c fill-column: 72
@c ispell-local-dictionary: "american"
@c End:
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 09fdaafc..8ba4ad36 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -699,6 +699,7 @@ fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
])# _AC_FC_LIBRARY_LDFLAGS
+
# AC_F77_LIBRARY_LDFLAGS
# ----------------------
AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],
@@ -708,6 +709,7 @@ _AC_FC_LIBRARY_LDFLAGS
AC_LANG_POP(Fortran 77)dnl
])# AC_F77_LIBRARY_LDFLAGS
+
# AC_FC_LIBRARY_LDFLAGS
# ----------------------
AC_DEFUN([AC_FC_LIBRARY_LDFLAGS],
@@ -803,6 +805,7 @@ fi])],
[AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])
])# _AC_FC_DUMMY_MAIN
+
# AC_F77_DUMMY_MAIN
# ----------------------
AC_DEFUN([AC_F77_DUMMY_MAIN],
@@ -812,6 +815,7 @@ _AC_FC_DUMMY_MAIN
AC_LANG_POP(Fortran 77)dnl
])# AC_F77_DUMMY_MAIN
+
# AC_FC_DUMMY_MAIN
# ----------------------
AC_DEFUN([AC_FC_DUMMY_MAIN],
@@ -859,8 +863,9 @@ AC_DEFINE_UNQUOTED([]_AC_FC[]_MAIN, $ac_cv_[]_AC_LANG_ABBREV[]_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
@@ -868,8 +873,9 @@ _AC_FC_MAIN
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
@@ -969,6 +975,7 @@ AC_CACHE_CHECK([for Fortran name-mangling scheme],
# The replacement is empty.
AU_DEFUN([AC_F77_NAME_MANGLING], [])
+
# _AC_F77_NAME_MANGLING
# ----------------------
AC_DEFUN([_AC_F77_NAME_MANGLING],
@@ -979,6 +986,7 @@ __AC_FC_NAME_MANGLING
AC_LANG_POP(Fortran 77)dnl
])# _AC_F77_NAME_MANGLING
+
# _AC_FC_NAME_MANGLING
# ----------------------
AC_DEFUN([_AC_FC_NAME_MANGLING],
@@ -1034,8 +1042,9 @@ case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
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
@@ -1043,8 +1052,9 @@ _AC_FC_WRAPPERS
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
@@ -1118,10 +1128,10 @@ AC_LANG_POP(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
@@ -1131,7 +1141,6 @@ for ac_flag in none -qsuffix=f=$1 -Tf; do
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])])
@@ -1170,10 +1179,10 @@ fi
# 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"
@@ -1189,7 +1198,6 @@ do
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],
diff --git a/tests/fortran.at b/tests/fortran.at
index 362edb4a..8c5bbda3 100644
--- a/tests/fortran.at
+++ b/tests/fortran.at
@@ -49,6 +49,18 @@ else
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])
@@ -56,10 +68,10 @@ 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
]])