Changeset 3540 for mpich2

Show
Ignore:
Timestamp:
11/14/08 02:48:45 (3 months ago)
Author:
chan
Message:

sync F77 m4 macros with mpich2's

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mpich2/trunk/src/mpe2/aclocal_f77.m4

    r575 r3540  
    3333dnl and arguments are pushed onto the stack from right to left) 
    3434dnl 
     35dnl One additional problem is that some Fortran implementations include  
     36dnl references to the runtime (like pgf90_compiled for the pgf90 compiler 
     37dnl used as the "Fortran 77" compiler).  This is not yet solved. 
     38dnl 
    3539dnl D*/ 
    3640dnl 
     
    4852   # where a Fortran compiler option is used to force a particular 
    4953   # external name format (rs6000 xlf, for example). 
     54   # This is needed for Mac OSX 10.5 
     55   rm -rf conftest.dSYM 
    5056   rm -f conftest* 
    5157   cat > conftest.f <<EOF 
     
    7076   dnl FLIBS comes from AC_F77_LIBRARY_LDFLAGS 
    7177   LIBS="fconftestf.o $FLIBS $LIBS" 
    72    AC_TRY_LINK(,my_name();,pac_cv_prog_f77_name_mangle="lower") 
     78   AC_TRY_LINK([extern void my_name(int);],my_name(0);,pac_cv_prog_f77_name_mangle="lower") 
    7379   if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
    74      AC_TRY_LINK(,my_name_();,pac_cv_prog_f77_name_mangle="lower underscore") 
     80     AC_TRY_LINK([extern void my_name_(int);],my_name_(0);,pac_cv_prog_f77_name_mangle="lower underscore") 
    7581   fi 
    7682   if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
    77      AC_TRY_LINK(void __stdcall MY_NAME(int);,MY_NAME(0);,pac_cv_prog_f77_name_mangle="upper stdcall") 
     83     AC_TRY_LINK([void __stdcall MY_NAME(int);],MY_NAME(0);,pac_cv_prog_f77_name_mangle="upper stdcall") 
    7884   fi 
    7985   if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
    80      AC_TRY_LINK(,MY_NAME();,pac_cv_prog_f77_name_mangle="upper") 
     86     AC_TRY_LINK([extern void MY_NAME(int);],MY_NAME(0);,pac_cv_prog_f77_name_mangle="upper") 
    8187   fi 
    8288   if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
    83      AC_TRY_LINK(,my_name__();, 
     89     AC_TRY_LINK([extern void my_name__(int);],my_name__(0);, 
    8490       pac_cv_prog_f77_name_mangle="lower doubleunderscore") 
    8591   fi 
    8692   if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
    87      AC_TRY_LINK(,MY_name();,pac_cv_prog_f77_name_mangle="mixed") 
     93     AC_TRY_LINK([extern void MY_name(int);],MY_name(0);,pac_cv_prog_f77_name_mangle="mixed") 
    8894   fi 
    8995   if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
    90      AC_TRY_LINK(,MY_name_();,pac_cv_prog_f77_name_mangle="mixed underscore") 
     96     AC_TRY_LINK([extern void MY_name_(int);],MY_name_(0);,pac_cv_prog_f77_name_mangle="mixed underscore") 
    9197   fi 
    9298   LIBS="$save_LIBS" 
    9399   AC_LANG_RESTORE 
     100   # If we got to this point, it may be that the programs have to be 
     101   # linked with the Fortran, not the C, compiler.  Try reversing 
     102   # the language used for the test 
     103   dnl Note that the definition of AC_TRY_LINK and AC_LANG_PROGRAM 
     104   dnl is broken in autoconf and will generate spurious warning messages 
     105   dnl To fix this, we use  
     106   dnl AC _LINK_IFELSE([AC _LANG_PROGRAM(,[[body]])],action-if-true) 
     107   dnl instead of AC _TRY_LINK(,body,action-if-true) 
     108   if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
     109       AC_LANG_SAVE 
     110       AC_LANG_FORTRAN77 
     111       save_LIBS="$LIBS" 
     112       LIBS="conftestc.o $LIBS" 
     113       if test "X$ac_ccompile" = "X" ; then 
     114           ac_ccompile='${CC-cc} -c $CFLAGS conftest.c 1>&AC_FD_CC' 
     115       fi 
     116       # This is needed for Mac OSX 10.5 
     117       rm -rf conftest.dSYM 
     118       rm -f conftest* 
     119       cat > conftest.c <<EOF 
     120       void my_name( int a ) { } 
     121EOF 
     122       if AC_TRY_EVAL(ac_ccompile) && test -s conftest.o ; then 
     123            mv conftest.o conftestc.o 
     124       else  
     125            echo "configure: failed program was:" >&AC_FD_CC 
     126            cat conftest.c >&AC_FD_CC 
     127       fi 
     128 
     129       AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[        call my_name(0)]])], 
     130           pac_cv_prog_f77_name_mangle="lower") 
     131 
     132       if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
     133           # This is needed for Mac OSX 10.5 
     134           rm -rf conftest.dSYM 
     135           rm -f conftest* 
     136           cat > conftest.c <<EOF 
     137 void my_name_(int a) { } 
     138EOF 
     139           if AC_TRY_EVAL(ac_ccompile) && test -s conftest.o ; then 
     140                mv conftest.o conftestc.o 
     141           else  
     142                echo "configure: failed program was:" >&AC_FD_CC 
     143                cat conftest.c >&AC_FD_CC 
     144           fi 
     145           AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[        call my_name(0)]])], 
     146                 pac_cv_prog_f77_name_mangle="lower underscore") 
     147       fi 
     148       if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
     149          # This is needed for Mac OSX 10.5 
     150          rm -rf conftest.dSYM 
     151          rm -f conftest* 
     152          cat >conftest.c <<EOF 
     153          void __stdcall MY_NAME(int a) {} 
     154EOF 
     155           if AC_TRY_EVAL(ac_ccompile) && test -s conftest.o ; then 
     156                mv conftest.o conftestc.o 
     157           else  
     158                echo "configure: failed program was:" >&AC_FD_CC 
     159                cat conftest.c >&AC_FD_CC 
     160           fi 
     161           AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[        call my_name(0)]])], 
     162                 pac_cv_prog_f77_name_mangle="upper stdcall") 
     163       fi 
     164       if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
     165          # This is needed for Mac OSX 10.5 
     166          rm -rf conftest.dSYM 
     167          rm -f conftest* 
     168          cat >conftest.c <<EOF 
     169          void MY_NAME(int a) {} 
     170EOF 
     171           if AC_TRY_EVAL(ac_ccompile) && test -s conftest.o ; then 
     172                mv conftest.o conftestc.o 
     173           else  
     174                echo "configure: failed program was:" >&AC_FD_CC 
     175                cat conftest.c >&AC_FD_CC 
     176           fi 
     177           AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[        call MY_NAME(0)]])], 
     178                pac_cv_prog_f77_name_mangle="upper") 
     179       fi 
     180       if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
     181          # This is needed for Mac OSX 10.5 
     182          rm -rf conftest.dSYM 
     183          rm -f conftest* 
     184          cat >conftest.c <<EOF 
     185          void my_name__(int a) {} 
     186EOF 
     187           if AC_TRY_EVAL(ac_ccompile) && test -s conftest.o ; then 
     188                mv conftest.o conftestc.o 
     189           else  
     190                echo "configure: failed program was:" >&AC_FD_CC 
     191                cat conftest.c >&AC_FD_CC 
     192           fi 
     193           AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[        call my_name(0)]])], 
     194               pac_cv_prog_f77_name_mangle="lower doubleunderscore") 
     195       fi 
     196       if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
     197          # This is needed for Mac OSX 10.5 
     198          rm -rf conftest.dSYM 
     199          rm -f conftest* 
     200          cat >conftest.c <<EOF 
     201          void MY_name(int a) {} 
     202EOF 
     203           if AC_TRY_EVAL(ac_ccompile) && test -s conftest.o ; then 
     204                mv conftest.o conftestc.o 
     205           else  
     206                echo "configure: failed program was:" >&AC_FD_CC 
     207                cat conftest.c >&AC_FD_CC 
     208           fi 
     209           AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[        call MY_name(0)]])], 
     210                pac_cv_prog_f77_name_mangle="mixed") 
     211       fi 
     212       if test  "X$pac_cv_prog_f77_name_mangle" = "X" ; then 
     213          # This is needed for Mac OSX 10.5 
     214          rm -rf conftest.dSYM 
     215          rm -f conftest* 
     216          cat >conftest.c <<EOF 
     217          void MY_name_(int a) {} 
     218EOF 
     219           if AC_TRY_EVAL(ac_ccompile) && test -s conftest.o ; then 
     220                mv conftest.o conftestc.o 
     221           else  
     222                echo "configure: failed program was:" >&AC_FD_CC 
     223                cat conftest.c >&AC_FD_CC 
     224           fi 
     225           AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[        call MY_name(0)]])], 
     226                   pac_cv_prog_f77_name_mangle="mixed underscore") 
     227       fi 
     228       LIBS="$save_LIBS" 
     229       AC_LANG_RESTORE 
     230   fi 
     231   # This is needed for Mac OSX 10.5 
     232   rm -rf conftest.dSYM 
    94233   rm -f fconftest* 
    95234]) 
     
    171310AC_CACHE_CHECK([for size of Fortran type $1],PAC_CV_NAME,[ 
    172311AC_REQUIRE([PAC_PROG_F77_NAME_MANGLE]) 
     312# This is needed for Mac OSX 10.5 
     313rm -rf conftest.dSYM 
    173314rm -f conftest* 
    174315cat <<EOF > conftest.f 
     
    250391,eval PAC_CV_NAME=$2) 
    251392else 
     393    # This is needed for Mac OSX 10.5 
     394    rm -rf conftest.dSYM 
    252395    rm -f conftest* 
    253396    cat <<EOF > conftestc.c 
     
    310453            eval PAC_CV_NAME=0 
    311454        fi 
     455        # This is needed for Mac OSX 10.5 
     456        rm -rf conftest.dSYM 
    312457        rm -f conftest* 
    313458    else 
     
    437582fi 
    438583# Restore FFLAGS before 2nd/3rd argument commands are executed, 
    439 # # as 2nd/3rd argument command could be modifying FFLAGS. 
     584# as 2nd/3rd argument command could be modifying FFLAGS. 
    440585FFLAGS="$save_FFLAGS" 
    441586if test "$ac_result" = "yes" ; then 
     
    446591     $3 
    447592fi 
     593# This is needed for Mac OSX 10.5 
     594rm -rf conftest.dSYM 
    448595rm -f conftest* 
    449596]) 
     
    561708    # Make sure that IFS includes a space, or the tests that run programs 
    562709    # may fail 
    563     IFS="  
     710    IFS=" "" 
    564711" 
    565712    save_trial_LIBS="$trial_LIBS" 
     
    628775    # Discard options that are not available: 
    629776    # (IFS already saved above) 
    630     IFS="  
     777    IFS=" "" 
    631778" 
    632779    save_trial_FLAGS="$trial_FLAGS" 
     
    766913    # over the possibilities of options and libraries 
    767914        save_IFS="$IFS" 
    768         IFS="  
     915        IFS=" "" 
    769916" 
    770917        for libs in $trial_LIBS ; do 
     
    787934                    fi 
    788935                fi 
    789                 IFS="  
     936                IFS=" "" 
    790937" 
    791938                if test "$found_answer" = "yes" ; then 
     
    8851032        cat conftest1.f >&AC_FD_CC 
    8861033    fi 
     1034    # This is needed for Mac OSX 10.5 
     1035    rm -rf conftest.dSYM 
    8871036    rm -f conftest* 
    8881037]) 
     
    9321081    fi 
    9331082done 
     1083# This is needed for Mac OSX 10.5 
     1084rm -rf conftest.dSYM 
    9341085rm -f conftest* 
    9351086rm -f $checkdir/conftestf.h 
     
    9631114EOF 
    9641115if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then 
     1116  # This is needed for Mac OSX 10.5 
     1117  rm -rf conftest.dSYM 
    9651118  rm -rf conftest* 
    9661119  pac_cv_prog_f77_allows_unused_externals="yes" 
     
    9681121  echo "configure: failed program was:" >&AC_FD_CC 
    9691122  cat conftest.$ac_ext >&AC_FD_CC 
     1123  # This is needed for Mac OSX 10.5 
     1124  rm -rf conftest.dSYM 
    9701125  rm -rf conftest* 
    9711126  pac_cv_prog_f77_allows_unused_externals="no" 
    9721127  $4 
    9731128fi 
     1129# This is needed for Mac OSX 10.5 
     1130rm -rf conftest.dSYM 
    9741131rm -f conftest* 
    9751132# 
     
    10161173dnl  
    10171174AC_DEFUN(PAC_PROG_F77_RUN_PROC_FROM_C,[ 
     1175# This is needed for Mac OSX 10.5 
     1176rm -rf conftest.dSYM 
    10181177rm -f conftest* 
    10191178cat <<EOF > conftest.f 
     
    10441203    cat conftest.f >&AC_FD_CC 
    10451204fi 
     1205# This is needed for Mac OSX 10.5 
     1206rm -rf conftest.dSYM 
    10461207rm -f conftest* 
    10471208]) 
     
    10651226AC_MSG_CHECKING([for which Fortran libraries are needed to link C with Fortran]) 
    10661227F77_IN_C_LIBS="$FLIBS" 
     1228# This is needed for Mac OSX 10.5 
     1229rm -rf conftest.dSYM 
    10671230rm -f conftest* 
    10681231cat <<EOF > conftest.f 
     
    10871250#define ftest_ ftest 
    10881251#endif 
     1252extern void ftest_(void); 
    10891253ftest_(); 
    10901254], [link_worked=yes], [link_worked=no] ) 
     
    11001264#define ftest_ ftest 
    11011265#endif 
     1266extern void ftest_(void); 
    11021267ftest_(); 
    11031268], [link_worked=yes], [link_worked=no] ) 
     
    11191284#define ftest_ ftest 
    11201285#endif 
     1286extern void ftest_(void); 
    11211287ftest_(); 
    11221288], [link_worked=yes], [link_worked=no] ) 
     
    11371303    cat conftest.f >&AC_FD_CC 
    11381304fi 
     1305# This is needed for Mac OSX 10.5 
     1306rm -rf conftest.dSYM 
    11391307rm -f conftest* mconftest* 
    11401308if test -z "$F77_IN_C_LIBS" ; then 
     
    11501318dnl 
    11511319AC_DEFUN([PAC_PROG_F77_LINKER_WITH_C],[ 
     1320AC_LANG_SAVE 
     1321AC_LANG_C 
    11521322AC_TRY_COMPILE(, 
    11531323long long a;,AC_DEFINE(HAVE_LONG_LONG,1,[Define if long long allowed])) 
     
    11641334#endif 
    11651335EOF 
    1166 AC_LANG_SAVE 
    1167 AC_LANG_C 
    11681336if AC_TRY_EVAL(ac_compile); then 
    11691337    mv conftest.o conftest1.o 
     
    13011469        end 
    13021470EOF 
     1471# This is needed for Mac OSX 10.5 
     1472rm -rf conftest.dSYM 
    13031473rm conftest* 
    13041474]) 
     
    13241494    AC_CACHE_CHECK([what libraries are needed to link Fortran programs with C routines that use stdio],pac_cv_prog_f77_and_c_stdio_libs,[ 
    13251495    pac_cv_prog_f77_and_c_stdio_libs=unknown 
     1496    # This is needed for Mac OSX 10.5 
     1497    rm -rf conftest.dSYM 
    13261498    rm -f conftest* 
    13271499    cat >conftest.f <<EOF 
     
    13591531    fi 
    13601532 
     1533    # This is needed for Mac OSX 10.5 
     1534    rm -rf conftest.dSYM 
    13611535    rm -f conftest* 
    13621536]) 
     
    14101584fi 
    14111585# 
     1586# This is needed for Mac OSX 10.5 
     1587rm -rf conftest.dSYM 
    14121588rm -f conftest* 
    14131589AC_LANG_RESTORE 
    14141590]) 
     1591dnl 
     1592dnl 
     1593dnl 
     1594dnl 
     1595AC_DEFUN(PAC_PROG_F77_OBJ_LINKS_WITH_C,[ 
     1596AC_MSG_CHECKING([whether Fortran 77 and C objects are compatible]) 
     1597dnl 
     1598rm -rf conftestc.dSYM 
     1599rm -f conftestc* 
     1600dnl construct with a C function with all possible F77 name mangling schemes. 
     1601cat <<_EOF > conftestc.c 
     1602/* lower */ 
     1603void c_subpgm( int *rc ); 
     1604void c_subpgm( int *rc ) { *rc = 1; } 
     1605 
     1606/* lower underscore */ 
     1607void c_subpgm_( int *rc ); 
     1608void c_subpgm_( int *rc ) { *rc = 2; } 
     1609 
     1610/* upper */ 
     1611void C_SUBPGM( int *rc ); 
     1612void C_SUBPGM( int *rc ) { *rc = 3; } 
     1613 
     1614/* lower doubleunderscore */ 
     1615void c_subpgm__( int *rc ); 
     1616void c_subpgm__( int *rc ) { *rc = 4; } 
     1617 
     1618/* mixed */ 
     1619void C_subpgm( int *rc ); 
     1620void C_subpgm( int *rc ) { *rc = 5; } 
     1621 
     1622/* mixed underscore */ 
     1623void C_subpgm_( int *rc ); 
     1624void C_subpgm_( int *rc ) { *rc = 6; } 
     1625_EOF 
     1626dnl 
     1627dnl Compile the C function into object file. 
     1628dnl 
     1629pac_Ccompile='${CC-cc} -c $CFLAGS conftestc.c 1>&AC_FD_CC' 
     1630if AC_TRY_EVAL(pac_Ccompile) && test -s conftestc.${ac_objext} ; then 
     1631    pac_c_working=yes 
     1632else 
     1633    pac_c_working=no 
     1634    echo "configure: failed C program was:" >&AC_FD_CC 
     1635    cat conftestc.c >&AC_FD_CC 
     1636fi 
     1637dnl 
     1638rm -rf conftestf.dSYM 
     1639rm -f conftestf* 
     1640cat <<_EOF > conftestf.f 
     1641      program test 
     1642      integer rc 
     1643      rc = -1 
     1644      call c_subpgm( rc ) 
     1645      write(6,*) "rc=", rc 
     1646      end 
     1647_EOF 
     1648dnl - compile the fortran program into object file 
     1649pac_Fcompile='${F77-f77} -c $FFLAGS conftestf.f 1>&AC_FD_CC' 
     1650if AC_TRY_EVAL(pac_Fcompile) && test -s conftestf.${ac_objext} ; then 
     1651    pac_f77_working=yes 
     1652else 
     1653    pac_f77_working=no 
     1654    echo "configure: failed F77 program was:" >&AC_FD_CC 
     1655    cat conftestf.f >&AC_FD_CC 
     1656fi 
     1657dnl 
     1658if test "$pac_c_working" = "yes" -a "$pac_f77_working" = "yes" ; then 
     1659dnl Try linking with F77 compiler 
     1660    rm -f conftest${ac_exeext} 
     1661    pac_link='$F77 $FFLAGS -o conftest${ac_exeext} conftestf.${ac_objext} conftestc.${ac_objext} $LDFLAGS >&AC_FD_CC' 
     1662    if AC_TRY_EVAL(pac_link) && test -s conftest${ac_exeext} ; then 
     1663        AC_MSG_RESULT(yes) 
     1664        rm -fr conftestf.dSYM conftestc.dSYM conftest.dSYM 
     1665        rm -f conftest* 
     1666    else 
     1667dnl     Try linking with C compiler 
     1668        rm -f conftest${ac_exeext} 
     1669        pac_link='$CC $CFLAGS -o conftest${ac_exeext} conftestf.${ac_objext} conftestc.${ac_objext} $LDFLAGS $FLIBS >&AC_FD_CC' 
     1670        if AC_TRY_EVAL(pac_link) && test -s conftest${ac_exeext} ; then 
     1671            AC_MSG_RESULT(yes) 
     1672            rm -fr conftestf.dSYM conftestc.dSYM conftest.dSYM 
     1673            rm -f conftest* 
     1674        else 
     1675            AC_MSG_RESULT(no) 
     1676            AC_CHECK_PROG(FILE, file, file, []) 
     1677            if test "X$FILE" != "X" ; then 
     1678                fobjtype="`${FILE} conftestf.${ac_objext} | sed -e \"s|conftestf\.${ac_objext}||g\"`" 
     1679                cobjtype="`${FILE} conftestc.${ac_objext} | sed -e \"s|conftestc\.${ac_objext}||g\"`" 
     1680                if test "$fobjtype" != "$cobjtype" ; then 
     1681                    AC_MSG_WARN([****  Incompatible Fortran and C Object File Types!  **** 
     1682F77 Object File Type : ${fobjtype}. 
     1683 C  Object File Type : ${cobjtype}.]) 
     1684                fi 
     1685            fi 
     1686        fi 
     1687    fi 
     1688else 
     1689    AC_MSG_RESULT([failed compilation]) 
     1690fi 
     1691])