# HG changeset patch # User Bruno Haible # Date 1283618343 -7200 # Node ID 8ae47cf4002f30e20a47a5e576c1d435ff0c9024 # Parent f4c566dd41a4ab5828220d5d18b4efd9592165e8 gnulib-tool: Change --import. New options --add/remove-import. * gnulib-tool: New options --add-import, --remove-import. (func_usage): Document them. (have_associative): Define always. (func_import): In import mode, don't merge the specified settings with the cached settings. Implement remove-import mode. * doc/gnulib-tool.texi (Modified imports): Mention the new options. Explain when to use them versus --import. (Simple update): Use --add-import instead of --import. * NEWS: Mention the change. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-09-04 Bruno Haible + + gnulib-tool: Change --import. New options --add/remove-import. + * gnulib-tool: New options --add-import, --remove-import. + (func_usage): Document them. + (have_associative): Define always. + (func_import): In import mode, don't merge the specified settings with + the cached settings. Implement remove-import mode. + * doc/gnulib-tool.texi (Modified imports): Mention the new options. + Explain when to use them versus --import. + (Simple update): Use --add-import instead of --import. + * NEWS: Mention the change. + 2010-09-04 Bruno Haible * doc/gnulib-tool.texi (Initial import): Update paragraph about diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ Important notes --------------- +2010-09-04 gnulib-tool The option '--import' is no longer cumulative; it + now expects the complete list of modules and other + options on the command line. If you want to + augment (not set) the list of modules, use the + new option '--add-import' instead of '--import'. + User visible incompatible changes --------------------------------- diff --git a/doc/gnulib-tool.texi b/doc/gnulib-tool.texi --- a/doc/gnulib-tool.texi +++ b/doc/gnulib-tool.texi @@ -302,30 +302,48 @@ You can at any moment decide to use Gnulib differently than the last time. -If you only want to use more Gnulib modules, simply invoke -@command{gnulib-tool --import @var{new-modules}}. @code{gnulib-tool} -remembers which modules were used last time. The list of modules that -you pass after @samp{--import} is @emph{added} to the previous list of -modules. +There are two ways to change how Gnulib is used. Which one you'll use, +depends on where you keep track of options and module names that you pass +to @code{gnulib-tool}. + +@itemize @bullet +@item +If you store the options and module names in a file under your own +control, such as @file{autogen.sh}, @file{bootstrap}, +@file{bootstrap.conf}, or similar, simply invoke @command{gnulib-tool} +again, with modified options and more or fewer module names. + +@item +@code{gnulib-tool} remembers which modules were used last time. If you +want to rely on @code{gnulib-tool}'s own memory of the last used +options and module names, you can use the commands +@command{gnulib-tool --add-import} and +@command{gnulib-tool --remove-import}. -For most changes, such as added or removed modules, or even different -choices of @samp{--lib}, @samp{--source-base} or @samp{--aux-dir}, there -are two ways to perform the change. +So, if you only want to use more Gnulib modules, simply invoke +@command{gnulib-tool --add-import @var{new-modules}}. The list of +modules that you pass after @samp{--add-import} is @emph{added} to the +previous list of modules. -The standard way is to modify manually the file @file{gnulib-cache.m4} -in the M4 macros directory, then launch @samp{gnulib-tool --import}. +Similarly, if you want to use fewer Gnulib modules, simply invoke +@command{gnulib-tool --remove-import @var{unneeded-modules}}. The list +of modules that you pass after @samp{--remove-import} is @emph{removed} +from the previous list of modules. Note that if a module is then still +needed as dependency of other modules, it will be used nevertheless. +If you want to @emph{really} not use a module any more, regardless of +whether other modules may need it, you need to use the @samp{--avoid} +option. -The other way is to call @command{gnulib-tool} again, with the changed -command-line options. Note that this doesn't let you remove modules, -because as you just learned, the list of modules is always cumulated. -Also this way is often impractical, because you don't remember the way -you invoked @code{gnulib-tool} last time. +For other changes, such as different choices of @samp{--lib}, +@samp{--source-base} or @samp{--aux-dir}, the normal way is to +modify manually the file @file{gnulib-cache.m4} in the M4 macros +directory, then launch @samp{gnulib-tool --add-import}. The only change for which this doesn't work is a change of the @samp{--m4-base} directory. Because, when you pass a different value of @samp{--m4-base}, @code{gnulib-tool} will not find the previous -@file{gnulib-cache.m4} file any more... A possible solution is to manually -copy the @file{gnulib-cache.m4} into the new M4 macro directory. +@file{gnulib-cache.m4} file any more... A possible solution is to +manually copy the @file{gnulib-cache.m4} into the new M4 macro directory. In the @file{gnulib-cache.m4}, the macros have the following meaning: @table @code @@ -372,6 +390,7 @@ file. Corresponds to the @samp{--macro-prefix} command line argument. @end table +@end itemize @node Simple update @section Simple update @@ -381,7 +400,7 @@ does it: @smallexample -$ gnulib-tool --import +$ gnulib-tool --add-import @end smallexample @noindent diff --git a/gnulib-tool b/gnulib-tool --- a/gnulib-tool +++ b/gnulib-tool @@ -127,6 +127,8 @@ Usage: gnulib-tool --list gnulib-tool --find filename gnulib-tool --import [module1 ... moduleN] + gnulib-tool --add-import [module1 ... moduleN] + gnulib-tool --remove-import [module1 ... moduleN] gnulib-tool --update gnulib-tool --create-testdir --dir=directory [module1 ... moduleN] gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN] @@ -151,9 +153,13 @@ Operation modes: --list print the available module names --find find the modules which contain the specified file - --import import the given modules into the current package; + --import import the given modules into the current package + --add-import augment the list of imports from gnulib into the + current package, by adding the given modules; if no modules are specified, update the current package from the current gnulib + --remove-import reduce the list of imports from gnulib into the + current package, by removing the given modules --update update the current package, restore files omitted from version control --create-testdir create a scratch package with the given modules @@ -861,7 +867,8 @@ # Command-line option processing. # Removes the OPTIONS from the arguments. Sets the variables: -# - mode list or import or create-testdir or create-megatestdir +# - mode list or import or add-import or remove-import or update +# or create-testdir or create-megatestdir # - destdir from --dir # - local_gnulib_dir from --local-dir # - modcache true or false, from --cache-modules/--no-cache-modules @@ -957,6 +964,12 @@ --import | --impor | --impo | --imp | --im | --i ) mode=import shift ;; + --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad ) + mode=add-import + shift ;; + --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r ) + mode=remove-import + shift ;; --update | --updat | --upda | --upd | --up | --u ) mode=update shift ;; @@ -1214,10 +1227,10 @@ esac done - if test "$mode" = import; then + if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \ || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then - echo "gnulib-tool: invalid options for 'import' mode" 1>&2 + echo "gnulib-tool: invalid options for '$mode' mode" 1>&2 echo "Try 'gnulib-tool --help' for more information." 1>&2 func_exit 1 fi @@ -1264,7 +1277,8 @@ DEFAULT_AUTOCONF_MINVERSION="2.59" autoconf_minversion= configure_ac= - if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then + if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \ + && test -n "$destdir"; then if test -f "$destdir"/configure.ac; then configure_ac="$destdir/configure.ac" else @@ -1350,6 +1364,15 @@ done signal=0 +# Note: The 'eval' silences stderr output in dash. +if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then + # Zsh 4 and Bash 4 have associative arrays. + have_associative=true +else + # For other shells, use 'eval' with computed shell variable names. + have_associative=false +fi + # func_lookup_file file # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through # 'patch'. @@ -1533,15 +1556,6 @@ if $modcache; then - # Note: The 'eval' silences stderr output in dash. - if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then - # Zsh 4 and Bash 4 have associative arrays. - have_associative=true - else - # For other shells, use 'eval' with computed shell variable names. - have_associative=false - fi - if $have_associative; then # Declare the associative arrays. @@ -3308,6 +3322,7 @@ # func_import modules # Uses also the variables +# - mode import or add-import or remove-import or update # - destdir target directory # - local_gnulib_dir from --local-dir # - modcache true or false, from --cache-modules/--no-cache-modules @@ -3351,6 +3366,8 @@ func_import () { # Get the cached settings. + # In 'import' mode, we read them only for the purpose of knowing the old + # installed file list, and don't use them as defaults. cached_local_gnulib_dir= cached_specified_modules= cached_incobsolete= @@ -3480,130 +3497,174 @@ fi fi - # Merge the cached settings with the specified ones. - # The m4base must be the same as expected from the pathname. - if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then - func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])" - fi - # 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 + if test "$mode" = import; then + # In 'import' mode, the new set of specified modules overrides the cached + # set of modules. Ignore the cached settings. + specified_modules="$1" + else + # Merge the cached settings with the specified ones. + # The m4base must be the same as expected from the pathname. + if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then + func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])" + fi + # 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 + to_remove[$m]=yes + done + for module in $cached_specified_modules; do + if 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 - 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" + 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. + if test -z "$sourcebase"; then + sourcebase="$cached_sourcebase" + if test -z "$sourcebase"; then + func_fatal_error "missing --source-base option" + fi + fi + # The pobase defaults to the cached one. + if test -z "$pobase"; then + pobase="$cached_pobase" + fi + # The docbase defaults to the cached one. + if test -z "$docbase"; then + docbase="$cached_docbase" + if test -z "$docbase"; then + func_fatal_error "missing --doc-base option. --doc-base has been introduced on 2006-07-11; if your last invocation of 'gnulib-tool --import' is before that date, you need to run 'gnulib-tool --import' once, with a --doc-base option." + fi + fi + # The testsbase defaults to the cached one. + if test -z "$testsbase"; then + testsbase="$cached_testsbase" + if test -z "$testsbase"; then + func_fatal_error "missing --tests-base option" + fi + fi + # Require the tests if specified either way. + if test -z "$inctests"; then + inctests="$cached_inctests" + fi + # The libname defaults to the cached one. + if test -z "$supplied_libname"; then + libname="$cached_libname" + if test -z "$libname"; then + func_fatal_error "missing --lib option" + fi + fi + # Require LGPL if specified either way. + if test -z "$lgpl"; then + lgpl="$cached_lgpl" + fi + # The makefile_name defaults to the cached one. + if test -z "$makefile_name"; then + makefile_name="$cached_makefile_name" + fi + # Use libtool if specified either way, or if guessed. + if test -z "$libtool"; then + if test -n "$cached_m4base"; then + libtool="$cached_libtool" + else + libtool="$guessed_libtool" + fi + fi + # The macro_prefix defaults to the cached one. + if test -z "$macro_prefix"; then + macro_prefix="$cached_macro_prefix" + if test -z "$macro_prefix"; then + func_fatal_error "missing --macro-prefix option" + fi + fi + # The po_domain defaults to the cached one. + if test -z "$po_domain"; then + po_domain="$cached_po_domain" + fi + # The vc_files defaults to the cached one. + if test -z "$vc_files"; then + vc_files="$cached_vc_files" + fi 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" - if test -z "$sourcebase"; then - func_fatal_error "missing --source-base option" - fi - fi - # The pobase defaults to the cached one. - if test -z "$pobase"; then - pobase="$cached_pobase" - fi - # The docbase defaults to the cached one. - if test -z "$docbase"; then - docbase="$cached_docbase" - if test -z "$docbase"; then - func_fatal_error "missing --doc-base option. --doc-base has been introduced on 2006-07-11; if your last invocation of 'gnulib-tool --import' is before that date, you need to run 'gnulib-tool --import' once, with a --doc-base option." - fi - fi - # The testsbase defaults to the cached one. - if test -z "$testsbase"; then - testsbase="$cached_testsbase" - if test -z "$testsbase"; then - func_fatal_error "missing --tests-base option" - fi - fi - # Require the tests if specified either way. - if test -z "$inctests"; then - inctests="$cached_inctests" - fi - # The libname defaults to the cached one. - if test -z "$supplied_libname"; then - libname="$cached_libname" - if test -z "$libname"; then - func_fatal_error "missing --lib option" - fi - fi - # Require LGPL if specified either way. - if test -z "$lgpl"; then - lgpl="$cached_lgpl" - fi - # The makefile_name defaults to the cached one. - if test -z "$makefile_name"; then - makefile_name="$cached_makefile_name" - fi - # Use libtool if specified either way, or if guessed. - if test -z "$libtool"; then - if test -n "$cached_m4base"; then - libtool="$cached_libtool" - else - libtool="$guessed_libtool" - fi - fi - # The macro_prefix defaults to the cached one. - if test -z "$macro_prefix"; then - macro_prefix="$cached_macro_prefix" - if test -z "$macro_prefix"; then - func_fatal_error "missing --macro-prefix option" - fi - fi - # The po_domain defaults to the cached one. - if test -z "$po_domain"; then - po_domain="$cached_po_domain" - fi - # The vc_files defaults to the cached one. - if test -z "$vc_files"; then - vc_files="$cached_vc_files" - fi # Canonicalize the list of specified modules. specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u` @@ -5429,7 +5490,7 @@ done ;; - import | update ) + import | add-import | remove-import | update ) # Where to import. if test -z "$destdir"; then @@ -5469,96 +5530,109 @@ fi # Determine where to apply func_import. - if test -n "$m4base"; then + if test "$mode" = import; then # Apply func_import to a particular gnulib directory. - # Any number of additional modules can be given. - if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then - # First use of gnulib in the given m4base. - test -n "$supplied_libname" || supplied_libname=true - test -n "$sourcebase" || sourcebase="lib" - test -n "$docbase" || docbase="doc" - test -n "$testsbase" || testsbase="tests" - test -n "$macro_prefix" || macro_prefix="gl" - fi + # The command line contains the complete specification; don't look at + # the contents of gnulib-cache.m4. + test -n "$supplied_libname" || supplied_libname=true + test -n "$sourcebase" || sourcebase="lib" + test -n "$m4base" || m4base="m4" + test -n "$docbase" || docbase="doc" + test -n "$testsbase" || testsbase="tests" + test -n "$macro_prefix" || macro_prefix="gl" func_import "$*" else - # Apply func_import to all gnulib directories. - # To get this list of directories, look at Makefile.am. (Not at - # configure, because it may be omitted from version control. Also, - # don't run "find $destdir -name gnulib-cache.m4", as it might be - # too expensive.) - m4dirs= - m4dirs_count=0 - if test -f "$destdir"/Makefile.am; then - aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am` - m4dir_is_next= - for arg in $aclocal_amflags; do - if test -n "$m4dir_is_next"; then - # Ignore absolute directory pathnames, like /usr/local/share/aclocal. - case "$arg" in - /*) ;; - *) - if test -f "$destdir/$arg"/gnulib-cache.m4; then - func_append m4dirs " $arg" - m4dirs_count=`expr $m4dirs_count + 1` - fi - ;; - esac - m4dir_is_next= - else - if test "X$arg" = "X-I"; then - m4dir_is_next=yes - else - m4dir_is_next= - fi - fi - done - else - # No Makefile.am! Oh well. Look at the last generated aclocal.m4. - if test -f "$destdir"/aclocal.m4; then - sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p' - sedexpr2='s,^[^/]*$,.,' - sedexpr3='s,/[^/]*$,,' - m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u` - m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done` - m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l` + if test -n "$m4base"; then + # Apply func_import to a particular gnulib directory. + # Any number of additional modules can be given. + if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then + # First use of gnulib in the given m4base. + test -n "$supplied_libname" || supplied_libname=true + test -n "$sourcebase" || sourcebase="lib" + test -n "$docbase" || docbase="doc" + test -n "$testsbase" || testsbase="tests" + test -n "$macro_prefix" || macro_prefix="gl" fi - fi - if test $m4dirs_count = 0; then - # First use of gnulib in a package. - # Any number of additional modules can be given. - test -n "$supplied_libname" || supplied_libname=true - test -n "$sourcebase" || sourcebase="lib" - m4base="m4" - test -n "$docbase" || docbase="doc" - test -n "$testsbase" || testsbase="tests" - test -n "$macro_prefix" || macro_prefix="gl" func_import "$*" else - if test $m4dirs_count = 1; then - # There's only one use of gnulib here. Assume the user means it. - # Any number of additional modules can be given. - for m4base in $m4dirs; do - func_import "$*" + # Apply func_import to all gnulib directories. + # To get this list of directories, look at Makefile.am. (Not at + # configure, because it may be omitted from version control. Also, + # don't run "find $destdir -name gnulib-cache.m4", as it might be + # too expensive.) + m4dirs= + m4dirs_count=0 + if test -f "$destdir"/Makefile.am; then + aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am` + m4dir_is_next= + for arg in $aclocal_amflags; do + if test -n "$m4dir_is_next"; then + # Ignore absolute directory pathnames, like /usr/local/share/aclocal. + case "$arg" in + /*) ;; + *) + if test -f "$destdir/$arg"/gnulib-cache.m4; then + func_append m4dirs " $arg" + m4dirs_count=`expr $m4dirs_count + 1` + fi + ;; + esac + m4dir_is_next= + else + if test "X$arg" = "X-I"; then + m4dir_is_next=yes + else + m4dir_is_next= + fi + fi done else - # Ambiguous - guess what the user meant. - if test $# = 0; then - # No further arguments. Guess the user wants to update all of them. + # No Makefile.am! Oh well. Look at the last generated aclocal.m4. + if test -f "$destdir"/aclocal.m4; then + sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p' + sedexpr2='s,^[^/]*$,.,' + sedexpr3='s,/[^/]*$,,' + m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u` + m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done` + m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l` + fi + fi + if test $m4dirs_count = 0; then + # First use of gnulib in a package. + # Any number of additional modules can be given. + test -n "$supplied_libname" || supplied_libname=true + test -n "$sourcebase" || sourcebase="lib" + m4base="m4" + test -n "$docbase" || docbase="doc" + test -n "$testsbase" || testsbase="tests" + test -n "$macro_prefix" || macro_prefix="gl" + func_import "$*" + else + if test $m4dirs_count = 1; then + # There's only one use of gnulib here. Assume the user means it. + # Any number of additional modules can be given. for m4base in $m4dirs; do - # Perform func_import in a subshell, so that variable values - # such as - # local_gnulib_dir, incobsolete, inc_cxx_tests, - # inc_longrunning_tests, inc_privileged_tests, - # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase, - # m4base, pobase, docbase, testsbase, inctests, libname, lgpl, - # makefile_name, libtool, macro_prefix, po_domain, vc_files - # don't propagate from one directory to another. - (func_import) || func_exit 1 + func_import "$*" done else - # Really ambiguous. - func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..." + # Ambiguous - guess what the user meant. + if test $# = 0; then + # No further arguments. Guess the user wants to update all of them. + for m4base in $m4dirs; do + # Perform func_import in a subshell, so that variable values + # such as + # local_gnulib_dir, incobsolete, inc_cxx_tests, + # inc_longrunning_tests, inc_privileged_tests, + # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase, + # m4base, pobase, docbase, testsbase, inctests, libname, lgpl, + # makefile_name, libtool, macro_prefix, po_domain, vc_files + # don't propagate from one directory to another. + (func_import) || func_exit 1 + done + else + # Really ambiguous. + func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..." + fi fi fi fi