+ echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
+ echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
+ echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
+ echo " fi; \\"
+ echo " done; \\"
+ echo " :"
+ rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
+}
+
+# func_emit_initmacro_start macro_prefix
+# emits the first few statements of the gl_INIT macro to standard output.
+# - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
+func_emit_initmacro_start ()
+{
+ macro_prefix_arg="$1"
+ # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
+ # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
+ # LIBOBJS. The purpose is to allow several gnulib instantiations under
+ # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
+ # flexibility.)
+ # Furthermore it avoids an automake error like this when a Makefile.am
+ # that uses pieces of gnulib also uses $(LIBOBJ):
+ # automatically discovered file `error.c' should not be explicitly mentioned
+ echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
+ echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
+ # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
+ # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
+ # automatically discovered file `error.c' should not be explicitly mentioned
+ # We let automake know about the files to be distributed through the
+ # EXTRA_lib_SOURCES variable.
+ echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
+ # Create data variables for checking the presence of files that are mentioned
+ # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
+ # because we want the check to happen when the configure file is created,
+ # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
+ # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
+ # in which to expect them.
+ echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
+ echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
+ echo " gl_COMMON"
+}
+
+# func_emit_initmacro_end macro_prefix
+# emits the last few statements of the gl_INIT macro to standard output.
+# - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
+func_emit_initmacro_end ()
+{
+ macro_prefix_arg="$1"
+ # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
+ # The check is performed only when autoconf is run from the directory where
+ # the configure.ac resides; if it is run from a different directory, the
+ # check is skipped.
+ echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
+ echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
+ echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
+ echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
+ echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
+ echo " exit 1"
+ echo " fi"
+ echo " done])dnl"
+ echo " m4_if(m4_sysval, [0], [],"
+ echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
+ echo " ])"
+ echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
+ echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
+ echo " m4_popdef([AC_LIBSOURCES])"
+ echo " m4_popdef([AC_REPLACE_FUNCS])"
+ echo " m4_popdef([AC_LIBOBJ])"
+ echo " AC_CONFIG_COMMANDS_PRE(["
+ echo " ${macro_prefix_arg}_libobjs="
+ echo " ${macro_prefix_arg}_ltlibobjs="
+ echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
+ echo " # Remove the extension."
+ echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
+ echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
+ echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
+ echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
+ echo " done"
+ echo " fi"
+ echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
+ echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
+ echo " ])"
+}
+
+# func_emit_initmacro_done macro_prefix sourcebase
+# emits a few statements after the gl_INIT macro to standard output.
+# - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
+# - sourcebase directory relative to destdir where to place source code
+func_emit_initmacro_done ()
+{
+ macro_prefix_arg="$1"
+ sourcebase_arg="$2"
+ echo
+ echo "# Like AC_LIBOBJ, except that the module name goes"
+ echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
+ echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
+ echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
+ echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
+ echo "])"
+ echo
+ echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
+ echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
+ echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
+ echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
+ echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
+ echo "])"
+ echo
+ echo "# Like AC_LIBSOURCES, except the directory where the source file is"
+ echo "# expected is derived from the gnulib-tool parameterization,"
+ echo "# and alloca is special cased (for the alloca-opt module)."
+ echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
+ echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
+ echo " m4_foreach([_gl_NAME], [\$1], ["
+ echo " m4_if(_gl_NAME, [alloca.c], [], ["
+ echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
+ echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
+ echo " ])"
+ echo " ])"
+ echo "])"
+}
+
+# func_emit_autoconf_snippet indentation
+# emits the autoconf snippet of a module.
+# 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
+# - 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.
+# - indentation spaces to prepend on each line
+func_emit_autoconf_snippet ()
+{
+ 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" \
+ | { 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
+# - 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