Commit b1df2f6d authored by Andreas Marek's avatar Andreas Marek

Check whether an underscore is needed for linking

If a C program needs an underscore to link against a Fortran library
append it, otherwise not
parent 5fd793c2
......@@ -947,6 +947,43 @@ dnl __m128d h1 = _fjsp_neg_v2r8(q);
dnl return 0;
dnl }
AC_LANG_PUSH([C])
dnl check whether one can link against Fortran programs from C
AC_MSG_CHECKING(whether we need _ in C programs to link against a Fortran library)
AC_LINK_IFELSE([AC_LANG_SOURCE([
int main(int argc, char **argv) {
int m, n, k, lda, ldb, ldc;
double alpha, beta;
double *a, *b, *c;
dgemm_("N", "N", &m, &n, &k, &alpha, a, lda, b, &ldb, &beta, c, &ldc);
}
])],
[can_link_with_=yes],
[can_link_with_=no]
)
AC_MSG_RESULT([${can_link_with_}])
if test x"$can_link_with_" = x"yes"; then
AC_DEFINE([NEED_UNDERSCORE_TO_LINK_AGAINST_FORTRAN],[1],[need to append an underscore])
fi
AC_MSG_CHECKING(whether we do not need _ in C programs to link against a Fortran library)
AC_LINK_IFELSE([AC_LANG_SOURCE([
int main(int argc, char **argv) {
int m, n, k, lda, ldb, ldc;
double alpha, beta;
double *a, *b, *c;
dgemm("N", "N", &m, &n, &k, &alpha, a, lda, b, &ldb, &beta, c, &ldc);
}
])],
[can_link_without_=yes],
[can_link_without_=no]
)
AC_MSG_RESULT([${can_link_without_}])
if test x"$can_link_with_" = x"yes"; then
AC_DEFINE([NEED_NO_UNDERSCORE_TO_LINK_AGAINST_FORTRAN],[1],[need not to append an underscore])
fi
if test x"${need_vsx}" = x"yes"; then
AC_MSG_CHECKING(whether we can compile Altivec VSX with intrinsics in C)
......
......@@ -86,25 +86,40 @@
#ifdef WITH_MPI
#include <mpi.h>
#if 0
#ifndef Add_
#ifdef NEED_NO_UNDERSCORE_TO_LINK_AGAINST_FORTRAN
#define numroc_ numroc
#define dlacpy_ dlacpy
#define pdtran_ pdtran
#define dlacpy_ dlacpy
#define pdlacpy_ pdlacpy
#define slacpy_ slacpy
#define pstran_ pstran
#define pslacpy_ pslacpy
#define zlacpy_ zlacpy
#define pztranc_ pztranc
#define pzlacpy_ pzlacpy
#define clacpy_ clacpy
#define pdtran_ pdtran
#define pstran_ pstran
#define pztranc_ pztranc
#define pctranc_ pctranc
#define pdlacpy_ pdlacpy
#define pslacpy_ pslacpy
#define pzlacpy_ pzlacpy
#define pclacpy_ pclacpy
#endif /* Add_ */
#endif
#ifdef NEED_UNDERSCORE_TO_LINK_AGAINST_FORTRAN
#define numroc_ numroc_
#define dlacpy_ dlacpy_
#define slacpy_ slacpy_
#define zlacpy_ zlacpy_
#define clacpy_ clacpy_
#define pdtran_ pdtran_
#define pstran_ pstran_
#define pztranc_ pztranc_
#define pctranc_ pctranc_
#define pdlacpy_ pdlacpy_
#define pslacpy_ pslacpy_
#define pzlacpy_ pzlacpy_
#define pclacpy_ pclacpy_
#endif
//***********************************************************************************************************
#define REALCASE 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment