diff --git a/configure b/configure index e8d5504..bc7a26b 100755 --- a/configure +++ b/configure @@ -3541,6 +3541,53 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_tmp$acx_fc_module_subname.$acx_cv_fc_module_subnaming_ext" >&5 $as_echo "$acx_tmp$acx_fc_module_subname.$acx_cv_fc_module_subnaming_ext" >&6; } +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Fortran compiler generates submodule files for modules" >&5 +$as_echo_n "checking whether Fortran compiler generates submodule files for modules... " >&6; } +if ${acx_cv_fc_module_separate_submod+:} false; then : + $as_echo_n "(cached) " >&6 +else + acx_cv_fc_module_separate_submod=unknown + if test "x$acx_cv_fc_module_subnaming_ext" = x"$acx_cv_fc_module_naming_ext"; then : + acx_cv_fc_module_separate_submod=no +else + as_dir=conftest.dir; as_fn_mkdir_p + cd conftest.dir + cat > conftest.$ac_ext <<_ACEOF + module conftest_module + implicit none + public + interface + module subroutine conftest_routine + end subroutine + end interface + end module +_ACEOF +if ac_fn_fc_try_compile "$LINENO"; then : + if test "x$acx_cv_fc_module_naming_upper" = xyes; then : + acx_fc_module_name='CONFTEST_MODULE' +else + acx_fc_module_name='conftest_module' +fi + if test -f "$acx_fc_module_name.$acx_cv_fc_module_subnaming_ext"; then : + acx_cv_fc_module_separate_submod=yes +else + acx_cv_fc_module_separate_submod=no +fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cd .. + rm -rf conftest.dir +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_fc_module_separate_submod" >&5 +$as_echo "$acx_cv_fc_module_separate_submod" >&6; } + if test "x$acx_cv_fc_module_separate_submod" = xunknown; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "unable to detect whether Fortran compiler generates submodule files for modules +See \`config.log' for more details" "$LINENO" 5; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran compiler flag needed to specify search paths for the \"INCLUDE\" statement" >&5 diff --git a/configure.ac b/configure.ac index cb38f63..3eabb9f 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,8 @@ ACX_FC_MODULE_NAMING( ACX_FC_MODULE_SUBNAMING +ACX_FC_MODULE_SEPARATE_SUBMOD + ACX_FC_INCLUDE_FLAG( [AC_SUBST([FC_INC_FLAG], [$acx_cv_fc_ftn_include_flag])]) ACX_FC_INCLUDE_ORDER( diff --git a/m4/acx_fc_module.m4 b/m4/acx_fc_module.m4 index af517e3..72c7bc5 100644 --- a/m4/acx_fc_module.m4 +++ b/m4/acx_fc_module.m4 @@ -276,6 +276,55 @@ submodule file naming template])])], [$acx_tmp$acx_fc_module_subname.$acx_cv_fc_module_subnaming_ext]) $1])]) +# ACX_FC_MODULE_SEPARATE_SUBMOD([ACTION-IF-SUCCESS], +# [ACTION-IF-FAILURE = FAILURE]) +# ----------------------------------------------------------------------------- +# Checks whether the Fortran compiler generates separate submodule files for +# the root ancestor modules. +# +# If successful, runs ACTION-IF-SUCCESS, otherwise runs ACTION-IF-FAILURE +# (defaults to failing with an error message). +# +# The result is cached in the acx_cv_fc_module_separate_submod variable. If the +# compiler generates separate submodule files for the root ancestor modules, +# acx_cv_fc_module_separate_submod is "yes", and "no" otherwise. If the +# detection fails, acx_cv_fc_module_separate_submod is set to "unknown". +# +AC_DEFUN([ACX_FC_MODULE_SEPARATE_SUBMOD], + [AC_LANG_ASSERT([Fortran])dnl + AC_REQUIRE([ACX_FC_MODULE_NAMING])dnl + AC_REQUIRE([ACX_FC_MODULE_SUBNAMING])dnl + AC_CACHE_CHECK( + [whether Fortran compiler generates submodule files for modules], + [acx_cv_fc_module_separate_submod], + [acx_cv_fc_module_separate_submod=unknown + AS_VAR_IF([acx_cv_fc_module_subnaming_ext], + ["$acx_cv_fc_module_naming_ext"], + [acx_cv_fc_module_separate_submod=no], + [AS_MKDIR_P([conftest.dir]) + cd conftest.dir + AC_COMPILE_IFELSE([AC_LANG_SOURCE( +[[ module conftest_module + implicit none + public + interface + module subroutine conftest_routine + end subroutine + end interface + end module]])], + [AS_VAR_IF([acx_cv_fc_module_naming_upper], [yes], + [acx_fc_module_name='CONFTEST_MODULE'], + [acx_fc_module_name='conftest_module']) + AS_IF( + [test -f "$acx_fc_module_name.$acx_cv_fc_module_subnaming_ext"], + [acx_cv_fc_module_separate_submod=yes], + [acx_cv_fc_module_separate_submod=no])]) + cd .. + rm -rf conftest.dir])]) + AS_VAR_IF([acx_cv_fc_module_separate_submod], [unknown], [m4_default([$2], + [AC_MSG_FAILURE([unable to detect whether Fortran compiler generates dnl +submodule files for modules])])], [$1])]) + # ACX_FC_MODULE_CHECK(MODULE-NAME, # [ACTION-IF-SUCCESS], # [ACTION-IF-FAILURE = FAILURE])