+ else
+
+ # func_cache_var module
+ # computes the cache variable name corresponding to $module.
+ # Note: This computation can map different module names to the same
+ # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
+ # to protect against this case.
+ # Output:
+ # - cachevar a shell variable name
+ if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
+ # Bash 2.0 and newer, ksh, and zsh support the syntax
+ # ${param//pattern/replacement}
+ # as a shorthand for
+ # `echo "$param" | sed -e "s/pattern/replacement/g"`.
+ # Note: The 'eval' above silences stderr output in dash.
+ func_cache_var ()
+ {
+ cachevar=c_${1//[!a-zA-Z0-9_]/_}
+ }
+ else
+ func_cache_var ()
+ {
+ case $1 in
+ *[!a-zA-Z0-9_]*)
+ cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
+ *)
+ cachevar=c_$1 ;;
+ esac
+ }
+ fi
+
+ fi
+
+ # func_init_sed_convert_to_cache_statements
+ # Input:
+ # - modcachevar_assignment
+ # Output:
+ # - sed_convert_to_cache_statements
+ func_init_sed_convert_to_cache_statements ()
+ {
+ # 'sed' script that turns a module description into shell script
+ # assignments, suitable to be eval'ed. All active characters are escaped.
+ # This script turns
+ # Description:
+ # Some module's description
+ #
+ # Files:
+ # lib/file.h
+ # into:
+ # modcache_description[$1]=\
+ # 'Some module'"'"'s description
+ # '
+ # modcache_files[$1]=\
+ # 'lib/file.h'
+ # or:
+ # c_MODULE_description_set=set; c_MODULE_description=\
+ # 'Some module'"'"'s description
+ # '
+ # c_MODULE_files_set=set; c_MODULE_files=\
+ # 'lib/file.h'
+ # The script consists of two parts:
+ # 1) Ignore the lines before the first field header.
+ # 2) A loop, treating non-field-header lines by escaping single quotes
+ # and adding a closing quote in the last line,
+ sed_convert_to_cache_statements="
+ :llla
+ # Here we have not yet seen a field header.
+
+ # See if the current line contains a field header.
+ t llla1
+ :llla1
+ ${sed_extract_field_header}
+ t lllb
+
+ # No field header. Ignore the line.
+
+ # Read the next line. Upon EOF, just exit.
+ n
+ b llla
+
+ :lllb
+ # The current line contains a field header.
+
+ # Turn it into the beginning of an assignment.
+ s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
+
+ # Move it to the hold space. Don't print it yet,
+ # because we want no assignment if the field is empty.
+ h
+
+ # Read the next line.
+ # Upon EOF, the field was empty. Print no assignment. Just exit.
+ n
+
+ # See if the current line contains a field header.
+ t lllb1
+ :lllb1
+ ${sed_extract_field_header}
+ # If it is, the previous field was empty. Print no assignment.
+ t lllb
+
+ # Not a field header.
+
+ # Print the previous line, held in the hold space.
+ x
+ p
+ x
+
+ # Transform single quotes.
+ s/'/'\"'\"'/g
+
+ # Prepend a single quote.
+ s/^/'/
+
+ :lllc
+
+ # Move it to the hold space.
+ h
+
+ # Read the next line.
+ # Upon EOF, branch.
+ \${
+ b llle
+ }
+ n
+
+ # See if the current line contains a field header.
+ t lllc1
+ :lllc1
+ ${sed_extract_field_header}
+ t llld
+
+ # Print the previous line, held in the hold space.
+ x
+ p
+ x
+
+ # Transform single quotes.
+ s/'/'\"'\"'/g
+
+ b lllc
+
+ :llld
+ # A field header.
+ # Print the previous line, held in the hold space, with a single quote
+ # to end the assignment.
+ x
+ s/\$/'/
+ p
+ x
+
+ b lllb
+
+ :llle
+ # EOF seen.
+ # Print the previous line, held in the hold space, with a single quote
+ # to end the assignment.
+ x
+ s/\$/'/
+ p
+ # Exit.
+ n
+ "
+ if ! $sed_comments; then
+ # Remove comments.
+ sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
+ | sed -e 's/^ *//' -e 's/^#.*//'`
+ fi
+ }
+
+ if $have_associative; then
+ # sed_convert_to_cache_statements does not depend on the module.
+ modcachevar_assignment='modcache_\1[$1]='
+ func_init_sed_convert_to_cache_statements
+ fi
+
+ # func_cache_lookup_module module
+ #
+ # looks up a module, like 'func_lookup_file modules/$module', and stores all
+ # of its relevant data in a cache in the memory of the processing shell. If
+ # already cached, it does not look it up again, thus saving file access time.
+ # Parameters:
+ # - module non-empty string
+ # Output if $have_associative:
+ # - modcache_cached[$module] set to yes
+ # - modcache_description[$module] ==
+ # - modcache_status[$module] \ set to the field's value, minus the
+ # - ... / final newline,
+ # - modcache_maintainer[$module] == or unset if the field's value is empty
+ # Output if ! $have_associative:
+ # - cachevar a shell variable name
+ # - ${cachevar}_cached set to $module
+ # - ${cachevar}_description ==
+ # - ${cachevar}_status \ set to the field's value, minus the
+ # - ... / final newline,
+ # - ${cachevar}_maintainer == or unset if the field's value is empty
+ # - ${cachevar}_description_set ==
+ # - ${cachevar}_status_set \ set to non-empty if the field's value
+ # - ... / is non-empty,
+ # - ${cachevar}_maintainer_set == or unset if the field's value is empty
+ func_cache_lookup_module ()
+ {
+ if $have_associative; then
+ cached=${modcache_cached[$1]}
+ else
+ func_cache_var "$1"
+ eval "cached=\"\$${cachevar}_cached\""
+ fi
+ if test -z "$cached"; then
+ # Not found in cache. Look it up on the file system.
+ func_lookup_file "modules/$1"
+ if $have_associative; then
+ modcache_cached[$1]=yes
+ else
+ eval "${cachevar}_cached=\"\$1\""
+ fi
+ if ! $have_associative; then
+ # sed_convert_to_cache_statements depends on the module.
+ modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
+ func_init_sed_convert_to_cache_statements
+ fi
+ cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
+ eval "$cache_statements"
+ else
+ if ! $have_associative; then
+ if test "$1" != "$cached"; then
+ func_fatal_error "cache variable collision between $1 and $cached"
+ fi
+ fi
+ fi
+ }
+
+fi
+
+# func_get_description module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_description ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_description[$1]+set}"; then
+ echo "${modcache_description[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_description_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_description\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
+# func_get_comment module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_comment ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_comment[$1]+set}"; then
+ echo "${modcache_comment[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_comment_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_comment\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
+# func_get_status module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_status ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_status[$1]+set}"; then
+ echo "${modcache_status[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_status_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_status\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
+# func_get_notice module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_notice ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_notice[$1]+set}"; then
+ echo "${modcache_notice[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_notice_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_notice\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
+# func_get_applicability module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+# The expected result (on stdout) is either 'main', or 'tests', or 'all'.
+func_get_applicability ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
+ else
+ func_cache_lookup_module "$1"
+ # Get the field's value, without the final newline.
+ if $have_associative; then
+ my_applicability="${modcache_applicability[$1]}"
+ else
+ eval "my_applicability=\"\$${cachevar}_applicability\""
+ fi
+ fi
+ if test -n "$my_applicability"; then
+ echo $my_applicability
+ else
+ # The default is 'main' or 'tests', depending on the module's name.
+ case $1 in
+ *-tests) echo "tests";;
+ *) echo "main";;
+ esac
+ fi
+}
+
+# func_get_filelist module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_filelist ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_files[$1]+set}"; then
+ echo "${modcache_files[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_files_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_files\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+ echo m4/00gnulib.m4
+ echo m4/gnulib-common.m4
+ case "$autoconf_minversion" in
+ 2.59)
+ echo m4/onceonly.m4
+ ;;
+ esac
+}
+
+# func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
+# stores in outputvar the filtered and processed filelist. Filtering: Only the
+# elements starting with prefix and ending with suffix are considered.
+# Processing: removed_prefix and removed_suffix are removed from each element,
+# added_prefix and added_suffix are added to each element.
+# prefix, suffix should not contain shell-special characters.
+# removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
+# added_prefix, added_suffix should not contain the characters \|&.
+func_filter_filelist ()
+{
+ if test "$2" != "$nl" \
+ || { $fast_func_append \
+ && { test -z "$6" || $fast_func_remove_prefix; } \
+ && { test -z "$7" || $fast_func_remove_suffix; }; \
+ }; then
+ ffflist=
+ for fff in $3; do
+ # Do not quote possibly-empty parameters in case patterns,
+ # AIX and HP-UX ksh won't match them if they are empty.
+ case "$fff" in
+ $4*$5)
+ if test -n "$6"; then
+ func_remove_prefix fff "$6"
+ fi
+ if test -n "$7"; then
+ func_remove_suffix fff "$7"
+ fi
+ fff="$8${fff}$9"
+ if test -z "$ffflist"; then
+ ffflist="${fff}"
+ else
+ func_append ffflist "$2${fff}"
+ fi
+ ;;
+ esac
+ done
+ else
+ sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
+ ffflist=`for fff in $3; do
+ case "$fff" in
+ $4*$5) echo "$fff" ;;
+ esac
+ done | sed -e "$sed_fff_filter"`
+ fi
+ eval "$1=\"\$ffflist\""
+}
+
+# func_get_dependencies module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_dependencies ()
+{
+ # ${module}-tests implicitly depends on ${module}, if that module exists.
+ case "$1" in
+ *-tests)
+ fgd1="$1"
+ func_remove_suffix fgd1 '-tests'
+ if func_exists_module "$fgd1"; then
+ echo "$fgd1"
+ fi
+ ;;
+ esac
+ # Then the explicit dependencies listed in the module description.
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_dependson[$1]+set}"; then
+ echo "${modcache_dependson[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_dependson_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_dependson\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
+# func_get_autoconf_early_snippet module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_autoconf_early_snippet ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_configureac_early[$1]+set}"; then
+ echo "${modcache_configureac_early[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_configureac_early_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_configureac_early\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
+# func_get_autoconf_snippet module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_autoconf_snippet ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_configureac[$1]+set}"; then
+ echo "${modcache_configureac[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_configureac_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_configureac\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
+# func_get_automake_snippet module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_automake_snippet ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_makefile[$1]+set}"; then
+ echo "${modcache_makefile[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_makefile_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_makefile\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+ case "$1" in
+ *-tests)
+ # *-tests module live in tests/, not lib/.
+ # Synthesize an EXTRA_DIST augmentation.
+ all_files=`func_get_filelist $1`
+ func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
+ extra_files="$tests_files"
+ if test -n "$extra_files"; then
+ echo "EXTRA_DIST +=" $extra_files
+ echo
+ fi
+ ;;
+ *)
+ # Synthesize an EXTRA_DIST augmentation.
+ sed_combine_lines='/\\$/{
+ :a
+ N
+ s/\\\n/ /
+ s/\\$/\\/
+ ta
+ }'
+ sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
+ already_mentioned_files=` \
+ { if ! $modcache; then
+ sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
+ else
+ if $have_associative; then
+ if test -n "${modcache_makefile[$1]+set}"; then
+ echo "${modcache_makefile[$1]}"
+ fi
+ else
+ eval 'field_set="$'"${cachevar}"'_makefile_set"'
+ if test -n "$field_set"; then
+ eval 'field_value="$'"${cachevar}"'_makefile"'
+ echo "${field_value}"
+ fi
+ fi
+ fi
+ } \
+ | sed -e "$sed_combine_lines" \
+ | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
+ all_files=`func_get_filelist $1`
+ func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
+ # Remove $already_mentioned_files from $lib_files.
+ echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
+ extra_files=`for f in $already_mentioned_files; do echo $f; done \
+ | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
+ if test -n "$extra_files"; then
+ echo "EXTRA_DIST +=" $extra_files
+ echo
+ fi
+ # Synthesize also an EXTRA_lib_SOURCES augmentation.
+ # This is necessary so that automake can generate the right list of
+ # dependency rules.
+ # A possible approach would be to use autom4te --trace of the redefined
+ # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
+ # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
+ # inside autoconf's built-in macros are not missed).
+ # But it's simpler and more robust to do it here, based on the file list.
+ # If some .c file exists and is not used with AC_LIBOBJ - for example,
+ # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
+ # automake will generate a useless dependency; this is harmless.
+ case "$1" in
+ relocatable-prog-wrapper) ;;
+ *)
+ func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
+ if test -n "$extra_files"; then
+ echo "EXTRA_lib_SOURCES +=" $extra_files
+ echo
+ fi
+ ;;
+ esac
+ # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
+ func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
+ if test -n "$buildaux_files"; then
+ sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
+ echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
+ echo
+ fi
+ # Synthesize an EXTRA_DIST augmentation also for the files from top/.
+ func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
+ if test -n "$top_files"; then
+ sed_prepend_topdir='s,^,$(top_srcdir)/,'
+ echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
+ echo
+ fi
+ ;;
+ esac
+}
+
+# func_get_include_directive module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_include_directive ()
+{
+ {
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_include[$1]+set}"; then
+ echo "${modcache_include[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_include_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_include\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+ } | sed -e 's/^\(["<]\)/#include \1/'
+}
+
+# func_get_link_directive module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_link_directive ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_link[$1]+set}"; then
+ echo "${modcache_link[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_link_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_link\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}