2 # Convenience script for regenerating all autogeneratable files that are
3 # omitted from the version control repository. In particular, this script
4 # also regenerates all aclocal.m4, config.h.in, Makefile.in, configure files
5 # with new versions of autoconf or automake.
7 # This script requires autoconf-2.62..2.69 and automake-1.11.1..1.12 in the
9 # It also requires either
10 # - the git program in the PATH and an internet connection, or
11 # - the GNULIB_TOOL environment variable pointing to the gnulib-tool script
12 # in a gnulib checkout
13 # The former method is tried first and if it fails, fallback to the
14 # latter. When git is used, the GNULIB_SRCDIR environment variable is
15 # also checked as a reference of gnulib checkout.
18 # - the bison program,
19 # - the gperf program,
20 # - the groff program,
21 # - the makeinfo program from the texinfo package,
24 # Copyright (C) 2003-2012 Free Software Foundation, Inc.
26 # This program is free software: you can redistribute it and/or modify
27 # it under the terms of the GNU General Public License as published by
28 # the Free Software Foundation; either version 3 of the License, or
29 # (at your option) any later version.
31 # This program is distributed in the hope that it will be useful,
32 # but WITHOUT ANY WARRANTY; without even the implied warranty of
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 # GNU General Public License for more details.
36 # You should have received a copy of the GNU General Public License
37 # along with this program. If not, see <http://www.gnu.org/licenses/>.
39 # Usage: ./autogen.sh [--quick] [--skip-gnulib]
41 # Usage after a first-time git clone / cvs checkout: ./autogen.sh
42 # Usage after a git clone / cvs update: ./autogen.sh --quick
43 # This uses an up-to-date gnulib checkout.
44 # (The gettext-0.18.3 release was prepared using gnulib commit
45 # c96bab3fee48a9df55e7366344f838e1fc785c28 from 2013-07-07.)
47 # Usage from a released tarball: ./autogen.sh --quick --skip-gnulib
48 # This does not use a gnulib checkout.
54 --quick) quick=true; shift;;
55 --skip-gnulib) skip_gnulib=true; shift;;
66 git_modules_config () {
67 test -f .gitmodules && git config --file .gitmodules "$@"
70 gnulib_path=$(git_modules_config submodule.gnulib.path)
71 test -z "$gnulib_path" && gnulib_path=gnulib
73 # The tests in gettext-tools/tests are not meant to be executable, because
74 # they have a TESTS_ENVIRONMENT that specifies the shell explicitly.
76 if ! $skip_gnulib; then
78 case ${GNULIB_SRCDIR--} in
80 if git_modules_config submodule.gnulib.url >/dev/null; then
81 echo "$0: getting gnulib files..."
82 git submodule init || exit $?
83 git submodule update || exit $?
85 elif [ ! -d "$gnulib_path" ]; then
86 echo "$0: getting gnulib files..."
88 trap cleanup_gnulib 1 2 13 15
91 git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
92 git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
97 GNULIB_SRCDIR=$gnulib_path
100 # Use GNULIB_SRCDIR as a reference.
101 if test -d "$GNULIB_SRCDIR"/.git && \
102 git_modules_config submodule.gnulib.url >/dev/null; then
103 echo "$0: getting gnulib files..."
104 if git submodule -h|grep -- --reference > /dev/null; then
105 # Prefer the one-liner available in git 1.6.4 or newer.
106 git submodule update --init --reference "$GNULIB_SRCDIR" \
107 "$gnulib_path" || exit $?
109 # This fallback allows at least git 1.5.5.
110 if test -f "$gnulib_path"/gnulib-tool; then
111 # Since file already exists, assume submodule init already complete.
112 git submodule update || exit $?
114 # Older git can't clone into an empty directory.
115 rmdir "$gnulib_path" 2>/dev/null
116 git clone --reference "$GNULIB_SRCDIR" \
117 "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
118 && git submodule init && git submodule update \
122 GNULIB_SRCDIR=$gnulib_path
126 # Now it should contain a gnulib-tool.
127 if test -f "$GNULIB_SRCDIR"/gnulib-tool; then
128 GNULIB_TOOL="$GNULIB_SRCDIR"/gnulib-tool
130 echo "** warning: gnulib-tool not found" 1>&2
132 # Skip the gnulib-tool step if gnulib-tool was not found.
133 if test -n "$GNULIB_TOOL"; then
134 # In gettext-runtime:
135 GNULIB_MODULES_RUNTIME_FOR_SRC='
156 GNULIB_MODULES_RUNTIME_OTHER='
163 $GNULIB_TOOL --dir=gettext-runtime --lib=libgrt --source-base=gnulib-lib --m4-base=gnulib-m4 --no-libtool --local-dir=gnulib-local --local-symlink \
164 --import $GNULIB_MODULES_RUNTIME_FOR_SRC $GNULIB_MODULES_RUNTIME_OTHER
165 # In gettext-runtime/libasprintf:
166 GNULIB_MODULES_LIBASPRINTF='
172 GNULIB_MODULES_LIBASPRINTF_OTHER='
174 $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 \
175 --import $GNULIB_MODULES_LIBASPRINTF $GNULIB_MODULES_LIBASPRINTF_OTHER
176 $GNULIB_TOOL --copy-file m4/intmax_t.m4 gettext-runtime/libasprintf/gnulib-m4/intmax_t.m4
178 GNULIB_MODULES_TOOLS_FOR_SRC='
217 libunistring-optional
256 unilbrk/ulc-width-linebreaks
277 # Common dependencies of GNULIB_MODULES_TOOLS_FOR_SRC and GNULIB_MODULES_TOOLS_FOR_LIBGREP.
278 GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES='
303 GNULIB_MODULES_TOOLS_OTHER='
314 GNULIB_MODULES_TOOLS_LIBUNISTRING_TESTS='
315 unilbrk/u8-possible-linebreaks-tests
316 unilbrk/ulc-width-linebreaks-tests
317 unistr/u8-mbtouc-tests
318 unistr/u8-mbtouc-unsafe-tests
321 $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 \
322 --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
323 # In gettext-tools/libgrep:
324 GNULIB_MODULES_TOOLS_FOR_LIBGREP='
328 $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 \
329 --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
330 # In gettext-tools/libgettextpo:
331 # This is a subset of the GNULIB_MODULES_FOR_SRC.
332 GNULIB_MODULES_LIBGETTEXTPO='
350 libunistring-optional
362 unilbrk/ulc-width-linebreaks
377 GNULIB_MODULES_LIBGETTEXTPO_OTHER='
379 $GNULIB_TOOL --dir=gettext-tools --source-base=libgettextpo --m4-base=libgettextpo/gnulib-m4 --macro-prefix=gtpo --makefile-name=Makefile.gnulib --libtool --local-dir=gnulib-local --local-symlink \
380 --import $GNULIB_MODULES_LIBGETTEXTPO $GNULIB_MODULES_LIBGETTEXTPO_OTHER
384 # Fetch config.guess, config.sub.
385 if test -n "$GNULIB_TOOL"; then
386 for file in config.guess config.sub; do
387 $GNULIB_TOOL --copy-file build-aux/$file; chmod a+x build-aux/$file
390 for file in config.guess config.sub; do
391 wget -q --timeout=5 -O build-aux/$file.tmp "http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/${file};hb=HEAD" \
392 && mv build-aux/$file.tmp build-aux/$file \
393 && chmod a+x build-aux/$file
397 (cd gettext-runtime/libasprintf
398 aclocal -I ../../m4 -I ../m4 -I gnulib-m4
400 autoheader && touch config.h.in
401 automake --add-missing --copy
405 aclocal -I m4 -I ../m4 -I gnulib-m4
407 autoheader && touch config.h.in
408 automake --add-missing --copy
409 # Rebuilding the PO files and manual pages is only rarely needed.
411 ./configure --disable-java --disable-native-java --disable-csharp \
412 && (cd po && make update-po) \
413 && (cd intl && make) && (cd gnulib-lib && make) && (cd src && make) \
414 && (cd man && make update-man1 all) \
419 cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS
421 (cd gettext-tools/examples
422 aclocal -I ../../gettext-runtime/m4 -I ../../m4
424 automake --add-missing --copy
425 # Rebuilding the examples PO files is only rarely needed.
427 ./configure && (cd po && make update-po) && make distclean
432 aclocal -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
434 autoheader && touch config.h.in
435 test -d intl || mkdir intl
436 automake --add-missing --copy
437 # Rebuilding the PO files, manual pages, documentation, test files is only rarely needed.
439 ./configure --disable-java --disable-native-java --disable-csharp --disable-openmp \
440 && (cd po && make update-po) \
441 && (cd intl && make) && (cd gnulib-lib && make) && (cd libgrep && make) && (cd src && make) \
442 && (cd man && make update-man1 all) \
443 && (cd doc && make all) \
444 && (cd tests && make update-expected) \
447 if ! test -f misc/archive.dir.tar; then
448 wget -q --timeout=5 -O - ftp://alpha.gnu.org/gnu/gettext/archive.dir-latest.tar.gz | gzip -d -c > misc/archive.dir.tar-t \
449 && mv misc/archive.dir.tar-t misc/archive.dir.tar