]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
New macro AC_FC_FIXEDFORM, improved AC_FC_FREEFORM, coverage.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Mon, 28 Jun 2010 22:15:25 +0000 (00:15 +0200)
committerEric Blake <eblake@redhat.com>
Fri, 2 Jul 2010 19:45:04 +0000 (13:45 -0600)
* lib/autoconf/fortran.m4 (_AC_FC_DIALECT_YEAR): Fix typo in
comment.
(AC_FC_FREEFORM): Update list of known options for Sun, HP,
Lahey/Fujitsu Fortran compilers.  Use M4 quoting consistently.
(AC_FC_FIXEDFORM): New macro.
* tests/fortran.at (AC_FC_DUMMY_MAIN usage, AC_FC_MAIN usage):
Use AC_FC_FIXEDFORM, to avoid testsuite failure with FC=xlf95.
(AC_FC_FREEFORM with AC_FC_SRCEXT, AC_FC_FIXEDFORM)
(AC_FC_FIXEDFORM with AC_FC_SRCEXT): New tests.
* tests/mktests.sh: No need to exclude AC_FC_FREEFORM, it uses
AC_LANG_PUSH/AC_LANG_POP.
* doc/autoconf.texi (Fortran Compiler): Document it.
* NEWS: Update.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/fortran.m4
tests/fortran.at
tests/mktests.sh

index a559c167b83c8754cb29a5f01ba5108b74905ad7..82df57cea792e2fb837b838e87da4b3bff0d3223 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2010-07-02  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       New macro AC_FC_FIXEDFORM, improved AC_FC_FREEFORM, coverage.
+       * lib/autoconf/fortran.m4 (_AC_FC_DIALECT_YEAR): Fix typo in
+       comment.
+       (AC_FC_FREEFORM): Update list of known options for Sun, HP,
+       Lahey/Fujitsu Fortran compilers.  Use M4 quoting consistently.
+       (AC_FC_FIXEDFORM): New macro.
+       * tests/fortran.at (AC_FC_DUMMY_MAIN usage, AC_FC_MAIN usage):
+       Use AC_FC_FIXEDFORM, to avoid testsuite failure with FC=xlf95.
+       (AC_FC_FREEFORM with AC_FC_SRCEXT, AC_FC_FIXEDFORM)
+       (AC_FC_FIXEDFORM with AC_FC_SRCEXT): New tests.
+       * tests/mktests.sh: No need to exclude AC_FC_FREEFORM, it uses
+       AC_LANG_PUSH/AC_LANG_POP.
+       * doc/autoconf.texi (Fortran Compiler): Document it.
+       * NEWS: Update.
+
 2010-07-02  Eric Blake  <eblake@redhat.com>
 
        Optimize AS_BOX.
diff --git a/NEWS b/NEWS
index 8acc6e7a316cdcc87567af8ba185a6cd11a5db89..cb1ffbd29314872d3d4681bbee3bd3ca72b3dc1a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,8 @@ GNU Autoconf NEWS - User visible changes.
 ** The following macros are now documented:
    AS_BOX
 
+** New macro AC_FC_FIXEDFORM to accept fixed-form Fortran.
+
 
 * Major changes in Autoconf 2.65 (2009-11-21) [stable]
   Released by Eric Blake, based on git versions 2.64.*.
index f531ed6e17d2051e273128a838def7941b666cf4..0c106c71e82c8a5548960180d628199ece0dedb9 100644 (file)
@@ -7750,8 +7750,8 @@ 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
+Except for the macros @code{AC_FC_SRCEXT}, @code{AC_FC_FREEFORM}, and
+@code{AC_FC_FIXEDFORM} (see below), the @code{FC} and @code{F77} macros
 behave almost identically, and so they are documented together in this
 section.
 
@@ -8109,6 +8109,28 @@ calls @var{action-if-failure} (defaults to exiting with an error
 message).
 @end defmac
 
+@defmac AC_FC_FIXEDFORM (@ovar{action-if-success}, @ovar{action-if-failure})
+@acindex{FC_FIXEDFORM}
+
+The @code{AC_FC_FIXEDFORM} tries to ensure that the Fortran compiler
+(@code{$FC}) allows the old fixed-format source code (as opposed to
+free-format style).  If necessary, it may add some additional flags to
+@code{FCFLAGS}.
+
+This macro is needed for some compilers alias names like @command{xlf95}
+which assume free-form source code by default, and in case you want to
+use fixed-form source with an extension like @file{.f90} which many
+compilers interpret as free-form by default.  If you specify a different
+extension with @code{AC_FC_SRCEXT}, such as @file{.f}, then
+@code{AC_FC_FIXEDFORM} ordinarily succeeds without modifying
+@code{FCFLAGS}.
+
+If @code{AC_FC_FIXEDFORM} succeeds in compiling fixed-form source, it
+calls @var{action-if-success} (defaults to nothing).  If it fails, it
+calls @var{action-if-failure} (defaults to exiting with an error
+message).
+@end defmac
+
 @node System Services
 @section System Services
 
