]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* aclang.m4 (AC_F77_NAME_MANGLING): Obsolete, becomes
authorAkim Demaille <akim@epita.fr>
Wed, 19 Jul 2000 09:56:18 +0000 (09:56 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 19 Jul 2000 09:56:18 +0000 (09:56 +0000)
_AC_F77_NAME_MANGLING.
(_AC_F77_NAME_MANGLING): Use independent checks for the
name mangling of symbols with and without underscores.
Use algorithm with for loops instead of recursive macro calls.
(AC_F77_WRAPPERS): Adapt to changes in _AC_F77_NAME_MANGLING.
* doc/autoconf.texi (Fortran 77 Compiler Characteristics):
Remove documentation of AC_F77_NAME_MANGLING.
Remove documentation of f77_case and f77_underscore.
Replace AC_F77_FUNC_WRAPPER with AC_F77_WRAPPERS.

ChangeLog
aclang.m4
doc/autoconf.texi
lib/autoconf/c.m4
lib/autoconf/fortran.m4
lib/autoconf/lang.m4

index e40ace0ece0f2e8f30f4f1a475b41cdc32e2898e..090972d378f17d43cab312baed7c4db18db0d5d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2000-07-19  Martin Wilck  <martin@tropos.de>
+
+       * aclang.m4 (AC_F77_NAME_MANGLING): Obsolete, becomes
+       _AC_F77_NAME_MANGLING.
+       (_AC_F77_NAME_MANGLING): Use independent checks for the
+       name mangling of symbols with and without underscores.
+       Use algorithm with for loops instead of recursive macro calls.
+       (AC_F77_WRAPPERS): Adapt to changes in _AC_F77_NAME_MANGLING.
+       * doc/autoconf.texi (Fortran 77 Compiler Characteristics):
+       Remove documentation of AC_F77_NAME_MANGLING.
+       Remove documentation of f77_case and f77_underscore.
+       Replace AC_F77_FUNC_WRAPPER with AC_F77_WRAPPERS.
+
 2000-07-19  Akim Demaille  <akim@epita.fr>
 
        * NEWS: Fresh air.
index 5d4819fd562a9741506561815f40aee2613a07a9..a09e43193992c101a909764482530e6553fccdd6 100644 (file)
--- a/aclang.m4
+++ b/aclang.m4
@@ -933,8 +933,7 @@ AC_DEFUN([AC_PROG_F77_C_O],
 AC_CACHE_CHECK([whether $F77 understand -c and -o together],
                [ac_cv_prog_f77_c_o],
 [cat >conftest.f <<EOF
-       program conftest
-       end
+AC_LANG_PROGRAM([])
 EOF
 # We do the `AC_TRY_EVAL' test twice because some compilers refuse to
 # overwrite an existing `.o' file with `-o', although they will create
@@ -945,8 +944,7 @@ if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
 else
   ac_cv_prog_f77_c_o=no
 fi
-rm -f conftest*
-])dnl
+rm -f conftest*])
 if test $ac_cv_prog_f77_c_o = yes; then
   AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1,
             [Define if your Fortran 77 compiler doesn't accept -c and -o together.])
@@ -1487,31 +1485,21 @@ AC_SUBST(FLIBS)
 ])# AC_F77_LIBRARY_LDFLAGS
 
 
-# AC_F77_NAME_MANGLING
+# _AC_F77_NAME_MANGLING
 # --------------------
 # Test for the name mangling scheme used by the Fortran 77 compiler.
-# Two variables are set by this macro:
-#
-#       f77_case: Set to either "upper" or "lower", depending on the
-#                 case of the name mangling.
-#
-#  f77_underscore: Set to either "no", "single" or "double", depending
-#                 on how underscores (i.e. "_") are appended to
-#                 identifiers, if at all.
 #
-#                 If no underscores are appended, then the value is
-#                 "no".
+# Sets ac_cv_f77_mangling. The value contains three fields, separated by commas:
 #
-#                 If a single underscore is appended, even with
-#                 identifiers which already contain an underscore
-#                 somewhere in their name, then the value is
-#                 "single".
+# lower case / upper case:
+#    case translation of the Fortan 77 symbols
+# underscore / no underscore:
+#    whether the compiler appends "_" to symbol names
+# extra underscore / no extra underscore:
+#    whether the compiler appends an extra "_" to symbol names already
+#    containing at least one underscore
 #
-#                 If a single underscore is appended *and* two
-#                 underscores are appended to identifiers which
-#                 already contain an underscore somewhere in their
-#                 name, then the value is "double".
-AC_DEFUN([AC_F77_NAME_MANGLING],
+AC_DEFUN([_AC_F77_NAME_MANGLING],
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_PROG_F77])dnl
 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
@@ -1532,32 +1520,51 @@ AC_COMPILE_IFELSE(
   ac_save_LIBS=$LIBS
   LIBS="cf77_test.${ac_objext} $FLIBS $LIBS"
 
-  f77_case=
-  f77_underscore=
-
-  AC_TRY_LINK_FUNC(foobar,
-    f77_case=lower
-    f77_underscore=no
-    ac_foo_bar=foo_bar_,
-    AC_TRY_LINK_FUNC(foobar_,
-      f77_case=lower
-      f77_underscore=single
-      ac_foo_bar=foo_bar__,
-      AC_TRY_LINK_FUNC(FOOBAR,
-        f77_case=upper
-        f77_underscore=no
-        ac_foo_bar=FOO_BAR_,
-        AC_TRY_LINK_FUNC(FOOBAR_,
-          f77_case=upper
-          f77_underscore=single
-          ac_foo_bar=FOO_BAR__))))
-
-  AC_TRY_LINK_FUNC(${ac_foo_bar}, f77_underscore=double)
-
-  if test -z "$f77_case" || test -z "$f77_underscore"; then
-    ac_cv_f77_mangling="unknown"
+  ac_success=no
+  for ac_foobar in foobar FOOBAR; do
+    for ac_underscore in "" "_"; do
+      ac_func="$ac_foobar$ac_underscore"
+      AC_TRY_LINK_FUNC($ac_func,
+         [ac_success=yes; break 2])
+    done
+  done
+
+  if test "$ac_success" = "yes"; then
+     case $ac_foobar in
+        foobar)
+           ac_case=lower
+           ac_foo_bar=foo_bar
+           ;;
+        FOOBAR)
+           ac_case=upper
+           ac_foo_bar=FOO_BAR
+           ;;
+     esac
+
+     ac_success_extra=no
+     for ac_extra in "" "_"; do
+        ac_func="$ac_foo_bar$ac_underscore$ac_extra"
+        AC_TRY_LINK_FUNC($ac_func,
+        [ac_success_extra=yes; break])
+     done
+
+     if test "$ac_success_extra" = "yes"; then
+       ac_cv_f77_mangling="$ac_case case"
+        if test -z "$ac_underscore"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, underscore"
+        fi
+        if test -z "$ac_extra"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no extra underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, extra underscore"
+        fi
+      else
+       ac_cv_f77_mangling="unknown"
+      fi
   else
-    ac_cv_f77_mangling="$f77_case case, $f77_underscore underscores"
+     ac_cv_f77_mangling="unknown"
   fi
 
   LIBS=$ac_save_LIBS
@@ -1565,10 +1572,10 @@ AC_COMPILE_IFELSE(
   rm -f cf77_test*])
 AC_LANG_POP()dnl
 ])
-f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'`
-f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
-])# AC_F77_NAME_MANGLING
+])# _AC_F77_NAME_MANGLING
 
+# The replacement is empty.
+AU_DEFUN([AC_F77_NAME_MANGLING], [])
 
 # AC_F77_WRAPPERS
 # ---------------
@@ -1577,29 +1584,35 @@ f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
 # underscores, respectively, so that they match the name mangling
 # scheme used by the Fortran 77 compiler.
 AC_DEFUN([AC_F77_WRAPPERS],
-[AC_REQUIRE([AC_F77_NAME_MANGLING])dnl
+[AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
 AH_TEMPLATE([F77_FUNC],
     [Define to a macro mangling the given C identifier (in lower and upper
      case), which must not contain underscores, for linking with Fortran.])dnl
 AH_TEMPLATE([F77_FUNC_],
     [As F77_FUNC, but for C identifiers containing underscores.])dnl
-case $f77_case,$f77_underscore in
-  lower,no)
+case $ac_cv_f77_mangling in
+  "lower case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name]) ;;
-  lower,single)
+  "lower case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [name])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
+  "lower case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
-  lower,double)
+  "lower case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## __]) ;;
-  upper,no)
+  "upper case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME]) ;;
-  upper,single)
+  "upper case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
+  "upper case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
-  upper,double)
+  "upper case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## __]) ;;
   *)
index 935d05629bbad415485f52912364c23478dbaeea..fd6dece32eb15f3bba4f6682ded14edcfc0cfe5a 100644 (file)
@@ -4162,40 +4162,8 @@ add these Fortran 77 libraries.  Hence, the macro
 libraries.
 @end defmac
 
-@defmac AC_F77_NAME_MANGLING
-@maindex F77_NAME_MANGLING
-Test for the name mangling scheme used by the Fortran 77 compiler.  This
-macro is used by @code{AC_F77_FUNC_WRAPPER} (@pxref{Fortran 77 Compiler
-Characteristics}, for more information).
-
-Two variables are set by this macro:
-
-@table @code
-@item f77_case
-Set to either @samp{upper} or @samp{lower}, depending on whether the
-Fortran 77 compiler translates the case of identifiers to either
-uppercase or lowercase.
-
-@item f77_underscore
-Set to either @samp{no}, @samp{single} or @samp{double}, depending on
-how the Fortran 77 compiler appends underscores (i.e. @code{_}) to
-identifiers, if at all.
-
-If no underscores are appended, then the value is @samp{no}.
-
-If a single underscore is appended, even with identifiers which already
-contain an underscore somewhere in their name, then the value is
-@samp{single}.
-
-If a single underscore is appended @emph{and} two underscores are
-appended to identifiers which already contain an underscore somewhere in
-their name, then the value is @samp{double}.
-
-@end table
-@end defmac
-
-@defmac AC_F77_FUNC_WRAPPER
-@maindex F77_FUNC_WRAPPER
+@defmac AC_F77_WRAPPERS
+@maindex F77_WRAPPERS
 @cvindex F77_FUNC
 @cvindex F77_FUNC_
 Defines C macros @code{F77_FUNC(name,NAME)} and
@@ -4209,7 +4177,7 @@ To call a Fortran 77 subroutine from C or to write a C function that is
 callable from Fortran 77, the C program must explicitly use identifiers
 in the format expected by the Fortran 77 compiler.  In order to do this,
 one simply wraps all C identifiers in one of the macros provided by
-@code{AC_F77_FUNC_WRAPPER}.  For example, suppose you have the following
+@code{AC_F77_WRAPPERS}.  For example, suppose you have the following
 Fortran 77 subroutine:
 
 @example
@@ -4257,9 +4225,6 @@ If the Fortran 77 identifier contains an underscore
 (e.g. @code{foo_bar}), you should use @code{F77_FUNC_} instead of
 @code{F77_FUNC} (with the same arguments).  This is because some Fortran
 77 compilers mangle names differently if they contain an underscore.
-The @code{AC_F77_FUNC_WRAPPER} macro uses the
-@code{AC_F77_NAME_MANGLING} macro to determine this automatically
-(@pxref{Fortran 77 Compiler Characteristics}, for more information).
 @end defmac
 
 @node System Services, UNIX Variants, Fortran 77 Compiler Characteristics, Existing Tests
