+ if case "$TERM" in
+ xterm*) test -t 1;;
+ *) false;;
+ esac; then
+ # Assume xterm compatible escape sequences.
+ bold_on=`printf '\x1b[1m'`
+ bold_off=`printf '\x1b[0m'`
+ else
+ bold_on=
+ bold_off=
+ fi
+ echo "Module list with included dependencies (indented):"
+ echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
+ echo "$modules" | sed -e '/^$/d' \
+ | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
+ | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
+}
+
+# func_modules_transitive_closure_separately
+# Determine main module list and tests-related module list separately.
+# The main module list is the transitive closure of the specified modules,
+# ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
+# is specified, it will consist only of LGPLed source.
+# The tests-related module list is the transitive closure of the specified
+# modules, including tests modules, minus the main module list excluding
+# modules of applicability 'all'. Its lib/* sources (brought in through
+# dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
+# source, even if --lgpl is specified.
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# - 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"