Fix RPMLINT
[platform/upstream/gettext.git] / autogen.sh
index 85bdbea..a1033b6 100755 (executable)
@@ -4,11 +4,16 @@
 # also regenerates all aclocal.m4, config.h.in, Makefile.in, configure files
 # with new versions of autoconf or automake.
 #
-# This script requires autoconf-2.60..2.65 and automake-1.11.1 in the PATH.
+# This script requires autoconf-2.62..2.69 and automake-1.11.1..1.12 in the
+# PATH.
 # It also requires either
+#   - the git program in the PATH and an internet connection, or
 #   - the GNULIB_TOOL environment variable pointing to the gnulib-tool script
-#     in a gnulib checkout, or
-#   - the git program in the PATH and an internet connection.
+#     in a gnulib checkout
+# The former method is tried first and if it fails, fallback to the
+# latter.  When git is used, the GNULIB_SRCDIR environment variable is
+# also checked as a reference of gnulib checkout.
+
 # It also requires
 #   - the bison program,
 #   - the gperf program,
@@ -16,7 +21,7 @@
 #   - the makeinfo program from the texinfo package,
 #   - perl.
 
-# Copyright (C) 2003-2010 Free Software Foundation, Inc.
+# Copyright (C) 2003-2012 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -36,8 +41,8 @@
 # Usage after a first-time git clone / cvs checkout:   ./autogen.sh
 # Usage after a git clone / cvs update:                ./autogen.sh --quick
 # This uses an up-to-date gnulib checkout.
-# (The gettext-0.18.1 release was prepared using gnulib commit
-# 74d509383fe30bb5511a978b52e4f8ecae37826b from 2010-06-03.)
+# (The gettext-0.18.3 release was prepared using gnulib commit
+# c96bab3fee48a9df55e7366344f838e1fc785c28 from 2013-07-07.)
 #
 # Usage from a released tarball:             ./autogen.sh --quick --skip-gnulib
 # This does not use a gnulib checkout.
@@ -52,30 +57,81 @@ while :; do
   esac
 done
 
+cleanup_gnulib() {
+  status=$?
+  rm -fr "$gnulib_path"
+  exit $status
+}
+
+git_modules_config () {
+  test -f .gitmodules && git config --file .gitmodules "$@"
+}
+
+gnulib_path=$(git_modules_config submodule.gnulib.path)
+test -z "$gnulib_path" && gnulib_path=gnulib
+
 # The tests in gettext-tools/tests are not meant to be executable, because
 # they have a TESTS_ENVIRONMENT that specifies the shell explicitly.
 
 if ! $skip_gnulib; then
-  if test -z "$GNULIB_TOOL"; then
-    # Check out gnulib in a subdirectory 'gnulib'.
-    if test -d gnulib; then
-      (cd gnulib && git pull)
-    else
-      git clone git://git.savannah.gnu.org/gnulib.git
+  # Get gnulib files.
+  case ${GNULIB_SRCDIR--} in
+  -)
+    if git_modules_config submodule.gnulib.url >/dev/null; then
+      echo "$0: getting gnulib files..."
+      git submodule init || exit $?
+      git submodule update || exit $?
+
+    elif [ ! -d "$gnulib_path" ]; then
+      echo "$0: getting gnulib files..."
+
+      trap cleanup_gnulib 1 2 13 15
+
+      shallow=
+      git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
+      git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
+        cleanup_gnulib
+
+      trap - 1 2 13 15
     fi
-    # Now it should contain a gnulib-tool.
-    if test -f gnulib/gnulib-tool; then
-      GNULIB_TOOL=`pwd`/gnulib/gnulib-tool
-    else
-      echo "** warning: gnulib-tool not found" 1>&2
+    GNULIB_SRCDIR=$gnulib_path
+    ;;
+  *)
+    # Use GNULIB_SRCDIR as a reference.
+    if test -d "$GNULIB_SRCDIR"/.git && \
+          git_modules_config submodule.gnulib.url >/dev/null; then
+      echo "$0: getting gnulib files..."
+      if git submodule -h|grep -- --reference > /dev/null; then
+        # Prefer the one-liner available in git 1.6.4 or newer.
+        git submodule update --init --reference "$GNULIB_SRCDIR" \
+          "$gnulib_path" || exit $?
+      else
+        # This fallback allows at least git 1.5.5.
+        if test -f "$gnulib_path"/gnulib-tool; then
+          # Since file already exists, assume submodule init already complete.
+          git submodule update || exit $?
+        else
+          # Older git can't clone into an empty directory.
+          rmdir "$gnulib_path" 2>/dev/null
+          git clone --reference "$GNULIB_SRCDIR" \
+            "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
+            && git submodule init && git submodule update \
+            || exit $?
+        fi
+      fi
+      GNULIB_SRCDIR=$gnulib_path
     fi