index 5d4819fd562a9741506561815f40aee2613a07a9..a09e43193992c101a909764482530e6553fccdd6 100644 (file)
@@ -933,8 +933,7 @@ AC_DEFUN([AC_PROG_F77_C_O],
 AC_CACHE_CHECK([whether $F77 understand -c and -o together],
                [ac_cv_prog_f77_c_o],
 [cat >conftest.f <<EOF
-       program conftest
-       end
+AC_LANG_PROGRAM([])
 EOF
 # We do the `AC_TRY_EVAL' test twice because some compilers refuse to
 # overwrite an existing `.o' file with `-o', although they will create
@@ -945,8 +944,7 @@ if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
 else
   ac_cv_prog_f77_c_o=no
 fi
-rm -f conftest*
-])dnl
+rm -f conftest*])
 if test $ac_cv_prog_f77_c_o = yes; then
   AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1,
             [Define if your Fortran 77 compiler doesn't accept -c and -o together.])
@@ -1487,31 +1485,21 @@ AC_SUBST(FLIBS)
 ])# AC_F77_LIBRARY_LDFLAGS
 
 
-# AC_F77_NAME_MANGLING
+# _AC_F77_NAME_MANGLING
 # --------------------
 # Test for the name mangling scheme used by the Fortran 77 compiler.
-# Two variables are set by this macro:
-#
-#       f77_case: Set to either "upper" or "lower", depending on the
-#                 case of the name mangling.
-#
-#  f77_underscore: Set to either "no", "single" or "double", depending
-#                 on how underscores (i.e. "_") are appended to
-#                 identifiers, if at all.
 #
-#                 If no underscores are appended, then the value is
-#                 "no".
+# Sets ac_cv_f77_mangling. The value contains three fields, separated by commas:
 #
-#                 If a single underscore is appended, even with
-#                 identifiers which already contain an underscore
-#                 somewhere in their name, then the value is
-#                 "single".
+# lower case / upper case:
+#    case translation of the Fortan 77 symbols
+# underscore / no underscore:
+#    whether the compiler appends "_" to symbol names
+# extra underscore / no extra underscore:
+#    whether the compiler appends an extra "_" to symbol names already
+#    containing at least one underscore
 #
-#                 If a single underscore is appended *and* two
-#                 underscores are appended to identifiers which
-#                 already contain an underscore somewhere in their
-#                 name, then the value is "double".
-AC_DEFUN([AC_F77_NAME_MANGLING],
+AC_DEFUN([_AC_F77_NAME_MANGLING],
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_PROG_F77])dnl
 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
@@ -1532,32 +1520,51 @@ AC_COMPILE_IFELSE(
   ac_save_LIBS=$LIBS
   LIBS="cf77_test.${ac_objext} $FLIBS $LIBS"
 
-  f77_case=
-  f77_underscore=
-
-  AC_TRY_LINK_FUNC(foobar,
-    f77_case=lower
-    f77_underscore=no
-    ac_foo_bar=foo_bar_,
-    AC_TRY_LINK_FUNC(foobar_,
-      f77_case=lower
-      f77_underscore=single
-      ac_foo_bar=foo_bar__,
-      AC_TRY_LINK_FUNC(FOOBAR,
-        f77_case=upper
-        f77_underscore=no
-        ac_foo_bar=FOO_BAR_,
-        AC_TRY_LINK_FUNC(FOOBAR_,
-          f77_case=upper
-          f77_underscore=single
-          ac_foo_bar=FOO_BAR__))))
-
-  AC_TRY_LINK_FUNC(${ac_foo_bar}, f77_underscore=double)
-
-  if test -z "$f77_case" || test -z "$f77_underscore"; then
-    ac_cv_f77_mangling="unknown"
+  ac_success=no
+  for ac_foobar in foobar FOOBAR; do
+    for ac_underscore in "" "_"; do
+      ac_func="$ac_foobar$ac_underscore"
+      AC_TRY_LINK_FUNC($ac_func,
+         [ac_success=yes; break 2])
+    done
+  done
+
+  if test "$ac_success" = "yes"; then
+     case $ac_foobar in
+        foobar)
+           ac_case=lower
+           ac_foo_bar=foo_bar
+           ;;
+        FOOBAR)
+           ac_case=upper
+           ac_foo_bar=FOO_BAR
+           ;;
+     esac
+
+     ac_success_extra=no
+     for ac_extra in "" "_"; do
+        ac_func="$ac_foo_bar$ac_underscore$ac_extra"
+        AC_TRY_LINK_FUNC($ac_func,
+        [ac_success_extra=yes; break])
+     done
+
+     if test "$ac_success_extra" = "yes"; then
+       ac_cv_f77_mangling="$ac_case case"
+        if test -z "$ac_underscore"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, underscore"
+        fi
+        if test -z "$ac_extra"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no extra underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, extra underscore"
+        fi
+      else
+       ac_cv_f77_mangling="unknown"
+      fi
   else
