forked from mom-ocean/MOM6
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autoconf: Fortran testing of C bindings
This patch fixes some issues with testing of C bindings in Fortran. Specifically, some tests are using a C compiler which may be unconfigured, causing unexpected errors. The autoconf script now uses the Fortran compiler to test these bindings, rather than using the C compiler to test for their existence. A new macro (AX_FC_CHECK_BIND_C) was added to run these tests. This achieves the actual goal (test of Fortran binding) on top of the original goal (availability of C function), while ensuring that the actual compiler of interest (FC) is used in the test. Two C-based tests are still present in the script for testing the size of jmp_buf and sigjmp_buf. The C compiler is now configured with the AX_MPI macro, and is only used to determine the size of these structs.
- Loading branch information
1 parent
d46de87
commit 522e7aa
Showing
3 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
dnl AX_FC_CHECK_C_LIB(FUNCTION, | ||
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], | ||
dnl [OTHER-LDFLAGS], [OTHER-LIBS]) | ||
dnl | ||
dnl This macro checks if a C binding is available to the compiler. | ||
dnl | ||
dnl Equivalently, it checks if the Fortran compiler can see a C function. | ||
dnl | ||
dnl Results are cached in `ax_fc_cv_bind_c_FUNCTION`. | ||
dnl | ||
AC_DEFUN([AX_FC_CHECK_BIND_C], [ | ||
AS_VAR_PUSHDEF([ax_fc_Bind_C], [ax_fc_cv_bind_c_$1]) | ||
m4_ifval([$4], | ||
[ax_fc_bind_c_msg_LDFLAGS=" with $4"], | ||
[ax_fc_bind_c_msg_LDFLAGS=""] | ||
) | ||
AC_CACHE_CHECK( | ||
[if $FC can bind $1$ax_fc_bind_c_msg_LDFLAGS], [ax_fc_cv_bind_c_$1], [ | ||
ax_fc_check_bind_c_save_LDFLAGS=$LDFLAGS | ||
LDFLAGS="$4 $LDFLAGS" | ||
ax_fc_check_bind_c_save_LIBS=$LIBS | ||
LIBS="$5 $LIBS" | ||
AC_LINK_IFELSE( | ||
[AC_LANG_PROGRAM([],[dnl | ||
dnl begin code block | ||
interface | ||
subroutine test() bind(c, name="$1") | ||
end subroutine test | ||
end interface | ||
call test]) | ||
dnl end code block | ||
], | ||
[AS_VAR_SET([ax_fc_Bind_C], [yes])], | ||
[AS_VAR_SET([ax_fc_Bind_C], [no])] | ||
) | ||
LDFLAGS=$ax_fc_check_bind_c_save_LDFLAGS | ||
LIBS=$ax_fc_check_bind_c_save_LIBS | ||
] | ||
) | ||
AS_VAR_IF([ax_fc_Bind_C], [yes], [$2], [$3]) | ||
AS_VAR_POPDEF([ax_fc_Bind_C]) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters