add packaging
[platform/upstream/gettext.git] / autogen.sh
1 #!/bin/sh
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.
6 #
7 # This script requires autoconf-2.62..2.69 and automake-1.11.1..1.12 in the
8 # PATH.
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.
16
17 # It also requires
18 #   - the bison program,
19 #   - the gperf program,
20 #   - the groff program,
21 #   - the makeinfo program from the texinfo package,
22 #   - perl.
23
24 # Copyright (C) 2003-2012 Free Software Foundation, Inc.
25 #
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.
30 #
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.
35 #
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/>.
38
39 # Usage: ./autogen.sh [--quick] [--skip-gnulib]
40 #
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.)
46 #
47 # Usage from a released tarball:             ./autogen.sh --quick --skip-gnulib
48 # This does not use a gnulib checkout.
49
50 quick=false
51 skip_gnulib=false
52 while :; do
53   case "$1" in
54     --quick) quick=true; shift;;
55     --skip-gnulib) skip_gnulib=true; shift;;
56     *) break ;;
57   esac
58 done
59
60 cleanup_gnulib() {
61   status=$?
62   rm -fr "$gnulib_path"
63   exit $status
64 }
65
66 git_modules_config () {
67   test -f .gitmodules && git config --file .gitmodules "$@"
68 }
69
70 gnulib_path=$(git_modules_config submodule.gnulib.path)
71 test -z "$gnulib_path" && gnulib_path=gnulib
72
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.
75
76 if ! $skip_gnulib; then
77   # Get gnulib files.
78   case ${GNULIB_SRCDIR--} in
79   -)
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 $?
84
85     elif [ ! -d "$gnulib_path" ]; then
86       echo "$0: getting gnulib files..."
87
88       trap cleanup_gnulib 1 2 13 15
89
90       shallow=
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" ||
93         cleanup_gnulib
94
95       trap - 1 2 13 15
96     fi
97     GNULIB_SRCDIR=$gnulib_path
98     ;;
99   *)
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 $?
108       else
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 $?
113         else
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 \
119             || exit $?
120         fi
121       fi
122       GNULIB_SRCDIR=$gnulib_path
123     fi
124     ;;
125   esac
126   # Now it should contain a gnulib-tool.
127   if test -f "$GNULIB_SRCDIR"/gnulib-tool; then
128     GNULIB_TOOL="$GNULIB_SRCDIR"/gnulib-tool
129   else
130     echo "** warning: gnulib-tool not found" 1>&2
131   fi
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='
136       atexit
137       basename
138       closeout
139       error
140       getopt-gnu
141       gettext-h
142       havelib
143       memmove
144       progname
145       propername
146       relocatable-prog
147       setlocale
148       sigpipe
149       stdbool
150       stdio
151       stdlib
152       strtoul
153       unlocked-io
154       xalloc
155     '
156     GNULIB_MODULES_RUNTIME_OTHER='
157       gettext-runtime-misc
158       ansi-c++-opt
159       csharpcomp-script
160       java
161       javacomp-script
162     '
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='
167       alloca
168       errno
169       verify
170       xsize
171     '
172     GNULIB_MODULES_LIBASPRINTF_OTHER='
173     '
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
177     # In gettext-tools:
178     GNULIB_MODULES_TOOLS_FOR_SRC='
179       alloca-opt
180       atexit
181       backupfile
182       basename
183       binary-io
184       bison-i18n
185       byteswap
186       c-ctype
187       c-strcase
188       c-strcasestr
189       c-strstr
190       clean-temp
191       closedir
192       closeout
193       copy-file
194       csharpcomp
195       csharpexec
196       error
197       error-progname
198       execute
199       fd-ostream
200       file-ostream
201       filename
202       findprog
203       fnmatch
204       fopen
205       fstrcmp
206       full-write
207       fwriteerror
208       gcd
209       getline
210       getopt-gnu
211       gettext-h
212       hash
213       html-styled-ostream
214       iconv
215       javacomp
216       javaexec
217       libunistring-optional
218       localcharset
219       locale
220       localename
221       lock
222       memmove
223       memset
224       minmax
225       obstack
226       open
227       opendir
228       openmp
229       ostream
230       pipe-filter-ii
231       progname
232       propername
233       readdir
234       relocatable-prog
235       relocatable-script
236       setlocale
237       sh-quote
238       sigpipe
239       sigprocmask
240       spawn-pipe
241       stdbool
242       stdio
243       stdlib
244       stpcpy
245       stpncpy
246       strcspn
247       strerror
248       strpbrk
249       strtol
250       strtoul
251       styled-ostream
252       sys_select
253       sys_stat
254       sys_time
255       term-styled-ostream
256       unilbrk/ulc-width-linebreaks
257       uniname/uniname
258       unistd
259       unistr/u8-mbtouc
260       unistr/u8-mbtoucr
261       unistr/u8-uctomb
262       unistr/u16-mbtouc
263       uniwidth/width
264       unlocked-io
265       vasprintf
266       wait-process
267       write
268       xalloc
269       xconcat-filename
270       xmalloca
271       xerror
272       xsetenv
273       xstriconv
274       xstriconveh
275       xvasprintf
276     '
277     # Common dependencies of GNULIB_MODULES_TOOLS_FOR_SRC and GNULIB_MODULES_TOOLS_FOR_LIBGREP.
278     GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES='
279       alloca-opt
280       extensions
281       gettext-h
282       include_next
283       locale
284       localcharset
285       malloc-posix
286       mbrtowc
287       mbsinit
288       multiarch
289       snippet/arg-nonnull
290       snippet/c++defs
291       snippet/warn-on-use
292       ssize_t
293       stdbool
294       stddef
295       stdint
296       stdlib
297       streq
298       unistd
299       verify
300       wchar
301       wctype-h
302     '
303     GNULIB_MODULES_TOOLS_OTHER='
304       gettext-tools-misc
305       ansi-c++-opt
306       csharpcomp-script
307       csharpexec-script
308       gcj
309       java
310       javacomp-script
311       javaexec-script
312       stdint
313     '
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
319       uniwidth/width-tests
320     '
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='
325       mbrlen
326       regex
327     '
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='
333       basename
334       close
335       c-ctype
336       c-strcase
337       c-strstr
338       error
339       error-progname
340       file-ostream
341       filename
342       fopen
343       fstrcmp
344       fwriteerror
345       gcd
346       getline
347       gettext-h
348       hash
349       iconv
350       libunistring-optional
351       minmax
352       open
353       ostream
354       progname
355       relocatable-lib
356       sigpipe
357       stdbool
358       stdio
359       stdlib
360       strchrnul
361       strerror
362       unilbrk/ulc-width-linebreaks
363       unistr/u8-mbtouc
364       unistr/u8-mbtoucr
365       unistr/u8-uctomb
366       unistr/u16-mbtouc
367       uniwidth/width
368       unlocked-io
369       vasprintf
370       xalloc
371       xconcat-filename
372       xmalloca
373       xerror
374       xstriconv
375       xvasprintf
376     '
377     GNULIB_MODULES_LIBGETTEXTPO_OTHER='
378     '
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
381   fi
382 fi
383
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
388   done
389 else
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
394   done
395 fi
396
397 (cd gettext-runtime/libasprintf
398  aclocal -I ../../m4 -I ../m4 -I gnulib-m4
399  autoconf
400  autoheader && touch config.h.in
401  automake --add-missing --copy
402 )
403
404 (cd gettext-runtime
405  aclocal -I m4 -I ../m4 -I gnulib-m4
406  autoconf
407  autoheader && touch config.h.in
408  automake --add-missing --copy
409  # Rebuilding the PO files and manual pages is only rarely needed.
410  if ! $quick; then
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) \
415      && make distclean
416  fi
417 )
418
419 cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS
420
421 (cd gettext-tools/examples
422  aclocal -I ../../gettext-runtime/m4 -I ../../m4
423  autoconf
424  automake --add-missing --copy
425  # Rebuilding the examples PO files is only rarely needed.
426  if ! $quick; then
427    ./configure && (cd po && make update-po) && make distclean
428  fi
429 )
430
431 (cd gettext-tools
432  aclocal -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
433  autoconf
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.
438  if ! $quick; then
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) \
445      && make distclean
446  fi
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
450  fi
451 )
452
453 aclocal -I m4
454 autoconf
455 automake