]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* tests/fortran.at (GNU Fortran 77): Don't run FC macros.
authorAkim Demaille <akim@epita.fr>
Fri, 31 Oct 2003 08:44:46 +0000 (08:44 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 31 Oct 2003 08:44:46 +0000 (08:44 +0000)
(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.

ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/fortran.m4
tests/fortran.at

index 54d5f2cd2d782427c3455d5c2e123c423f7d5555..ef41b0b2ed1f2018a7052117e4d58818161f7fbe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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
diff --git a/NEWS b/NEWS
index af82355d78bd27aa5df0c58d6ff3ce00e4f9bfeb..8fdecf2507a6fb8c07f08a6ab157fea0e74b9f85 100644 (file)
--- 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
index 4d3a207656fd853ecadd33eccb41697743a1a98f..8ff4865648210a1106e10957a9323bcb6fea0405 100644 (file)
@@ -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:
index 09fdaafce94e2b899ebf67b51f5315f4299be494..8ba4ad36f15c67370aa1146843730cec3e076a4a 100644 (file)
@@ -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],
index 362edb4a63836422a0f43d742e51f24ce2dc3715..8c5bbda3a5a4227a361695cb95b301a19195ae52 100644 (file)
@@ -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
 ]])