forked from mom-ocean/MOM6
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch updates the macros used in the `ac/deps` directory. It includes a bugfix in the library testing, and also bundles the macro for testing Fortran links to C libraries. Both of these macros were already in `ac/m4` but unused by `ac/deps`. No problems were observed in any recent FMS builds, although in principle they could have been affected by these errors. The issues were only detected when the macros were used in an unrelated project (LM3 land model). These issues are due to code duplication in `ac/m4` and `ac/deps/m4`. This separation was intended to draw a clear logical separation between MOM6 and its FMS dependency, and only provide what is required by each respective build. But perhaps there are some flaws in this thinking, and may warrant further discussion.
- Loading branch information
1 parent
72fbee0
commit 9f7f86d
Showing
2 changed files
with
52 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
dnl AX_FC_CHECK_C_LIB(LIBRARY, FUNCTION, | ||
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], | ||
dnl [OTHER-LDFLAGS], [OTHER-LIBS]) | ||
dnl | ||
dnl This macro checks if a C library can be referenced by a Fortran compiler. | ||
dnl | ||
dnl Results are cached in `ax_fc_cv_c_lib_LIBRARY_FUNCTION`. | ||
dnl | ||
dnl NOTE: Might be possible to rewrite this to use `AX_FC_CHECK_BIND_C`. | ||
dnl | ||
AC_DEFUN([AX_FC_CHECK_C_LIB], [ | ||
AS_VAR_PUSHDEF([ax_fc_C_Lib], [ax_fc_cv_c_lib_$1_$2]) | ||
m4_ifval([$5], | ||
[ax_fc_c_lib_msg_LDFLAGS=" with $5"], | ||
[ax_fc_c_lib_msg_LDFLAGS=""] | ||
) | ||
AC_CACHE_CHECK( | ||
[for $2 in -l$1$ax_fc_c_lib_msg_LDFLAGS], [ax_fc_cv_c_lib_$1_$2], [ | ||
ax_fc_check_c_lib_save_LDFLAGS=$LDFLAGS | ||
LDFLAGS="$6 $LDFLAGS" | ||
ax_fc_check_c_lib_save_LIBS=$LIBS | ||
LIBS="-l$1 $7 $LIBS" | ||
AC_LINK_IFELSE( | ||
[AC_LANG_PROGRAM([],[dnl | ||
dnl begin code block | ||
interface | ||
subroutine test() bind(c, name="$2") | ||
end subroutine test | ||
end interface | ||
call test]) | ||
dnl end code block | ||
], | ||
[AS_VAR_SET([ax_fc_C_Lib], [yes])], | ||
[AS_VAR_SET([ax_fc_C_Lib], [no])] | ||
) | ||
LDFLAGS=$ax_fc_check_c_lib_save_LDFLAGS | ||
LIBS=$ax_fc_check_c_lib_save_LIBS | ||
] | ||
) | ||
AS_VAR_IF([ax_fc_C_Lib], [yes], | ||
[m4_default([$3], [LIBS="-l$1 $LIBS"])], | ||
[$4] | ||
) | ||
AS_VAR_POPDEF([ax_fc_C_Lib]) | ||
]) |
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