-    ac_cv_f77_mangling="$f77_case case, $f77_underscore underscores"
+     ac_cv_f77_mangling="unknown"
   fi
 
   LIBS=$ac_save_LIBS
@@ -1565,10 +1572,10 @@ AC_COMPILE_IFELSE(
   rm -f cf77_test*])
 AC_LANG_POP()dnl
 ])
-f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'`
-f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
-])# AC_F77_NAME_MANGLING
+])# _AC_F77_NAME_MANGLING
 
+# The replacement is empty.
+AU_DEFUN([AC_F77_NAME_MANGLING], [])
 
 # AC_F77_WRAPPERS
 # ---------------
@@ -1577,29 +1584,35 @@ f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
 # underscores, respectively, so that they match the name mangling
 # scheme used by the Fortran 77 compiler.
 AC_DEFUN([AC_F77_WRAPPERS],
-[AC_REQUIRE([AC_F77_NAME_MANGLING])dnl
+[AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
 AH_TEMPLATE([F77_FUNC],
     [Define to a macro mangling the given C identifier (in lower and upper
      case), which must not contain underscores, for linking with Fortran.])dnl
 AH_TEMPLATE([F77_FUNC_],
     [As F77_FUNC, but for C identifiers containing underscores.])dnl
-case $f77_case,$f77_underscore in
-  lower,no)
+case $ac_cv_f77_mangling in
+  "lower case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name]) ;;
-  lower,single)
+  "lower case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [name])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
+  "lower case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
-  lower,double)
+  "lower case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## __]) ;;
-  upper,no)
+  "upper case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME]) ;;
-  upper,single)
+  "upper case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
+  "upper case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
-  upper,double)
+  "upper case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## __]) ;;
   *)
index 5d4819fd562a9741506561815f40aee2613a07a9..a09e43193992c101a909764482530e6553fccdd6 100644 (file)
@@ -933,8 +933,7 @@ AC_DEFUN([AC_PROG_F77_C_O],
 AC_CACHE_CHECK([whether $F77 understand -c and -o together],
                [ac_cv_prog_f77_c_o],
 [cat >conftest.f <<EOF
-       program conftest
-       end
+AC_LANG_PROGRAM([])
 EOF
 # We do the `AC_TRY_EVAL' test twice because some compilers refuse to
 # overwrite an existing `.o' file with `-o', although they will create
@@ -945,8 +944,7 @@ if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
 else
   ac_cv_prog_f77_c_o=no
 fi
-rm -f conftest*
-])dnl
+rm -f conftest*])
 if test $ac_cv_prog_f77_c_o = yes; then
   AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1,
             [Define if your Fortran 77 compiler doesn't accept -c and -o together.])
@@ -1487,31 +1485,21 @@ AC_SUBST(FLIBS)
 ])# AC_F77_LIBRARY_LDFLAGS
 
 
-# AC_F77_NAME_MANGLING
+# _AC_F77_NAME_MANGLING
 # --------------------
 # Test for the name mangling scheme used by the Fortran 77 compiler.
-# Two variables are set by this macro:
-#
-#       f77_case: Set to either "upper" or "lower", depending on the
-#                 case of the name mangling.
-#
-#  f77_underscore: Set to either "no", "single" or "double", depending
-#                 on how underscores (i.e. "_") are appended to
-#                 identifiers, if at all.
 #
-#                 If no underscores are appended, then the value is
-#                 "no".
+# Sets ac_cv_f77_mangling. The value contains three fields, separated by commas:
 #
