readme-release: new module with release instructions
[gnulib.git] / gnulib-tool
index 3cf697f..65ecefd 100755 (executable)
@@ -123,24 +123,12 @@ fi
 # outputs to stdout the --help usage message.
 func_usage ()
 {
-  # This use of bold display can be removed on 2011-01-01.
-  if case "$TERM" in
-       xterm*) test -t 1;;
-       *) false;;
-     esac; then
-    # Assume xterm compatible escape sequences.
-    bold_on=`printf '\x1b[1m'`
-    bold_off=`printf '\x1b[0m'`
-  else
-    bold_on=
-    bold_off=
-  fi
   echo "\
 Usage: gnulib-tool --list
-       gnulib-tool --find filename${bold_on}
+       gnulib-tool --find filename
        gnulib-tool --import [module1 ... moduleN]
        gnulib-tool --add-import [module1 ... moduleN]
-       gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
+       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]
@@ -165,14 +153,14 @@ Usage: gnulib-tool --list
 Operation modes:
 
       --list                print the available module names
-      --find                find the modules which contain the specified file${bold_on}
+      --find                find the modules which contain the specified file
       --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${bold_off}
+                            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
@@ -2534,7 +2522,7 @@ func_show_module_list ()
   echo "Module list with included dependencies (indented):"
   echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
   echo "$modules" | sed -e '/^$/d' \
-    | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
+    | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
     | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/    /' -e 's/^    |\(.*\)$/  '"${bold_on}"'\1'"${bold_off}"'/'
 }
 
@@ -3372,6 +3360,88 @@ func_emit_initmacro_done ()
   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"
+  for module in $1; do
+    eval $verifier # one of func_verify_module, func_verify_nontests_module, func_verify_tests_module.
+    if test -n "$module"; then
+      func_emit_autoconf_snippet "  "
+    fi
+  done
+}
+
 # func_import modules
 # Uses also the variables
 # - mode            import or add-import or remove-import or update
@@ -4553,22 +4623,7 @@ s,//*$,/,'
     echo "  gl_m4_base='$m4base'"
     func_emit_initmacro_start $macro_prefix
     echo "  gl_source_base='$sourcebase'"
-    for module in $main_modules; do
-      func_verify_module
-      if test -n "$module"; then
-        echo "  # Code from module $module:"
-        func_get_autoconf_snippet "$module" \
-          | sed -e '/^$/d;' -e 's/^/  /' \
-                -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
-                -e "$sed_replace_build_aux"
-        if test "$module" = 'alloca' && test "$libtool" = true; then
-          echo 'changequote(,)dnl'
-          echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
-          echo 'changequote([, ])dnl'
-          echo 'AC_SUBST([LTALLOCA])'
-        fi
-      fi
-    done
+    func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
     echo "  # End of code from modules"
     func_emit_initmacro_end $macro_prefix
     echo "  gltests_libdeps="
@@ -4584,18 +4639,7 @@ s,//*$,/,'
     echo "  AC_SUBST([${macro_prefix}tests_WITNESS])"
     echo "  gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
     echo "  m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
-    for module in $testsrelated_modules; do
-      func_verify_module
-      if test -n "$module"; then
-        func_get_autoconf_snippet "$module" \
-          | sed -e '/^$/d;' -e 's/^/  /' \
-                -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
-                -e "$sed_replace_build_aux" \
-                -e 's/\$gl_cond_libtool/false/g' \
-                -e 's/gl_libdeps/gltests_libdeps/g' \
-                -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
-      fi
-    done
+    func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
     echo "  m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
     func_emit_initmacro_end ${macro_prefix}tests
     # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
@@ -5148,34 +5192,9 @@ func_create_testdir ()
      # autoconf snippets. It's cleanest to put those of the library before
      # those of the tests.
      echo "gl_source_base='../$sourcebase'"
-     for module in $modules; do
-       func_verify_nontests_module
-       if test -n "$module"; then
-         case $module in
-           gnumakefile | maintainer-makefile)
-             # These modules are meant to be used only in the top-level directory.
-             ;;
-           *)
-             func_get_autoconf_snippet "$module" \
-               | sed -e "$sed_replace_build_aux"
-             if test "$module" = 'alloca' && test "$libtool" = true; then
-               echo 'changequote(,)dnl'
-               echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
-               echo 'changequote([, ])dnl'
-               echo 'AC_SUBST([LTALLOCA])'
-             fi
-             ;;
-         esac
-       fi
-     done
+     func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
      echo "gl_source_base='.'"
-     for module in $modules; do
-       func_verify_tests_module
-       if test -n "$module"; then
-         func_get_autoconf_snippet "$module" \
-           | sed -e "$sed_replace_build_aux"
-       fi
-     done
+     func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
      func_emit_initmacro_end $macro_prefix
      # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
      # created using libtool, because libtool already handles the dependencies.
@@ -5281,19 +5300,7 @@ func_create_testdir ()
    echo "gl_m4_base='$m4base'"
    func_emit_initmacro_start $macro_prefix
    echo "gl_source_base='$sourcebase'"
-   for module in $modules; do
-     func_verify_nontests_module
-     if test -n "$module"; then
-       func_get_autoconf_snippet "$module" \
-         | sed -e "$sed_replace_build_aux"
-       if test "$module" = 'alloca' && test "$libtool" = true; then
-         echo 'changequote(,)dnl'
-         echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
-         echo 'changequote([, ])dnl'
-         echo 'AC_SUBST([LTALLOCA])'
-       fi
-     fi
-   done
+   func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
    func_emit_initmacro_end $macro_prefix
    # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
    # created using libtool, because libtool already handles the dependencies.