autoconf
[Top][All Lists]
Advanced

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

Re: F77_DUMMY_MAIN (Was: Release 2.51 now?)


From: Akim Demaille
Subject: Re: F77_DUMMY_MAIN (Was: Release 2.51 now?)
Date: 17 Jul 2001 10:21:10 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Academic Rigor)

>>>>> "Steven" == Steven G Johnson <address@hidden> writes:

>> I don't know why it's needed in the definition of
>> AC_LANG_PROGRAM(C), but it appears to be the reason why it is
>> "used" so often.

Steven> Once F77_DUMMY_MAIN is called, autoconf has to assume that the
Steven> user may have included FLIBS in LIBS, in which case the dummy
Steven> main is needed in order for any link tests to work.

Steven> It was somewhat ugly to include it in program(C) in all cases,
Steven> I agree, even though it is #ifdef'ed out.  Is there a simple
Steven> way to include it only if/after F77_DUMMY_MAIN is called?

Sure, based on AC_PROVIDE_I

Steven> Would it work just to define an M4 macro with the dummy main
Steven> in F77_DUMMY_MAIN, which is then called from
Steven> AC_LANG_PROGRAM(C) and is empty if the former has not been
Steven> called yet?

I'm checking this in:

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * aclang.m4 (AC_LANG_PROGRAM(C)): Output F77_DUMMY_MAIN only when
        AC_F77_DUMMY_MAIN has been run.
        From Pavel Roskin and Steven G. Johnson.

Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.144
diff -u -u -r1.144 aclang.m4
--- aclang.m4 2001/07/06 01:03:18 1.144
+++ aclang.m4 2001/07/17 08:21:25
@@ -354,14 +354,18 @@
 
 # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
 # --------------------------------------
+# If AC_F77_DUMMY_MAIN was run, then any C/C++ program might be linked
+# against Fortran code, hence a dummy main might be needed.
 m4_define([AC_LANG_PROGRAM(C)],
 [$1
-#ifdef F77_DUMMY_MAIN
+m4_provide_ifelse([AC_F77_DUMMY_MAIN],
+[#ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
      extern "C"
 #  endif
    int F77_DUMMY_MAIN() { return 1; }
 #endif
+])dnl
 int
 main ()
 {


/tmp % cat configure.ac                                          nostromo 10:17
AC_INIT
sed 's/^/</' <<EOFOO
AC_LANG_PROGRAM(foo)
EOFOO
AC_F77_DUMMY_MAIN
sed 's/^/>/' <<EOFOO
AC_LANG_PROGRAM(foo)
EOFOO


/tmp % ace                                                       nostromo 10:17
/tmp % ./configure -q                                            nostromo 10:17
<#line 925 "configure"
<#include "confdefs.h"
<foo
<int
<main ()
<{
<
<  ;
<  return 0;
<}
>#line 2212 "configure"
>#include "confdefs.h"
>foo
>#ifdef F77_DUMMY_MAIN
>#  ifdef __cplusplus
>     extern "C"
>#  endif
>   int F77_DUMMY_MAIN() { return 1; }
>#endif
>int
>main ()
>{
>
>  ;
>  return 0;
>}



reply via email to

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