The attached patch adds a white-space separated list of Fortran compilers
whose existence should be ignored to AC_PROG_{FC,F77}.
(There may be better ways of implementing this!)

The problem I encountered was that the first available compiler on
the checklist was unable to compile a particular program. The
current options to work around this are:

- look for another compiler on the system and set FC
- add a list of compilers to try without the problematic one as the first
  argument to AC_PROG_FC

I was looking for an option of the form "I don't know what other compilers
are on this system, I just know that foo95 doesn't work in this case".

If this is deemed to be a good idea, would a --with{,out}-fortran-compilers
option by desirable to manipulate arguments 1 and 3 to AC_PROG_FC more
easily for a configure user?

Cheers,

Patrick
>From 27196e1aa3a661447d2404fa0266e2b524d8153f Mon Sep 17 00:00:00 2001
From: Patrick Welche <[email protected]>
Date: Mon, 17 Jun 2013 09:55:47 +0100
Subject: [PATCH] fortran.m4: add list of Fortran compilers to ignore as
 argument to AC_PROG_{FC,F77}

---
 doc/autoconf.texi       | 13 +++++++++++--
 lib/autoconf/fortran.m4 | 15 ++++++++++-----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index faf6d97..95beb10 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7870,7 +7870,7 @@ Except for the macros @code{AC_FC_SRCEXT}, 
@code{AC_FC_FREEFORM},
 are documented together in this section.
 
 
-@defmac AC_PROG_F77 (@ovar{compiler-search-list})
+@defmac AC_PROG_F77 (@ovar{compiler-search-list}, 
@ovar{rejected-compiler-list})
 @acindex{PROG_F77}
 @evindex F77
 @evindex FFLAGS
@@ -7883,6 +7883,10 @@ set in the environment, then check for @code{g77} and 
@code{f77}, and
 then some other names.  Set the output variable @code{F77} to the name
 of the compiler found.
 
+The optional second argument to the macro is a blank-separated list of
+Fortran 77 compilers whose presence should be ignored and are omitted
+from the search.
+
 This macro may, however, be invoked with an optional first argument
 which, if specified, must be a blank-separated list of Fortran 77
 compilers to search for.  This just gives the user an opportunity to
@@ -7906,7 +7910,8 @@ The result of the GNU test is cached in the
 @code{ac_cv_prog_f77_g} variable.
 @end defmac
 
-@defmac AC_PROG_FC (@ovar{compiler-search-list}, @ovar{dialect})
+@defmac AC_PROG_FC (@ovar{compiler-search-list}, @ovar{dialect}, @
+  @ovar{rejected-compiler-list})
 @acindex{PROG_FC}
 @evindex FC
 @evindex FCFLAGS
@@ -7930,6 +7935,10 @@ is actually supported.  Thus, it is preferable that you 
avoid the
 @code{dialect} option, and use AC_PROG_FC only for code compatible with
 the latest Fortran standard.
 
+The optional third argument to the macro is a blank-separated list of
+Fortran compilers whose presence should be ignored and are omitted
+from the search.
+
 This macro may, alternatively, be invoked with an optional first argument
 which, if specified, must be a blank-separated list of Fortran
 compilers to search for, just as in @code{AC_PROG_F77}.
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index f20b029..2354e0a 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -285,7 +285,7 @@ AC_DEFUN([_AC_FC_DIALECT_YEAR],
         [m4_fatal([unknown Fortran dialect])])])
 
 
-# _AC_PROG_FC([DIALECT], [COMPILERS...])
+# _AC_PROG_FC([DIALECT], [COMPILERS...], [REJECTED_COMPILERS...])
 # --------------------------------------
 # DIALECT is a Fortran dialect, given by Fortran [YY]YY or simply [YY]YY,
 # and must be one of those supported by _AC_FC_DIALECT_YEAR
@@ -322,6 +322,11 @@ m4_define([_AC_F90_FC], [xlf90 f90 pgf90 pghpf epcf90])
 m4_define([_AC_F77_FC], [g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77])
 AC_DEFUN([_AC_PROG_FC],
 [_AC_FORTRAN_ASSERT()dnl
+m4_foreach_w([_AC_FC_rejcomp], [$3], [
+m4_define([_AC_F95_FC],m4_bpatsubst(m4_defn([_AC_F95_FC]),\<_AC_FC_rejcomp\>))
+m4_define([_AC_F90_FC],m4_bpatsubst(m4_defn([_AC_F90_FC]),\<_AC_FC_rejcomp\>))
+m4_define([_AC_F77_FC],m4_bpatsubst(m4_defn([_AC_F77_FC]),\<_AC_FC_rejcomp\>))
+])
 AC_CHECK_TOOLS([]_AC_FC[],
       m4_default([$2],
        m4_case(_AC_FC_DIALECT_YEAR([$1]),
@@ -351,7 +356,7 @@ _AC_PROG_FC_G
 ])# _AC_PROG_FC
 
 
-# AC_PROG_F77([COMPILERS...])
+# AC_PROG_F77([COMPILERS...], [REJECTED_COMPILERS...])
 # ---------------------------
 # COMPILERS is a space separated list of Fortran 77 compilers to search
 # for.  See also _AC_PROG_FC.
@@ -361,7 +366,7 @@ AC_ARG_VAR([F77],    [Fortran 77 compiler command])dnl
 AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl
 _AC_ARG_VAR_LDFLAGS()dnl
 _AC_ARG_VAR_LIBS()dnl
-_AC_PROG_FC([Fortran 77], [$1])
+_AC_PROG_FC([Fortran 77], [$1], [$2])
 if test $ac_compiler_gnu = yes; then
   G77=yes
 else
@@ -371,7 +376,7 @@ AC_LANG_POP(Fortran 77)dnl
 ])# AC_PROG_F77
 
 
-# AC_PROG_FC([COMPILERS...], [DIALECT])
+# AC_PROG_FC([COMPILERS...], [DIALECT], [REJECTED_COMPILERS...])
 # -------------------------------------
 # COMPILERS is a space separated list of Fortran 77 compilers to search
 # for, and [DIALECT] is an optional dialect.  See also _AC_PROG_FC.
@@ -381,7 +386,7 @@ AC_ARG_VAR([FC],    [Fortran compiler command])dnl
 AC_ARG_VAR([FCFLAGS], [Fortran compiler flags])dnl
 _AC_ARG_VAR_LDFLAGS()dnl
 _AC_ARG_VAR_LIBS()dnl
-_AC_PROG_FC([$2], [$1])
+_AC_PROG_FC([$2], [$1], [$3])
 if test $ac_compiler_gnu = yes; then
   GFC=yes
 else
-- 
1.8.2.3

Reply via email to