- fi
- # Append the cached and the specified module names. So that
- # "gnulib-tool --import foo" means to add the module foo.
- specified_modules="$cached_specified_modules $1"
- # Included obsolete modules among the dependencies if specified either way.
- if test -z "$incobsolete"; then
- incobsolete="$cached_incobsolete"
- fi
- # Included special kinds of tests modules among the dependencies if specified
- # either way.
- if test -z "$inc_cxx_tests"; then
- inc_cxx_tests="$cached_inc_cxx_tests"
- fi
- if test -z "$inc_longrunning_tests"; then
- inc_longrunning_tests="$cached_inc_longrunning_tests"
- fi
- if test -z "$inc_privileged_tests"; then
- inc_privileged_tests="$cached_inc_privileged_tests"
- fi
- if test -z "$inc_unportable_tests"; then
- inc_unportable_tests="$cached_inc_unportable_tests"
- fi
- if test -z "$inc_all_tests"; then
- inc_all_tests="$cached_inc_all_tests"
- fi
- # --without-*-tests options are not supported here.
- excl_cxx_tests=
- excl_longrunning_tests=
- excl_privileged_tests=
- excl_unportable_tests=
- # Append the cached and the specified avoidlist. This is probably better
- # than dropping the cached one when --avoid is specified at least once.
- avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
- avoidlist=`echo $avoidlist`
-
- # The sourcebase defaults to the cached one.
- if test -z "$sourcebase"; then
- sourcebase="$cached_sourcebase"
+ # The local_gnulib_dir defaults to the cached one. Recall that the cached one
+ # is relative to $destdir, whereas the one we use is relative to . or absolute.
+ if test -z "$local_gnulib_dir"; then
+ if test -n "$cached_local_gnulib_dir"; then
+ case "$destdir" in
+ /*)
+ local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
+ *)
+ case "$cached_local_gnulib_dir" in
+ /*)
+ local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
+ *)
+ func_relconcat "$destdir" "$cached_local_gnulib_dir"
+ local_gnulib_dir="$relconcat" ;;
+ esac ;;
+ esac
+ fi
+ fi
+ case $mode in
+ add-import)
+ # Append the cached and the specified module names. So that
+ # "gnulib-tool --add-import foo" means to add the module foo.
+ specified_modules="$cached_specified_modules $1"
+ ;;
+ remove-import)
+ # Take the cached module names, minus the specified module names.
+ specified_modules=
+ if $have_associative; then
+ # Use an associative array, for O(N) worst-case run time.
+ declare -A to_remove
+ for m in $1; do
+ eval 'to_remove[$m]=yes'
+ done
+ for module in $cached_specified_modules; do
+ if eval 'test -z "${to_remove[$module]}"'; then
+ func_append specified_modules "$module "
+ fi
+ done
+ else
+ # This loop has O(N²) worst-case run time.
+ for module in $cached_specified_modules; do
+ to_remove=
+ for m in $1; do
+ if test "$m" = "$module"; then
+ to_remove=yes
+ break
+ fi
+ done
+ if test -z "$to_remove"; then
+ func_append specified_modules "$module "
+ fi
+ done
+ fi
+ ;;
+ update)
+ # Take the cached module names. There are no specified module names.
+ specified_modules="$cached_specified_modules"
+ ;;
+ esac
+ # Included obsolete modules among the dependencies if specified either way.
+ if test -z "$incobsolete"; then
+ incobsolete="$cached_incobsolete"
+ fi
+ # Included special kinds of tests modules among the dependencies if specified
+ # either way.
+ if test -z "$inc_cxx_tests"; then
+ inc_cxx_tests="$cached_inc_cxx_tests"
+ fi
+ if test -z "$inc_longrunning_tests"; then
+ inc_longrunning_tests="$cached_inc_longrunning_tests"
+ fi
+ if test -z "$inc_privileged_tests"; then
+ inc_privileged_tests="$cached_inc_privileged_tests"
+ fi
+ if test -z "$inc_unportable_tests"; then
+ inc_unportable_tests="$cached_inc_unportable_tests"
+ fi
+ if test -z "$inc_all_tests"; then
+ inc_all_tests="$cached_inc_all_tests"
+ fi
+ # Append the cached and the specified avoidlist. This is probably better
+ # than dropping the cached one when --avoid is specified at least once.
+ avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
+ avoidlist=`echo $avoidlist`
+
+ # The sourcebase defaults to the cached one.