-#                 If a single underscore is appended, even with
-#                 identifiers which already contain an underscore
-#                 somewhere in their name, then the value is
-#                 "single".
+# lower case / upper case:
+#    case translation of the Fortan 77 symbols
+# underscore / no underscore:
+#    whether the compiler appends "_" to symbol names
+# extra underscore / no extra underscore:
+#    whether the compiler appends an extra "_" to symbol names already
+#    containing at least one underscore
 #
-#                 If a single underscore is appended *and* two
-#                 underscores are appended to identifiers which
-#                 already contain an underscore somewhere in their
-#                 name, then the value is "double".
-AC_DEFUN([AC_F77_NAME_MANGLING],
+AC_DEFUN([_AC_F77_NAME_MANGLING],
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_PROG_F77])dnl
 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
@@ -1532,32 +1520,51 @@ AC_COMPILE_IFELSE(
   ac_save_LIBS=$LIBS
   LIBS="cf77_test.${ac_objext} $FLIBS $LIBS"
 
-  f77_case=
-  f77_underscore=
-
-  AC_TRY_LINK_FUNC(foobar,
-    f77_case=lower
-    f77_underscore=no
-    ac_foo_bar=foo_bar_,
-    AC_TRY_LINK_FUNC(foobar_,
-      f77_case=lower
-      f77_underscore=single
-      ac_foo_bar=foo_bar__,
-      AC_TRY_LINK_FUNC(FOOBAR,
-        f77_case=upper
-        f77_underscore=no
-        ac_foo_bar=FOO_BAR_,
-        AC_TRY_LINK_FUNC(FOOBAR_,
-          f77_case=upper
-          f77_underscore=single
-          ac_foo_bar=FOO_BAR__))))
-
-  AC_TRY_LINK_FUNC(${ac_foo_bar}, f77_underscore=double)
-
-  if test -z "$f77_case" || test -z "$f77_underscore"; then
-    ac_cv_f77_mangling="unknown"
+  ac_success=no
+  for ac_foobar in foobar FOOBAR; do
+    for ac_underscore in "" "_"; do
+      ac_func="$ac_foobar$ac_underscore"
+      AC_TRY_LINK_FUNC($ac_func,
+         [ac_success=yes; break 2])
+    done
+  done
+
+  if test "$ac_success" = "yes"; then
+     case $ac_foobar in
+        foobar)
+           ac_case=lower
+           ac_foo_bar=foo_bar
+           ;;
+        FOOBAR)
+           ac_case=upper
+           ac_foo_bar=FOO_BAR
+           ;;
+     esac
+
+     ac_success_extra=no
+     for ac_extra in "" "_"; do
+        ac_func="$ac_foo_bar$ac_underscore$ac_extra"
+        AC_TRY_LINK_FUNC($ac_func,
+        [ac_success_extra=yes; break])
+     done
+
+     if test "$ac_success_extra" = "yes"; then
+       ac_cv_f77_mangling="$ac_case case"
+        if test -z "$ac_underscore"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, underscore"
+        fi
+        if test -z "$ac_extra"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no extra underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, extra underscore"
+        fi
+      else
+       ac_cv_f77_mangling="unknown"
+      fi
   else
-    ac_cv_f77_mangling="$f77_case case, $f77_underscore underscores"
+     ac_cv_f77_mangling="unknown"
   fi
 
   LIBS=$ac_save_LIBS
@@ -1565,10 +1572,10 @@ AC_COMPILE_IFELSE(
   rm -f cf77_test*])
 AC_LANG_POP()dnl
 ])
-f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'`
-f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
-])# AC_F77_NAME_MANGLING
+])# _AC_F77_NAME_MANGLING
 
+# The replacement is empty.
+AU_DEFUN([AC_F77_NAME_MANGLING], [])
 
 # AC_F77_WRAPPERS
 # ---------------
