+# - specified_modules list of specified modules
+# - inctests true if tests should be included, blank otherwise
+# - incobsolete true if obsolete modules among dependencies should be
+# included, blank otherwise
+# - inc_cxx_tests true if C++ interoperability tests should be included,
+# blank otherwise
+# - inc_longrunning_tests true if long-runnings tests should be included,
+# blank otherwise
+# - inc_privileged_tests true if tests that require root privileges should be
+# included, blank otherwise
+# - inc_unportable_tests true if tests that fail on some platforms should be
+# included, blank otherwise
+# - inc_all_direct_tests true if all kinds of problematic unit tests among
+# the unit tests of the specified modules should be
+# included, blank otherwise
+# - inc_all_indirect_tests true if all kinds of problematic unit tests among
+# the unit tests of the dependencies should be
+# included, blank otherwise
+# - excl_cxx_tests true if C++ interoperability tests should be excluded,
+# blank otherwise
+# - excl_longrunning_tests true if long-runnings tests should be excluded,
+# blank otherwise
+# - excl_privileged_tests true if tests that require root privileges should be
+# excluded, blank otherwise
+# - excl_unportable_tests true if tests that fail on some platforms should be
+# excluded, blank otherwise
+# - avoidlist list of modules to avoid
+# - cond_dependencies true if conditional dependencies shall be supported,
+# blank otherwise
+# - tmp pathname of a temporary directory
+# Output:
+# - main_modules list of modules, including dependencies
+# - testsrelated_modules list of tests-related modules, including dependencies
+# - conddep_dependers, conddep_condition information about conditionally
+# enabled modules
+func_modules_transitive_closure_separately ()
+{
+ # Determine main module list.
+ saved_inctests="$inctests"
+ inctests=""
+ modules="$specified_modules"
+ func_modules_transitive_closure
+ main_modules="$modules"
+ inctests="$saved_inctests"
+ if test $verbose -ge 1; then
+ echo "Main module list:"
+ echo "$main_modules" | sed -e 's/^/ /'
+ fi
+ # Determine tests-related module list.
+ echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
+ testsrelated_modules=`for module in $main_modules; do
+ if test \`func_get_applicability $module\` = main; then
+ echo $module
+ fi
+ done \
+ | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
+ if test $verbose -ge 1; then
+ echo "Tests-related module list:"
+ echo "$testsrelated_modules" | sed -e 's/^/ /'
+ fi
+}
+
+# func_determine_use_libtests
+# Determines whether a $testsbase/libtests.a is needed.
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# - testsrelated_modules list of tests-related modules, including dependencies
+# Output:
+# - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
+func_determine_use_libtests ()
+{
+ use_libtests=false
+ for module in $testsrelated_modules; do
+ func_verify_nontests_module
+ if test -n "$module"; then
+ all_files=`func_get_filelist $module`
+ # Test whether some file in $all_files lies in lib/.
+ for f in $all_files; do
+ case $f in
+ lib/*)
+ use_libtests=true
+ break 2
+ ;;
+ esac
+ done
+ fi
+ done
+}
+
+# func_modules_add_dummy
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# - modules list of modules, including dependencies
+# Output:
+# - modules list of modules, including 'dummy' if needed
+func_modules_add_dummy ()
+{
+ # Determine whether any module provides a lib_SOURCES augmentation.
+ have_lib_SOURCES=
+ sed_remove_backslash_newline=':a
+/\\$/{
+s/\\$//
+N
+s/\n//
+ba
+}'
+ for module in $modules; do
+ func_verify_nontests_module
+ if test -n "$module"; then
+ # Extract the value of "lib_SOURCES += ...".
+ for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
+ # Ignore .h files since they are not compiled.
+ case "$file" in
+ *.h) ;;
+ *)
+ have_lib_SOURCES=yes
+ break 2
+ ;;
+ esac
+ done
+ fi
+ done
+ # Add the dummy module, to make sure the library will be non-empty.
+ if test -z "$have_lib_SOURCES"; then
+ if func_acceptable "dummy"; then
+ func_append modules " dummy"
+ fi
+ fi
+}
+
+# func_modules_add_dummy_separately
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# - main_modules list of modules, including dependencies
+# - testsrelated_modules list of tests-related modules, including dependencies
+# - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
+# Output:
+# - main_modules list of modules, including 'dummy' if needed
+# - testsrelated_modules list of tests-related modules, including 'dummy' if
+# needed
+func_modules_add_dummy_separately ()
+{
+ # Add the dummy module to the main module list if needed.
+ modules="$main_modules"
+ func_modules_add_dummy
+ main_modules="$modules"
+
+ # Add the dummy module to the tests-related module list if needed.
+ if $use_libtests; then
+ modules="$testsrelated_modules"
+ func_modules_add_dummy
+ testsrelated_modules="$modules"
+ fi
+}
+
+# func_modules_notice
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# - verbose integer, default 0, inc/decremented by --verbose/--quiet
+# - modules list of modules, including dependencies
+func_modules_notice ()