index 1d8ef0b891b86a99af138e442d1ed08b94efb648..f059546dec71be5987f6b1f8d61ae71ad59b22bc 100644 (file)
@@ -308,7 +308,7 @@ AC_DEFUN([_AC_FC_DIALECT_YEAR],
 #  frt: Fujitsu F77 compiler
 #  pgf77/pgf90/pghpf/pgf95/pgfortran: Portland Group F77/F90/F95 compilers
 #  xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
-#    Prefer xlf9x to the generic names because they do not reject file
+#    Prefer xlf9x to the generic names because they do not reject files
 #    with extension `.f'.
 #  lf95: Lahey-Fujitsu F95 compiler
 #  fl32: Microsoft Fortran 77 "PowerStation" compiler
@@ -1164,23 +1164,25 @@ AC_LANG_POP(Fortran)dnl
 # prevent flag from being added to FCFLAGS multiple times.)
 #
 # The known flags are:
-#        -ffree-form: GNU g77
-#                -FR: Intel compiler (icc, ecc)
-#              -free: Compaq compiler (fort)
+#        -ffree-form: GNU g77, gfortran
+#         -FR, -free: Intel compiler (icc, ecc, ifort)
+#              -free: Compaq compiler (fort), Sun compiler (f95)
 #             -qfree: IBM compiler (xlf)
 # -Mfree, -Mfreeform: Portland Group compiler
 #          -freeform: SGI compiler
 #            -f free: Absoft Fortran
+#       +source=free: HP Fortran
+#              -nfix: Lahey/Fujitsu Fortran
 # We try to test the "more popular" flags first, by some prejudiced
 # notion of popularity.
 AC_DEFUN_ONCE([AC_FC_FREEFORM],
-[AC_LANG_PUSH(Fortran)dnl
-AC_CACHE_CHECK([for Fortran flag needed to allow free-form source],
-               ac_cv_fc_freeform,
+[AC_LANG_PUSH([Fortran])dnl
+AC_CACHE_CHECK([for Fortran flag needed to accept free-form source],
+              [ac_cv_fc_freeform],
 [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"
+              -freeform "-f free" +source=free -nfix
 do
   test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag"
 dnl Use @&t@ below to ensure that editors don't turn 8+ spaces into tab.
@@ -1204,5 +1206,58 @@ else
   fi
   $1
 fi
-AC_LANG_POP(Fortran)dnl
+AC_LANG_POP([Fortran])dnl
 ])# AC_FC_FREEFORM
+
+
+# AC_FC_FIXEDFORM([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
+# ------------------------------------------------------------------
+# Look for a compiler flag to make the Fortran (FC) compiler accept
+# fixed-format source code, and adds it to FCFLAGS.  Call
+# ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can
+# compile code using new extension) and ACTION-IF-FAILURE (defaults to
+# failing with an error message) if not.  (Defined via DEFUN_ONCE to
+# prevent flag from being added to FCFLAGS multiple times.)
+#
+# The known flags are:
+#       -ffixed-form: GNU g77, gfortran
+#             -fixed: Intel compiler (ifort), Sun compiler (f95)
+#            -qfixed: IBM compiler (xlf*)
+#            -Mfixed: Portland Group compiler
+#         -fixedform: SGI compiler
+#           -f fixed: Absoft Fortran
+#      +source=fixed: HP Fortran
+#              -fix: Lahey/Fujitsu Fortran
+# Since compilers may accept fixed form based on file name extension,
+# but users may want to use it with others as well, call AC_FC_SRCEXT
+# with the respective source extension before calling this macro.
+AC_DEFUN_ONCE([AC_FC_FIXEDFORM],
+[AC_LANG_PUSH([Fortran])dnl
+AC_CACHE_CHECK([for Fortran flag needed to accept fixed-form source],
+              [ac_cv_fc_fixedform],
+[ac_cv_fc_fixedform=unknown
+ac_fc_fixedform_FCFLAGS_save=$FCFLAGS
+for ac_flag in none -ffixed-form -fixed -qfixed -Mfixed -fixedform "-f fixed" \
+              +source=fixed -fix
+do
+  test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_fixedform_FCFLAGS_save $ac_flag"
+  AC_COMPILE_IFELSE([
+C     This comment should confuse free-form compilers.
+      program main
+      end],
+                   [ac_cv_fc_fixedform=$ac_flag; break])
+done
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+FCFLAGS=$ac_fc_fixedform_FCFLAGS_save
+])
+if test "x$ac_cv_fc_fixedform" = xunknown; then
+  m4_default([$2],
+            [AC_MSG_ERROR([Fortran does not accept fixed-form source], 77)])
+else
+  if test "x$ac_cv_fc_fixedform" != xnone; then
+    FCFLAGS="$FCFLAGS $ac_cv_fc_fixedform"
+  fi
+  $1
+fi
+AC_LANG_POP([Fortran])dnl
+])# AC_FC_FIXEDFORM
index 1b435322f94dea140e9aef24c69bcd1569207054..24d2a61fd45babcdf4987278298d2c51a483e0f7 100644 (file)
@@ -257,6 +257,7 @@ AT_DATA([configure.ac],
 [[AC_INIT
 AC_CONFIG_HEADERS([config.h:config.hin])
 AC_PROG_FC
+AC_FC_FIXEDFORM
 AC_FC_DUMMY_MAIN([], [AC_MSG_FAILURE([failed to determine FC dummy main], [77])])
 AC_FC_WRAPPERS
 AC_PROG_CC
@@ -419,6 +420,7 @@ AT_DATA([configure.ac],
 [[AC_INIT
 AC_CONFIG_HEADERS([config.h:config.hin])
 AC_PROG_FC
+AC_FC_FIXEDFORM
 AC_FC_MAIN
 AC_FC_WRAPPERS
 AC_PROG_CC
@@ -757,3 +759,118 @@ AT_CHECK([$MAKE], [], [ignore], [ignore])
 dnl AT_CHECK([./prog])
 
 AT_CLEANUP
+
+
+## --------------------------------- ##
+## AC_FC_FREEFORM with AC_FC_SRCEXT. ##
+## --------------------------------- ##
+
+AT_SETUP([AC_FC_FREEFORM with AC_FC_SRCEXT])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_FC_SRCEXT([f90])
+AC_PROG_FC
+AC_FC_FREEFORM
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[prog: prog.@OBJEXT@
+       @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f90 .@OBJEXT@
+.f90.@OBJEXT@:
+       @FC@ @FCFLAGS@ -c @FCFLAGS_f90@ $<
+]])
+
+AT_DATA([prog.f90],
+[[program main
+end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: ${MAKE=make}
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./prog])
+
+AT_CLEANUP
+
+
+## ---------------- ##
+## AC_FC_FIXEDFORM. ##
+## ---------------- ##
+
+AT_SETUP([AC_FC_FIXEDFORM])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_FC_FIXEDFORM
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[prog: prog.@OBJEXT@
+       @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f .@OBJEXT@
+.f.@OBJEXT@:
+       @FC@ @FCFLAGS@ -c $<
+]])
+
+AT_DATA([prog.f],
+[[      program main
+C      fixed-form style comment
+       end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: ${MAKE=make}
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./prog])
+
+AT_CLEANUP
+
+
+## ---------------------------------- ##
+## AC_FC_FIXEDFORM with AC_FC_SRCEXT. ##
+## ---------------------------------- ##
+
+AT_SETUP([AC_FC_FIXEDFORM with AC_FC_SRCEXT])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_FC_SRCEXT([f90])
+AC_FC_FIXEDFORM
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
+[[prog: prog.@OBJEXT@
+       @FC@ @FCFLAGS@ -o $@ prog.@OBJEXT@ @LIBS@
+
+.SUFFIXES: .f90 .@OBJEXT@
+.f90.@OBJEXT@:
+       @FC@ @FCFLAGS@ -c @FCFLAGS_f90@ $<
+]])
+
+AT_DATA([prog.f90],
+[[      program main
+C      fixed-form style comment
+       end
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+: ${MAKE=make}
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+dnl AT_CHECK([./prog])
+
+AT_CLEANUP
index fe59be2c3304ce75a0983262631b3bdc2b24e909..0a04e59cf3b71997a2ac93799bba1463b82ee785 100755 (executable)
@@ -104,9 +104,6 @@ ac_exclude_list='
        /^AC_FC_SRCEXT$/ {next}
        /^AC_PATH_((TARGET_)?TOOL|PROG)S?$/ {next}
 
-       # Requires the current language to be Fortran, not C.
-       /^AC_FC_FREEFORM$/ {next}
-
        # Is a number.
        /^AC_FD_CC$/ {next}