+# sed expression to keep the first 32 characters of each line.
+sed_first_32_chars='s/^\(................................\).*/\1/'
+
+# func_module_shellfunc_name module
+# computes the shell function name that will contain the m4 macros for the module.
+# Input:
+# - macro_prefix prefix to use
+# Output:
+# - shellfunc shell function name
+func_module_shellfunc_name ()
+{
+ case $1 in
+ *[!a-zA-Z0-9_]*)
+ shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
+ *)
+ shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
+ esac
+}
+
+# func_module_shellvar_name module
+# computes the shell variable name the will be set to true once the m4 macros
+# for the module have been executed.
+# Output:
+# - shellvar shell variable name
+func_module_shellvar_name ()
+{
+ case $1 in
+ *[!a-zA-Z0-9_]*)
+ shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
+ *)
+ shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
+ esac
+}
+
+# func_module_conditional_name module
+# computes the automake conditional name for the module.
+# Output:
+# - conditional name of automake conditional
+func_module_conditional_name ()
+{
+ case $1 in
+ *[!a-zA-Z0-9_]*)
+ conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
+ *)
+ conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
+ esac
+}
+
+# func_uncond_add_module B
+# notes the presence of B as an unconditional module.
+#
+# func_conddep_add_module A B cond
+# notes the presence of a conditional dependency from module A to module B,
+# subject to the condition that A is enabled and cond is true.
+#
+# func_cond_module_p B
+# tests whether module B is conditional.
+#
+# func_cond_module_condition A B
+# returns the condition when B should be enabled as a dependency of A, once the
+# m4 code for A has been executed.
+# Output: - condition
+#
+if $have_associative; then
+ declare -A conddep_isuncond
+ declare -A conddep_dependers
+ declare -A conddep_condition
+ func_uncond_add_module ()
+ {
+ eval 'conddep_isuncond[$1]=true'
+ eval 'unset conddep_dependers[$1]'
+ }
+ func_conddep_add_module ()
+ {
+ eval 'isuncond="${conddep_isuncond[$2]}"'
+ if test -z "$isuncond"; then
+ # No unconditional dependency to B known at this point.
+ eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
+ eval 'conddep_condition[$1---$2]="$3"'
+ fi
+ }
+ func_cond_module_p ()
+ {
+ eval 'previous_dependers="${conddep_dependers[$1]}"'
+ test -n "$previous_dependers"
+ }
+ func_cond_module_condition ()
+ {
+ eval 'condition="${conddep_condition[$1---$2]}"'
+ }
+else
+ func_uncond_add_module ()
+ {
+ case $1 in
+ *[!a-zA-Z0-9_]*)
+ suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
+ *)
+ suffix=$1 ;;
+ esac
+ eval 'conddep_isuncond_'"$suffix"'=true'
+ eval 'unset conddep_dependers_'"$suffix"
+ }
+ func_conddep_add_module ()
+ {
+ case $2 in
+ *[!a-zA-Z0-9_]*)
+ suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
+ *)
+ suffix=$2 ;;
+ esac
+ eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
+ if test -z "$isuncond"; then
+ eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
+ suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
+ eval 'conddep_condition_'"$suffix"'="$3"'
+ fi
+ }
+ func_cond_module_p ()
+ {
+ case $1 in
+ *[!a-zA-Z0-9_]*)
+ suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
+ *)
+ suffix=$1 ;;
+ esac
+ eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
+ test -n "$previous_dependers"
+ }
+ func_cond_module_condition ()
+ {
+ suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
+ eval 'condition="${conddep_condition_'"$suffix"'}"'
+ }
+fi
+
+sed_dependencies_without_conditions='s/ *\[.*//'
+