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.60..2.61 and automake-1.10 in the PATH.
8# It also requires either
9#   - the GNULIB_TOOL environment variable pointing to the gnulib-tool script
10#     in a gnulib checkout, or
11#   - the cvs program in the PATH and an internet connection.
12
13# Copyright (C) 2003-2007 Free Software Foundation, Inc.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation; either version 3 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program.  If not, see <http://www.gnu.org/licenses/>.
27
28# Usage: ./autogen.sh [--quick] [--skip-gnulib]
29#
30# Usage after a first-time CVS checkout:     ./autogen.sh
31# Usage after a CVS update:                  ./autogen.sh --quick
32# This uses an up-to-date gnulib checkout.
33# (The gettext-0.17 release was prepared using gnulib commit
34# bf5ebbca03613397b66521e98dd4ce28741c4689 from 2007-11-07.)
35#
36# Usage from a released tarball:             ./autogen.sh --quick --skip-gnulib
37# This does not use a gnulib checkout.
38
39quick=false
40skip_gnulib=false
41while :; do
42  case "$1" in
43    --quick) quick=true; shift;;
44    --skip-gnulib) skip_gnulib=true; shift;;
45    *) break ;;
46  esac
47done
48
49if test $skip_gnulib = false; then
50  if test -z "$GNULIB_TOOL"; then
51    # Check out gnulib in a subdirectory 'gnulib'.
52    GNULIB_CVS_ROOT=':pserver:anonymous@pserver.git.sv.gnu.org:/gnulib.git'
53    GNULIB_CVS_REPOSITORY='gnulib'
54    if test -d gnulib; then
55      (cd gnulib && cvs update -d -P)
56    else
57      cvs -d "$GNULIB_CVS_ROOT" checkout -d $GNULIB_CVS_REPOSITORY HEAD
58    fi
59    # Now it should contain a gnulib-tool.
60    if test -f gnulib/gnulib-tool; then
61      GNULIB_TOOL=`pwd`/gnulib/gnulib-tool
62    else
63      echo "** warning: gnulib-tool not found" 1>&2
64    fi
65  fi
66  # Skip the gnulib-tool step if gnulib-tool was not found.
67  if test -n "$GNULIB_TOOL"; then
68    # In gettext-runtime:
69    if test -f gettext-runtime/gnulib-m4/gnulib-cache.m4; then
70      mv -f gettext-runtime/gnulib-m4/gnulib-cache.m4 gettext-runtime/gnulib-m4/gnulib-cache.m4~
71    fi
72    GNULIB_MODULES_RUNTIME_FOR_SRC='
73      atexit
74      basename
75      closeout
76      error
77      exit
78      getopt
79      gettext-h
80      memmove
81      progname
82      propername
83      relocatable-prog
84      stdbool
85      strtoul
86      unlocked-io
87      xalloc
88    '
89    GNULIB_MODULES_RUNTIME_OTHER='
90      gettext-runtime-misc
91      csharpcomp-script
92      java
93      javacomp-script
94    '
95    $GNULIB_TOOL --dir=gettext-runtime --lib=libgrt --source-base=gnulib-lib --m4-base=gnulib-m4 --no-libtool --local-dir=gnulib-local --local-symlink \
96      --import $GNULIB_MODULES_RUNTIME_FOR_SRC $GNULIB_MODULES_RUNTIME_OTHER
97    # In gettext-tools:
98    if test -f gettext-tools/gnulib-m4/gnulib-cache.m4; then
99      mv -f gettext-tools/gnulib-m4/gnulib-cache.m4 gettext-tools/gnulib-m4/gnulib-cache.m4~
100    fi
101    GNULIB_MODULES_TOOLS_FOR_SRC='
102      alloca-opt
103      atexit
104      backupfile
105      basename
106      binary-io
107      bison-i18n
108      byteswap
109      c-ctype
110      c-strcase
111      c-strcasestr
112      c-strstr
113      clean-temp
114      closeout
115      copy-file
116      csharpcomp
117      csharpexec
118      error
119      error-progname
120      execute
121      exit
122      fd-ostream
123      file-ostream
124      filename
125      findprog
126      fnmatch-posix
127      fopen
128      fstrcmp
129      full-write
130      fwriteerror
131      gcd
132      getline
133      getopt
134      gettext-h
135      hash
136      html-styled-ostream
137      iconv
138      javacomp
139      javaexec
140      linebreak
141      localcharset
142      locale
143      localename
144      lock
145      memmove
146      memset
147      minmax
148      obstack
149      open
150      openmp
151      ostream
152      pipe
153      progname
154      propername
155      relocatable-prog
156      relocatable-script
157      sh-quote
158      stdbool
159      stpcpy
160      stpncpy
161      strcspn
162      strpbrk
163      strtol
164      strtoul
165      styled-ostream
166      sys_stat
167      sys_time
168      term-styled-ostream
169      ucs4-utf8
170      uniname/uniname
171      unistd
172      uniwidth/width
173      unlocked-io
174      utf8-ucs4
175      utf16-ucs4
176      vasprintf
177      wait-process
178      xalloc
179      xmalloca
180      xerror
181      xsetenv
182      xstriconv
183      xvasprintf
184    '
185    # Not yet used. Add some files to gettext-tools-misc instead.
186    GNULIB_MODULES_TOOLS_FOR_LIBGREP='
187      error
188      exitfail
189      gettext-h
190      hard-locale
191      obstack
192      regex
193      stdbool
194      xalloc
195    '
196    GNULIB_MODULES_TOOLS_OTHER='
197      gettext-tools-misc
198      gcj
199      java
200      stdint
201    '
202    $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 \
203      --import $GNULIB_MODULES_TOOLS_FOR_SRC $GNULIB_MODULES_TOOLS_OTHER
204    # In gettext-tools/libgettextpo:
205    if test -f gettext-tools/libgettextpo/gnulib-m4/gnulib-cache.m4; then
206      mv -f gettext-tools/libgettextpo/gnulib-m4/gnulib-cache.m4 gettext-tools/libgettextpo/gnulib-m4/gnulib-cache.m4~
207    fi
208    # This is a subset of the GNULIB_MODULES_FOR_SRC.
209    GNULIB_MODULES_LIBGETTEXTPO='
210      basename
211      c-ctype
212      c-strcase
213      c-strstr
214      error
215      error-progname
216      exit
217      file-ostream
218      filename
219      fopen
220      fstrcmp
221      fwriteerror
222      gcd
223      getline
224      gettext-h
225      hash
226      iconv
227      linebreak
228      minmax
229      ostream
230      progname
231      relocatable-lib
232      stdbool
233      ucs4-utf8
234      uniwidth/width
235      unlocked-io
236      utf8-ucs4
237      utf16-ucs4
238      vasprintf
239      xalloc
240      xmalloca
241      xerror
242      xstriconv
243      xvasprintf
244    '
245    GNULIB_MODULES_LIBGETTEXTPO_OTHER='
246    '
247    $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 \
248      --import $GNULIB_MODULES_LIBGETTEXTPO $GNULIB_MODULES_LIBGETTEXTPO_OTHER
249  fi
250fi
251
252(cd autoconf-lib-link
253 ../build-aux/fixaclocal aclocal -I m4 -I ../m4
254 autoconf
255 automake
256)
257
258(cd gettext-runtime
259 ../build-aux/fixaclocal aclocal -I m4 -I ../autoconf-lib-link/m4 -I ../m4 -I gnulib-m4
260 autoconf
261 autoheader && touch config.h.in
262 automake
263)
264
265(cd gettext-runtime/libasprintf
266 ../../build-aux/fixaclocal aclocal -I ../../m4 -I ../m4
267 autoconf
268 autoheader && touch config.h.in
269 automake
270)
271
272cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS
273
274(cd gettext-tools
275 ../build-aux/fixaclocal aclocal -I m4 -I ../gettext-runtime/m4 -I ../autoconf-lib-link/m4 -I ../m4 -I gnulib-m4 -I libgettextpo/gnulib-m4
276 autoconf
277 autoheader && touch config.h.in
278 automake
279)
280
281(cd gettext-tools/examples
282 ../../build-aux/fixaclocal aclocal -I ../../gettext-runtime/m4 -I ../../m4
283 autoconf
284 automake
285 # Rebuilding the examples PO files is only rarely needed.
286 if ! $quick; then
287   ./configure && (cd po && make update-po) && make distclean
288 fi
289)
290
291build-aux/fixaclocal aclocal
292autoconf
293automake
294
295cp -p autoconf-lib-link/config.rpath build-aux/config.rpath
296