+# func_emit_autoconf_snippet indentation
+# emits the autoconf snippet of a module.
+# Input:
+# - indentation spaces to prepend on each line
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# - sed_replace_build_aux sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+# sed expression for resolving ${gl_include_guard_prefix}
+# - module the module name
+# - toplevel true or false. 'false' means a subordinate use of
+# gnulib-tool.
+# - disable_libtool true or false. It tells whether to disable libtool
+# handling even if it has been specified through the
+# command line options.
+# - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
+# invocations.
+func_emit_autoconf_snippet ()
+{
+ indentation="$1"
+ if { case $module in
+ gnumakefile | maintainer-makefile)
+ # These modules are meant to be used only in the top-level directory.
+ $toplevel ;;
+ *)
+ true ;;
+ esac
+ }; then
+ func_get_autoconf_snippet "$module" \
+ | sed -e '/^$/d;' -e "s/^/$indentation/" \
+ -e "$sed_replace_build_aux" \
+ -e "$sed_replace_include_guard_prefix" \
+ | { if $disable_libtool; then
+ sed -e 's/\$gl_cond_libtool/false/g' \
+ -e 's/gl_libdeps/gltests_libdeps/g' \
+ -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
+ else
+ cat
+ fi
+ } \
+ | { if $disable_gettext; then
+ sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
+ else
+ cat
+ fi
+ }
+ if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
+ echo 'changequote(,)dnl'
+ echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
+ echo 'changequote([, ])dnl'
+ echo 'AC_SUBST([LTALLOCA])'
+ fi
+ fi
+}
+
+# func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
+# collects and emit the autoconf snippets of a set of modules.
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# - sed_replace_build_aux sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+# sed expression for resolving ${gl_include_guard_prefix}
+# - modules the list of modules.
+# - verifier one of func_verify_module, func_verify_nontests_module,
+# func_verify_tests_module. It selects the subset of
+# $modules to consider.
+# - toplevel true or false. 'false' means a subordinate use of
+# gnulib-tool.
+# - disable_libtool true or false. It tells whether to disable libtool
+# handling even if it has been specified through the
+# command line options.
+# - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
+# invocations.
+func_emit_autoconf_snippets ()
+{
+ verifier="$2"
+ toplevel="$3"
+ disable_libtool="$4"
+ disable_gettext="$5"
+ if test "$cond_dependencies" = true; then
+ for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
+ # Emit the autoconf code for the unconditional modules.
+ for module in $1; do
+ eval $verifier
+ if test -n "$module"; then
+ if func_cond_module_p "$module"; then
+ :
+ else
+ func_emit_autoconf_snippet " "
+ fi
+ fi
+ done
+ # Initialize the shell variables indicating that the modules are enabled.
+ for module in $1; do
+ eval $verifier
+ if test -n "$module"; then
+ if func_cond_module_p "$module"; then
+ func_module_shellvar_name "$module"
+ echo " $shellvar=false"
+ fi
+ fi
+ done
+ # Emit the autoconf code for the conditional modules, each in a separate
+ # function. This makes it possible to support cycles among conditional
+ # modules.
+ for module in $1; do
+ eval $verifier
+ if test -n "$module"; then
+ if func_cond_module_p "$module"; then
+ func_module_shellfunc_name "$module"
+ func_module_shellvar_name "$module"
+ echo " $shellfunc ()"
+ echo ' {'
+ echo " if ! \$$shellvar; then"
+ func_emit_autoconf_snippet " "
+ echo " $shellvar=true"
+ deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
+ # Intersect $deps with the modules list $1.
+ deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
+ for dep in $deps; do
+ if func_cond_module_p "$dep"; then
+ func_module_shellfunc_name "$dep"
+ func_cond_module_condition "$module" "$dep"
+ if test "$condition" != true; then
+ echo " if $condition; then"
+ echo " $shellfunc"
+ echo ' fi'
+ else
+ echo " $shellfunc"
+ fi
+ else
+ # The autoconf code for $dep has already been emitted above and
+ # therefore is already executed when this function is run.
+ :
+ fi
+ done
+ echo ' fi'
+ echo ' }'
+ fi
+ fi
+ done
+ # Emit the dependencies from the unconditional to the conditional modules.
+ for module in $1; do
+ eval $verifier
+ if test -n "$module"; then
+ if func_cond_module_p "$module"; then
+ :
+ else
+ deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
+ # Intersect $deps with the modules list $1.
+ deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
+ for dep in $deps; do
+ if func_cond_module_p "$dep"; then
+ func_module_shellfunc_name "$dep"
+ func_cond_module_condition "$module" "$dep"
+ if test "$condition" != true; then
+ echo " if $condition; then"
+ echo " $shellfunc"
+ echo ' fi'
+ else
+ echo " $shellfunc"
+ fi
+ else
+ # The autoconf code for $dep has already been emitted above and
+ # therefore is already executed when this code is run.
+ :
+ fi
+ done
+ fi
+ fi
+ done
+ # Define the Automake conditionals.
+ echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
+ for module in $1; do
+ eval $verifier
+ if test -n "$module"; then
+ if func_cond_module_p "$module"; then
+ func_module_conditional_name "$module"
+ func_module_shellvar_name "$module"
+ echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
+ fi
+ fi
+ done
+ else
+ # Ignore the conditions, and enable all modules unconditionally.
+ for module in $1; do
+ eval $verifier
+ if test -n "$module"; then
+ func_emit_autoconf_snippet " "
+ fi
+ done
+ fi
+}
+