@@ -1577,29 +1584,35 @@ f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
 # underscores, respectively, so that they match the name mangling
 # scheme used by the Fortran 77 compiler.
 AC_DEFUN([AC_F77_WRAPPERS],
-[AC_REQUIRE([AC_F77_NAME_MANGLING])dnl
+[AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
 AH_TEMPLATE([F77_FUNC],
     [Define to a macro mangling the given C identifier (in lower and upper
      case), which must not contain underscores, for linking with Fortran.])dnl
 AH_TEMPLATE([F77_FUNC_],
     [As F77_FUNC, but for C identifiers containing underscores.])dnl
-case $f77_case,$f77_underscore in
-  lower,no)
+case $ac_cv_f77_mangling in
+  "lower case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name]) ;;
-  lower,single)
+  "lower case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [name])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
+  "lower case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
-  lower,double)
+  "lower case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## __]) ;;
-  upper,no)
+  "upper case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME]) ;;
-  upper,single)
+  "upper case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
+  "upper case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
-  upper,double)
+  "upper case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## __]) ;;
   *)
index 5d4819fd562a9741506561815f40aee2613a07a9..a09e43193992c101a909764482530e6553fccdd6 100644 (file)
@@ -933,8 +933,7 @@ AC_DEFUN([AC_PROG_F77_C_O],
 AC_CACHE_CHECK([whether $F77 understand -c and -o together],
                [ac_cv_prog_f77_c_o],
 [cat >conftest.f <<EOF
-       program conftest
-       end
+AC_LANG_PROGRAM([])
 EOF
 # We do the `AC_TRY_EVAL' test twice because some compilers refuse to
 # overwrite an existing `.o' file with `-o', although they will create
@@ -945,8 +944,7 @@ if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
 else
   ac_cv_prog_f77_c_o=no
 fi
-rm -f conftest*
-])dnl
+rm -f conftest*])
 if test $ac_cv_prog_f77_c_o = yes; then
   AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1,
             [Define if your Fortran 77 compiler doesn't accept -c and -o together.])
@@ -1487,31 +1485,21 @@ AC_SUBST(FLIBS)
 ])# AC_F77_LIBRARY_LDFLAGS
 
 
-# AC_F77_NAME_MANGLING
+# _AC_F77_NAME_MANGLING
 # --------------------
 # Test for the name mangling scheme used by the Fortran 77 compiler.
-# Two variables are set by this macro:
-#
-#       f77_case: Set to either "upper" or "lower", depending on the
-#                 case of the name mangling.
-#
-#  f77_underscore: Set to either "no", "single" or "double", depending
-#                 on how underscores (i.e. "_") are appended to
-#                 identifiers, if at all.
 #
-#                 If no underscores are appended, then the value is
-#                 "no".
+# Sets ac_cv_f77_mangling. The value contains three fields, separated by commas:
 #
-#                 If a single underscore is appended, even with
-#                 identifiers which already contain an underscore
-#                 somewhere in their name, then the value is
-#                 "single".
+# lower case / upper case:
+#    case translation of the Fortan 77 symbols
+# underscore / no underscore:
+#    whether the compiler appends "_" to symbol names
+# extra underscore / no extra underscore:
+#    whether the compiler appends an extra "_" to symbol names already
+#    containing at least one underscore
 #
-#                 If a single underscore is appended *and* two
-#                 underscores are appended to identifiers which
-#                 already contain an underscore somewhere in their
-#                 name, then the value is "double".
-AC_DEFUN([AC_F77_NAME_MANGLING],
+AC_DEFUN([_AC_F77_NAME_MANGLING],
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_PROG_F77])dnl
 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
