2 # Copyright (C) 2003-2015 Free Software Foundation, Inc.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This script populates the build infrastructure in the source tree
18 # checked-out from VCS.
20 # This script requires:
27 # By default, it fetches Gnulib as a git submodule. If you already
28 # have a local copy of Gnulib, you can avoid extra network traffic by
29 # setting the GNULIB_SRCDIR environment variable pointing to the path.
31 # In addition, it fetches the archive.dir.tar.gz file, which contains
32 # data files used by the autopoint program. If you already have the
33 # file, place it under gettext-tools/misc, before running this script.
35 # Usage: ./autogen.sh [--skip-gnulib]
37 # Usage after a git clone: ./autogen.sh
38 # Usage from a released tarball: ./autogen.sh --skip-gnulib
39 # This does not use a gnulib checkout.
42 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
47 --skip-gnulib) skip_gnulib=true; shift;;
58 git_modules_config () {
59 test -f .gitmodules && git config --file .gitmodules "$@"
62 gnulib_path=$(git_modules_config submodule.gnulib.path)
63 test -z "$gnulib_path" && gnulib_path=gnulib
65 # The tests in gettext-tools/tests are not meant to be executable, because
66 # they have a TESTS_ENVIRONMENT that specifies the shell explicitly.
68 if ! $skip_gnulib; then
70 case ${GNULIB_SRCDIR--} in
72 if git_modules_config submodule.gnulib.url >/dev/null; then
73 echo "$0: getting gnulib files..."
74 git submodule init || exit $?
75 git submodule update || exit $?
77 elif [ ! -d "$gnulib_path" ]; then
78 echo "$0: getting gnulib files..."
80 trap cleanup_gnulib 1 2 13 15
83 git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
84 git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
89 GNULIB_SRCDIR=$gnulib_path
92 # Use GNULIB_SRCDIR as a reference.
93 if test -d "$GNULIB_SRCDIR"/.git && \
94 git_modules_config submodule.gnulib.url >/dev/null; then
95 echo "$0: getting gnulib files..."
96 if git submodule -h|grep -- --reference > /dev/null; then
97 # Prefer the one-liner available in git 1.6.4 or newer.
98 git submodule update --init --reference "$GNULIB_SRCDIR" \
99 "$gnulib_path" || exit $?
101 # This fallback allows at least git 1.5.5.
102 if test -f "$gnulib_path"/gnulib-tool; then
103 # Since file already exists, assume submodule init already complete.
104 git submodule update || exit $?
106 # Older git can't clone into an empty directory.
107 rmdir "$gnulib_path" 2>/dev/null
108 git clone --reference "$GNULIB_SRCDIR" \
109 "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
110 && git submodule init && git submodule update \
114 GNULIB_SRCDIR=$gnulib_path
118 # Now it should contain a gnulib-tool.
119 if test -f "$GNULIB_SRCDIR"/gnulib-tool; then
120 GNULIB_TOOL="$GNULIB_SRCDIR"/gnulib-tool
122 echo "** warning: gnulib-tool not found" 1>&2
124 # Skip the gnulib-tool step if gnulib-tool was not found.
125 if test -n "$GNULIB_TOOL"; then
126 # In gettext-runtime:
127 GNULIB_MODULES_RUNTIME_FOR_SRC='
148 GNULIB_MODULES_RUNTIME_OTHER='
155 $GNULIB_TOOL --dir=gettext-runtime --lib=libgrt --source-base=gnulib-lib --m4-base=gnulib-m4 --no-libtool --local-dir=gnulib-local --local-symlink \
156 --import $GNULIB_MODULES_RUNTIME_FOR_SRC $GNULIB_MODULES_RUNTIME_OTHER || exit $?
157 # In gettext-runtime/libasprintf:
158 GNULIB_MODULES_LIBASPRINTF='
164 GNULIB_MODULES_LIBASPRINTF_OTHER='
166 $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 \
167 --import $GNULIB_MODULES_LIBASPRINTF $GNULIB_MODULES_LIBASPRINTF_OTHER || exit $?
168 $GNULIB_TOOL --copy-file m4/intmax_t.m4 gettext-runtime/libasprintf/gnulib-m4/intmax_t.m4 || exit $?
170 GNULIB_MODULES_TOOLS_FOR_SRC='
209 libunistring-optional
250 unilbrk/ulc-width-linebreaks
271 # Common dependencies of GNULIB_MODULES_TOOLS_FOR_SRC and GNULIB_MODULES_TOOLS_FOR_LIBGREP.
272 GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES='
297 GNULIB_MODULES_TOOLS_OTHER='
308 GNULIB_MODULES_TOOLS_LIBUNISTRING_TESTS='
309 unilbrk/u8-possible-linebreaks-tests
310 unilbrk/ulc-width-linebreaks-tests
311 unistr/u8-mbtouc-tests
312 unistr/u8-mbtouc-unsafe-tests
315 $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 \
316 --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 || exit $?
317 # In gettext-tools/libgrep:
318 GNULIB_MODULES_TOOLS_FOR_LIBGREP='
322 $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 \
323 --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 || exit $?
324 # In gettext-tools/libgettextpo:
325 # This is a subset of the GNULIB_MODULES_FOR_SRC.
326 GNULIB_MODULES_LIBGETTEXTPO='
344 libunistring-optional
360 unilbrk/ulc-width-linebreaks
375 GNULIB_MODULES_LIBGETTEXTPO_OTHER='
377 $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 \
378 --import $GNULIB_MODULES_LIBGETTEXTPO $GNULIB_MODULES_LIBGETTEXTPO_OTHER || exit $?
379 # Import build tools. We use --copy-file to avoid directory creation.
380 $GNULIB_TOOL --copy-file tests/init.sh gettext-tools || exit $?
381 $GNULIB_TOOL --copy-file build-aux/git-version-gen || exit $?
382 $GNULIB_TOOL --copy-file build-aux/gitlog-to-changelog || exit $?
386 # Fetch config.guess, config.sub.
387 if test -n "$GNULIB_TOOL"; then
388 for file in config.guess config.sub; do
389 $GNULIB_TOOL --copy-file build-aux/$file; chmod a+x build-aux/$file || exit $?
392 for file in config.guess config.sub; do
393 echo "$0: getting $file..."
394 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" \
395 && mv build-aux/$file.tmp build-aux/$file \
396 && chmod a+x build-aux/$file
398 rm -f build-aux/$file.tmp
399 test $retval -eq 0 || exit $retval
403 # Fetch gettext-tools/misc/archive.dir.tar.
404 if ! test -f gettext-tools/misc/archive.dir.tar; then
405 if ! test -f gettext-tools/misc/archive.dir.tar.xz; then
406 echo "$0: getting gettext-tools/misc/archive.dir.tar..."
407 wget -q --timeout=5 -O gettext-tools/misc/archive.dir.tar.xz-t "ftp://alpha.gnu.org/gnu/gettext/archive.dir-latest.tar.xz" \
408 && mv gettext-tools/misc/archive.dir.tar.xz-t gettext-tools/misc/archive.dir.tar.xz
410 rm -f gettext-tools/misc/archive.dir.tar.xz-t
411 test $retval -eq 0 || exit $retval
413 xz -d -c < gettext-tools/misc/archive.dir.tar.xz > gettext-tools/misc/archive.dir.tar-t \
414 && mv gettext-tools/misc/archive.dir.tar-t gettext-tools/misc/archive.dir.tar
416 rm -f gettext-tools/misc/archive.dir.tar-t
417 test $retval -eq 0 || exit $retval
420 # Automake requires that ChangeLog exist.
421 for dir in . gettext-runtime gettext-runtime/libasprintf \
422 gettext-tools gettext-tools/examples \
423 gettext-runtime/intl gettext-runtime/po gettext-tools/po; do
424 cat > "$dir/ChangeLog" <<\EOF
425 No more ChangeLog files
426 ========================
427 Do not modify any of the ChangeLog files in gettext. Starting on
428 October 14th, 2015 we put changelog information only in the git commit
429 log, and generate a top-level ChangeLog file from logs at "make dist"
439 # Generate configure script in each subdirectories.
440 (cd gettext-runtime/libasprintf
441 echo "$0: generating configure in gettext-runtime/libasprintf..."
442 aclocal -I ../../m4 -I ../m4 -I gnulib-m4
444 autoheader && touch config.h.in
445 automake --add-missing --copy
449 echo "$0: generating configure in gettext-runtime..."
450 aclocal -I m4 -I ../m4 -I gnulib-m4
452 autoheader && touch config.h.in
453 automake --add-missing --copy
456 (cd gettext-tools/examples
457 echo "$0: generating configure in gettext-tools/examples..."
458 aclocal -I ../../gettext-runtime/m4 -I ../../m4
460 automake --add-missing --copy
463 echo "$0: copying common files from gettext-runtime to gettext-tools..."
464 cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS
465 cp -p gettext-runtime/po/Makefile.in.in gettext-tools/po/Makefile.in.in
466 cp -p gettext-runtime/po/Rules-quot gettext-tools/po/Rules-quot
467 cp -p gettext-runtime/po/boldquot.sed gettext-tools/po/boldquot.sed
468 cp -p gettext-runtime/po/quot.sed gettext-tools/po/quot.sed
469 cp -p gettext-runtime/po/en@quot.header gettext-tools/po/en@quot.header
470 cp -p gettext-runtime/po/en@boldquot.header gettext-tools/po/en@boldquot.header
471 cp -p gettext-runtime/po/insert-header.sin gettext-tools/po/insert-header.sin
472 cp -p gettext-runtime/po/remove-potcdate.sin gettext-tools/po/remove-potcdate.sin
473 # Those two files might be newer than Gnulib's.
474 sed_extract_serial='s/^#.* serial \([^ ]*\).*/\1/p
476 for file in intl.m4 po.m4; do
477 existing_serial=`sed -n -e "$sed_extract_serial" < "gettext-tools/gnulib-m4/$file"`
478 gettext_serial=`sed -n -e "$sed_extract_serial" < "gettext-runtime/m4/$file"`
479 if test -n "$existing_serial" && test -n "$gettext_serial" \
480 && test "$existing_serial" -ge "$gettext_serial" 2> /dev/null; then
483 cp -p "gettext-runtime/m4/$file" "gettext-tools/gnulib-m4/$file"
488 echo "$0: generating configure in gettext-tools..."
489 aclocal -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
491 autoheader && touch config.h.in
492 test -d intl || mkdir intl
493 automake --add-missing --copy