| 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 ) { } |
---|
| 121 | EOF |
---|
| 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) { } |
---|
| 138 | EOF |
---|
| 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) {} |
---|
| 154 | EOF |
---|
| 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) {} |
---|
| 170 | EOF |
---|
| 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) {} |
---|
| 186 | EOF |
---|
| 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) {} |
---|
| 202 | EOF |
---|
| 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) {} |
---|
| 218 | EOF |
---|
| 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 |
---|
| 1591 | dnl |
---|
| 1592 | dnl |
---|
| 1593 | dnl |
---|
| 1594 | dnl |
---|
| 1595 | AC_DEFUN(PAC_PROG_F77_OBJ_LINKS_WITH_C,[ |
---|
| 1596 | AC_MSG_CHECKING([whether Fortran 77 and C objects are compatible]) |
---|
| 1597 | dnl |
---|
| 1598 | rm -rf conftestc.dSYM |
---|
| 1599 | rm -f conftestc* |
---|
| 1600 | dnl construct with a C function with all possible F77 name mangling schemes. |
---|
| 1601 | cat <<_EOF > conftestc.c |
---|
| 1602 | /* lower */ |
---|
| 1603 | void c_subpgm( int *rc ); |
---|
| 1604 | void c_subpgm( int *rc ) { *rc = 1; } |
---|
| 1605 | |
---|
| 1606 | /* lower underscore */ |
---|
| 1607 | void c_subpgm_( int *rc ); |
---|
| 1608 | void c_subpgm_( int *rc ) { *rc = 2; } |
---|
| 1609 | |
---|
| 1610 | /* upper */ |
---|
| 1611 | void C_SUBPGM( int *rc ); |
---|
| 1612 | void C_SUBPGM( int *rc ) { *rc = 3; } |
---|
| 1613 | |
---|
| 1614 | /* lower doubleunderscore */ |
---|
| 1615 | void c_subpgm__( int *rc ); |
---|
| 1616 | void c_subpgm__( int *rc ) { *rc = 4; } |
---|
| 1617 | |
---|
| 1618 | /* mixed */ |
---|
| 1619 | void C_subpgm( int *rc ); |
---|
| 1620 | void C_subpgm( int *rc ) { *rc = 5; } |
---|
| 1621 | |
---|
| 1622 | /* mixed underscore */ |
---|
| 1623 | void C_subpgm_( int *rc ); |
---|
| 1624 | void C_subpgm_( int *rc ) { *rc = 6; } |
---|
| 1625 | _EOF |
---|
| 1626 | dnl |
---|
| 1627 | dnl Compile the C function into object file. |
---|
| 1628 | dnl |
---|
| 1629 | pac_Ccompile='${CC-cc} -c $CFLAGS conftestc.c 1>&AC_FD_CC' |
---|
| 1630 | if AC_TRY_EVAL(pac_Ccompile) && test -s conftestc.${ac_objext} ; then |
---|
| 1631 | pac_c_working=yes |
---|
| 1632 | else |
---|
| 1633 | pac_c_working=no |
---|
| 1634 | echo "configure: failed C program was:" >&AC_FD_CC |
---|
| 1635 | cat conftestc.c >&AC_FD_CC |
---|
| 1636 | fi |
---|
| 1637 | dnl |
---|
| 1638 | rm -rf conftestf.dSYM |
---|
| 1639 | rm -f conftestf* |
---|
| 1640 | cat <<_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 |
---|
| 1648 | dnl - compile the fortran program into object file |
---|
| 1649 | pac_Fcompile='${F77-f77} -c $FFLAGS conftestf.f 1>&AC_FD_CC' |
---|
| 1650 | if AC_TRY_EVAL(pac_Fcompile) && test -s conftestf.${ac_objext} ; then |
---|
| 1651 | pac_f77_working=yes |
---|
| 1652 | else |
---|
| 1653 | pac_f77_working=no |
---|
| 1654 | echo "configure: failed F77 program was:" >&AC_FD_CC |
---|
| 1655 | cat conftestf.f >&AC_FD_CC |
---|
| 1656 | fi |
---|
| 1657 | dnl |
---|
| 1658 | if test "$pac_c_working" = "yes" -a "$pac_f77_working" = "yes" ; then |
---|
| 1659 | dnl 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 |
---|
| 1667 | dnl 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! **** |
---|
| 1682 | F77 Object File Type : ${fobjtype}. |
---|
| 1683 | C Object File Type : ${cobjtype}.]) |
---|
| 1684 | fi |
---|
| 1685 | fi |
---|
| 1686 | fi |
---|
| 1687 | fi |
---|
| 1688 | else |
---|
| 1689 | AC_MSG_RESULT([failed compilation]) |
---|
| 1690 | fi |
---|
| 1691 | ]) |
---|