@@ -1532,32 +1520,51 @@ AC_COMPILE_IFELSE(
   ac_save_LIBS=$LIBS
   LIBS="cf77_test.${ac_objext} $FLIBS $LIBS"
 
-  f77_case=
-  f77_underscore=
-
-  AC_TRY_LINK_FUNC(foobar,
-    f77_case=lower
-    f77_underscore=no
-    ac_foo_bar=foo_bar_,
-    AC_TRY_LINK_FUNC(foobar_,
-      f77_case=lower
-      f77_underscore=single
-      ac_foo_bar=foo_bar__,
-      AC_TRY_LINK_FUNC(FOOBAR,
-        f77_case=upper
-        f77_underscore=no
-        ac_foo_bar=FOO_BAR_,
-        AC_TRY_LINK_FUNC(FOOBAR_,
-          f77_case=upper
-          f77_underscore=single
-          ac_foo_bar=FOO_BAR__))))
-
-  AC_TRY_LINK_FUNC(${ac_foo_bar}, f77_underscore=double)
-
-  if test -z "$f77_case" || test -z "$f77_underscore"; then
-    ac_cv_f77_mangling="unknown"
+  ac_success=no
+  for ac_foobar in foobar FOOBAR; do
+    for ac_underscore in "" "_"; do
+      ac_func="$ac_foobar$ac_underscore"
+      AC_TRY_LINK_FUNC($ac_func,
+         [ac_success=yes; break 2])
+    done
+  done
+
+  if test "$ac_success" = "yes"; then
+     case $ac_foobar in
+        foobar)
+           ac_case=lower
+           ac_foo_bar=foo_bar
+           ;;
+        FOOBAR)
+           ac_case=upper
+           ac_foo_bar=FOO_BAR
+           ;;
+     esac
+
+     ac_success_extra=no
+     for ac_extra in "" "_"; do
+        ac_func="$ac_foo_bar$ac_underscore$ac_extra"
+        AC_TRY_LINK_FUNC($ac_func,
+        [ac_success_extra=yes; break])
+     done
+
+     if test "$ac_success_extra" = "yes"; then
+       ac_cv_f77_mangling="$ac_case case"
+        if test -z "$ac_underscore"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, underscore"
+        fi
+        if test -z "$ac_extra"; then
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, no extra underscore"
+       else
+           ac_cv_f77_mangling="$ac_cv_f77_mangling, extra underscore"
+        fi
+      else
+       ac_cv_f77_mangling="unknown"
+      fi
   else
-    ac_cv_f77_mangling="$f77_case case, $f77_underscore underscores"
+     ac_cv_f77_mangling="unknown"
   fi
 
   LIBS=$ac_save_LIBS
@@ -1565,10 +1572,10 @@ AC_COMPILE_IFELSE(
   rm -f cf77_test*])
 AC_LANG_POP()dnl
 ])
-f77_case=`echo "$ac_cv_f77_mangling" | sed 's/ case.*$//'`
-f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
-])# AC_F77_NAME_MANGLING
+])# _AC_F77_NAME_MANGLING
 
+# The replacement is empty.
+AU_DEFUN([AC_F77_NAME_MANGLING], [])
 
 # AC_F77_WRAPPERS
 # ---------------
@@ -1577,29 +1584,35 @@ f77_underscore=`echo "$ac_cv_f77_mangling" | sed 's/^.*, \(.*\) .*$/\1/'`
 # underscores, respectively, so that they match the name mangling
 # scheme used by the Fortran 77 compiler.
 AC_DEFUN([AC_F77_WRAPPERS],
-[AC_REQUIRE([AC_F77_NAME_MANGLING])dnl
+[AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
 AH_TEMPLATE([F77_FUNC],
     [Define to a macro mangling the given C identifier (in lower and upper
      case), which must not contain underscores, for linking with Fortran.])dnl
 AH_TEMPLATE([F77_FUNC_],
     [As F77_FUNC, but for C identifiers containing underscores.])dnl
-case $f77_case,$f77_underscore in
-  lower,no)
+case $ac_cv_f77_mangling in
+  "lower case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name]) ;;
-  lower,single)
+  "lower case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [name])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
+  "lower case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
-  lower,double)
+  "lower case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [name ## __]) ;;
-  upper,no)
+  "upper case, no underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME]) ;;
-  upper,single)
+  "upper case, no underscore, extra underscore")
+          AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])
+          AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
+  "upper case, underscore, no extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
-  upper,double)
+  "upper case, underscore, extra underscore")
           AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])
           AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## __]) ;;
   *)