+    ;;
+  esac
+  # Now it should contain a gnulib-tool.
+  if test -f "$GNULIB_SRCDIR"/gnulib-tool; then
+    GNULIB_TOOL="$GNULIB_SRCDIR"/gnulib-tool
+  else
+    echo "** warning: gnulib-tool not found" 1>&2
   fi
   # Skip the gnulib-tool step if gnulib-tool was not found.
   if test -n "$GNULIB_TOOL"; then
     # In gettext-runtime:
-    if test -f gettext-runtime/gnulib-m4/gnulib-cache.m4; then
-      mv -f gettext-runtime/gnulib-m4/gnulib-cache.m4 gettext-runtime/gnulib-m4/gnulib-cache.m4~
-    fi
     GNULIB_MODULES_RUNTIME_FOR_SRC='
       atexit
       basename
@@ -88,6 +144,7 @@ if ! $skip_gnulib; then
       progname
       propername
       relocatable-prog
+      setlocale
       sigpipe
       stdbool
       stdio
@@ -98,6 +155,7 @@ if ! $skip_gnulib; then
     '
     GNULIB_MODULES_RUNTIME_OTHER='
       gettext-runtime-misc
+      ansi-c++-opt
       csharpcomp-script
       java
       javacomp-script
@@ -105,21 +163,18 @@ if ! $skip_gnulib; then
     $GNULIB_TOOL --dir=gettext-runtime --lib=libgrt --source-base=gnulib-lib --m4-base=gnulib-m4 --no-libtool --local-dir=gnulib-local --local-symlink \
       --import $GNULIB_MODULES_RUNTIME_FOR_SRC $GNULIB_MODULES_RUNTIME_OTHER
     # In gettext-runtime/libasprintf:
-    if test -f gettext-runtime/libasprintf/gnulib-m4/gnulib-cache.m4; then
-      mv -f gettext-runtime/libasprintf/gnulib-m4/gnulib-cache.m4 gettext-runtime/libasprintf/gnulib-m4/gnulib-cache.m4~
-    fi
     GNULIB_MODULES_LIBASPRINTF='
       alloca
       errno
+      verify
+      xsize
     '
     GNULIB_MODULES_LIBASPRINTF_OTHER='
     '
     $GNULIB_TOOL --dir=gettext-runtime/libasprintf --source-base=. --m4-base=gnulib-m4 --lgpl=2 --makefile-name=Makefile.gnulib --libtool --local-dir=gnulib-local --local-symlink \
       --import $GNULIB_MODULES_LIBASPRINTF $GNULIB_MODULES_LIBASPRINTF_OTHER
+    $GNULIB_TOOL --copy-file m4/intmax_t.m4 gettext-runtime/libasprintf/gnulib-m4/intmax_t.m4
     # In gettext-tools:
-    if test -f gettext-tools/gnulib-m4/gnulib-cache.m4; then
-      mv -f gettext-tools/gnulib-m4/gnulib-cache.m4 gettext-tools/gnulib-m4/gnulib-cache.m4~
-    fi
     GNULIB_MODULES_TOOLS_FOR_SRC='
       alloca-opt
       atexit
@@ -133,6 +188,7 @@ if ! $skip_gnulib; then
       c-strcasestr
       c-strstr
       clean-temp
+      closedir
       closeout
       copy-file
       csharpcomp
@@ -168,17 +224,20 @@ if ! $skip_gnulib; then
       minmax
       obstack
       open
+      opendir
       openmp
       ostream
-      pipe
       pipe-filter-ii
       progname
       propername
+      readdir
       relocatable-prog
       relocatable-script
+      setlocale
       sh-quote
       sigpipe
       sigprocmask
+      spawn-pipe
       stdbool
       stdio
       stdlib
@@ -198,6 +257,7 @@ if ! $skip_gnulib; then
       uniname/uniname
       unistd
       unistr/u8-mbtouc
+      unistr/u8-mbtoucr
       unistr/u8-uctomb
       unistr/u16-mbtouc
       uniwidth/width
@@ -217,16 +277,18 @@ if ! $skip_gnulib; then
     # Common dependencies of GNULIB_MODULES_TOOLS_FOR_SRC and GNULIB_MODULES_TOOLS_FOR_LIBGREP.
     GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES='
       alloca-opt
-      arg-nonnull
-      c++defs
       extensions
       gettext-h
       include_next
+      locale
       localcharset
       malloc-posix
       mbrtowc
       mbsinit
       multiarch
+      snippet/arg-nonnull
+      snippet/c++defs
+      snippet/warn-on-use
       ssize_t
       stdbool
       stddef
@@ -235,12 +297,12 @@ if ! $skip_gnulib; then
       streq
       unistd
       verify
-      warn-on-use
       wchar
-      wctype
+      wctype-h
     '
     GNULIB_MODULES_TOOLS_OTHER='
       gettext-tools-misc
+      ansi-c++-opt
       csharpcomp-script
       csharpexec-script
       gcj
@@ -249,24 +311,27 @@ if ! $skip_gnulib; then
       javaexec-script
       stdint
     '
+    GNULIB_MODULES_TOOLS_LIBUNISTRING_TESTS='
+      unilbrk/u8-possible-linebreaks-tests
+      unilbrk/ulc-width-linebreaks-tests
+      unistr/u8-mbtouc-tests
+      unistr/u8-mbtouc-unsafe-tests
+      uniwidth/width-tests
+    '
     $GNULIB_TOOL --dir=gettext-tools --lib=libgettextlib --source-base=gnulib-lib --m4-base=gnulib-m4 --tests-base=gnulib-tests --makefile-name=Makefile.gnulib --libtool --with-tests --local-dir=gnulib-local --local-symlink \
-      --import --avoid=hash-tests $GNULIB_MODULES_TOOLS_FOR_SRC $GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES $GNULIB_MODULES_TOOLS_OTHER
+      --import --avoid=hash-tests `for m in $GNULIB_MODULES_TOOLS_LIBUNISTRING_TESTS; do echo --avoid=$m; done` $GNULIB_MODULES_TOOLS_FOR_SRC $GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES $GNULIB_MODULES_TOOLS_OTHER
     # In gettext-tools/libgrep:
-    if test -f gettext-tools/libgrep/gnulib-m4/gnulib-cache.m4; then
-      mv -f gettext-tools/libgrep/gnulib-m4/gnulib-cache.m4 gettext-tools/libgrep/gnulib-m4/gnulib-cache.m4~
-    fi
     GNULIB_MODULES_TOOLS_FOR_LIBGREP='
+      mbrlen
       regex
     '
-    $GNULIB_TOOL --dir=gettext-tools --macro-prefix=grgl --lib=libgrep --source-base=libgrep --m4-base=libgrep/gnulib-m4 --makefile-name=Makefile.gnulib --local-dir=gnulib-local --local-symlink \
+    $GNULIB_TOOL --dir=gettext-tools --macro-prefix=grgl --lib=libgrep --source-base=libgrep --m4-base=libgrep/gnulib-m4 --witness-c-macro=IN_GETTEXT_TOOLS_LIBGREP --makefile-name=Makefile.gnulib --local-dir=gnulib-local --local-symlink \
       --import `for m in $GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES; do if test \`$GNULIB_TOOL --extract-applicability $m\` != all; then echo --avoid=$m; fi; done` $GNULIB_MODULES_TOOLS_FOR_LIBGREP
     # In gettext-tools/libgettextpo:
-    if test -f gettext-tools/libgettextpo/gnulib-m4/gnulib-cache.m4; then
-      mv -f gettext-tools/libgettextpo/gnulib-m4/gnulib-cache.m4 gettext-tools/libgettextpo/gnulib-m4/gnulib-cache.m4~
-    fi
     # This is a subset of the GNULIB_MODULES_FOR_SRC.
     GNULIB_MODULES_LIBGETTEXTPO='
       basename
+      close
       c-ctype
       c-strcase
       c-strstr
@@ -292,9 +357,11 @@ if ! $skip_gnulib; then
       stdbool
       stdio
       stdlib
+      strchrnul
       strerror
       unilbrk/ulc-width-linebreaks
       unistr/u8-mbtouc
+      unistr/u8-mbtoucr
       unistr/u8-uctomb
       unistr/u16-mbtouc
       uniwidth/width
@@ -328,14 +395,14 @@ else
 fi
 
 (cd gettext-runtime/libasprintf
../../build-aux/fixaclocal aclocal -I ../../m4 -I ../m4 -I gnulib-m4
+ aclocal -I ../../m4 -I ../m4 -I gnulib-m4
  autoconf
  autoheader && touch config.h.in
  automake --add-missing --copy
 )
 
 (cd gettext-runtime
../build-aux/fixaclocal aclocal -I m4 -I ../m4 -I gnulib-m4
+ aclocal -I m4 -I ../m4 -I gnulib-m4
  autoconf
  autoheader && touch config.h.in
  automake --add-missing --copy
@@ -352,7 +419,7 @@ fi
 cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS
 
 (cd gettext-tools/examples
../../build-aux/fixaclocal aclocal -I ../../gettext-runtime/m4 -I ../../m4
+ aclocal -I ../../gettext-runtime/m4 -I ../../m4
  autoconf
  automake --add-missing --copy
  # Rebuilding the examples PO files is only rarely needed.
@@ -362,7 +429,7 @@ cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS
 )
 
 (cd gettext-tools
../build-aux/fixaclocal aclocal -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
+ aclocal -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
  autoconf
  autoheader && touch config.h.in
  test -d intl || mkdir intl
@@ -377,8 +444,12 @@ cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS
      && (cd tests && make update-expected) \
      && make distclean
  fi
+ if ! test -f misc/archive.dir.tar; then
+   wget -q --timeout=5 -O - ftp://alpha.gnu.org/gnu/gettext/archive.dir-latest.tar.gz | gzip -d -c > misc/archive.dir.tar-t \
+     && mv misc/archive.dir.tar-t misc/archive.dir.tar
+ fi
 )
 
-build-aux/fixaclocal aclocal -I m4
+aclocal -I m4
 autoconf
 automake