autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interface of AC_F77_DUMMY_MAIN


From: Akim Demaille
Subject: Re: Interface of AC_F77_DUMMY_MAIN
Date: 17 Jul 2001 13:48:02 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Academic Rigor)

>>>>> "Akim" == Akim Demaille <address@hidden> writes:

Steven> Suggestions?

Akim> I still propose what I suggested above: two actions, and a means
Akim> for the user to read the name of the dummy main, empty standing
Akim> for not needed.

Here is what I mean.  As soon as we agree on this, 2.51 will be
released.  I hope people have been testing 2.50c hard...

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * aclang.m4 (AC_F77_DUMMY_MAIN): Let the interface be more
        Autoconfy: $1 = action-if-found, $2 = action-if-not-found.

Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.145
diff -u -u -r1.145 aclang.m4
--- aclang.m4 2001/07/17 08:23:42 1.145
+++ aclang.m4 2001/07/17 11:41:45
@@ -1925,40 +1925,42 @@
 ])# AC_F77_LIBRARY_LDFLAGS
 
 
-# AC_F77_DUMMY_MAIN([ACTION-IF-FAIL], [ACTION-IF-NONE], [ACTION-IF-FOUND])
-# ------------------------------------------------------------------------
+# AC_F77_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -----------------------------------------------------------
+#
 # Detect name of dummy main routine required by the Fortran libraries,
 # (if any) and define F77_DUMMY_MAIN to this name (which should be
 # used for a dummy declaration, if it is defined).  On some systems,
 # linking a C program to the Fortran library does not work unless you
 # supply a dummy function called something like MAIN__.
 #
-# Execute ACTION-IF-FAIL if no way of successfully linking a C program
-# with the F77 libs is found; default to exiting with an error message.
-# Execute ACTION-IF-NONE if no dummy main is required for linking.
-# Execute ACTION-IF-FOUND if a dummy routine name is found (default to
-# defining F77_DUMMY_MAIN).
+# Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C
+# program with the F77 libs is found; default to exiting with an error
+# message.  Execute ACTION-IF-FOUND if a dummy routine name is needed
+# and found or if it is not needed (default to defining F77_DUMMY_MAIN
+# when needed).
 #
 # What is technically happening is that the Fortran libraries provide
-# their own main() function, which usually initializes Fortran I/O
-# and similar stuff, and then calls MAIN__, which is the entry point
-# of your program.  Usually, a C program will override this with its
-# own main() routine, but the linker sometimes complain if you don't
+# their own main() function, which usually initializes Fortran I/O and
+# similar stuff, and then calls MAIN__, which is the entry point of
+# your program.  Usually, a C program will override this with its own
+# main() routine, but the linker sometimes complain if you don't
 # provide a dummy (never-called) MAIN__ routine anyway.
 #
 # Of course, programs that want to allow Fortran subroutines to do
 # I/O, etcetera, should call their main routine MAIN__() (or whatever)
-# instead of main().   A separate autoconf test (AC_F77_MAIN) checks
-# for the routine to use in this case (since the semantics of the
-# test are slightly different).  To link to e.g. purely numerical
+# instead of main().  A separate autoconf test (AC_F77_MAIN) checks
+# for the routine to use in this case (since the semantics of the test
+# are slightly different).  To link to e.g. purely numerical
 # libraries, this is normally not necessary, however, and most C/C++
 # programs are reluctant to turn over so much control to Fortran.  =)
 #
 # The name variants we check for are (in order):
@@ -1968,7 +1970,9 @@
  LIBS="$LIBS $FLIBS"
 
  # First, try linking without a dummy main:
- AC_TRY_LINK([],[],ac_cv_f77_dummy_main=none,ac_cv_f77_dummy_main=unknown)
+ AC_TRY_LINK([], [],
+             ac_cv_f77_dummy_main=none,
+             ac_cv_f77_dummy_main=unknown)
 
  if test $ac_cv_f77_dummy_main = unknown; then
    for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
@@ -1980,16 +1984,16 @@
  LIBS=$ac_f77_dm_save_LIBS
  AC_LANG_POP(C)dnl
 ])
-if test $ac_cv_f77_dummy_main = unknown; then
-  m4_default([$1],[AC_MSG_ERROR([Linking to Fortran libraries from C fails.])])
-elif test $ac_cv_f77_dummy_main = none; then
-  m4_default([$2],[:])
-else
-  m4_default([$3],
-    [AC_DEFINE_UNQUOTED([F77_DUMMY_MAIN], $ac_cv_f77_dummy_main,
-       [Define to dummy `main' function (if any) required to link to
-        the Fortran 77 libraries.])])
-fi
+F77_DUMMY_MAIN=$ac_cv_f77_dummy_main
+AS_IF([test "$F77_DUMMY_MAIN" != unknown],
+      [m4_default([$1],
+[if test $F77_DUMMY_MAIN != none; then
+  AC_DEFINE_UNQUOTED([F77_DUMMY_MAIN], $F77_DUMMY_MAIN,
+                     [Define to dummy `main' function (if any) required to
+                      link to the Fortran 77 libraries.])
+fi])],
+      [m4_default([$2],
+                [AC_MSG_ERROR([Linking to Fortran libraries from C fails.])])])
 ])# AC_F77_DUMMY_MAIN
 
 
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.492
diff -u -u -r1.492 autoconf.texi
--- doc/autoconf.texi 2001/07/17 10:01:09 1.492
+++ doc/autoconf.texi 2001/07/17 11:41:49
@@ -4735,7 +4735,7 @@
 @end defmac
 
 
address@hidden AC_F77_DUMMY_MAIN (@ovar{action-if-fail}, @ovar{action-if-none}, 
@ovar{action-if-found})
address@hidden AC_F77_DUMMY_MAIN (@ovar{action-if-found}, 
@ovar{action-if-not-found})
 @maindex F77_DUMMY_MAIN
 @cvindex F77_DUMMY_MAIN
 With many compilers, the Fortran libraries detected by
@@ -4750,14 +4750,13 @@
 library initializations.  In this case, however, one may still need to
 provide a dummy @code{MAIN__} routine in order to prevent linking errors
 on some systems.  @code{AC_F77_DUMMY_MAIN} detects whether any such
-routine is @emph{required} for linking, and what its name is.
+routine is @emph{required} for linking, and what its name is; the shell
+variable @code{F77_DUMMY_MAIN} holds this name, @code{unknown} when no
+solution was found, and @code{none} when no such dummy main is needed.
 
-If it cannot figure out how to link successfully, @code{action-if-fail}
-is executed, with the default action being to exit with an error
-message.  @code{action-if-none} is executed if no dummy main is needed
-(default: no action).  @code{action-if-found} is executed if a dummy
-main is required; the default action is to define @code{F77_DUMMY_MAIN}
-to the name of this required routine (e.g. @code{MAIN__}).
+By default, @var{action-if-found} defines @code{F77_DUMMY_MAIN} to the
+name of this routine (e.g. @code{MAIN__}) @emph{if} it is required.
address@hidden defaults to exiting with an error.
 
 In order to link with Fortran routines, the user's C/C++ program should
 then include the following code to define the dummy main if it is



reply via email to

[Prev in Thread] Current Thread [Next in Thread]