]>
Commit | Line | Data |
---|---|---|
01c56de4 AD |
1 | #! /bin/sh |
2 | ||
1f65350a | 3 | # Bootstrap this package from CVS. |
01c56de4 | 4 | |
b4068c7c | 5 | # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
1f65350a PE |
6 | |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 2, or (at your option) | |
10 | # any later version. | |
11 | ||
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | ||
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
0fb669f9 PE |
19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
20 | # 02110-1301, USA. | |
1f65350a PE |
21 | |
22 | # Written by Paul Eggert. | |
23 | ||
3b2942e6 PE |
24 | nl=' |
25 | ' | |
5a2baae7 | 26 | |
62a9592d | 27 | # Ensure file names are sorted consistently across platforms. |
b5240ba5 | 28 | # Also, ensure diagnostics are in English, e.g., "wget --help" below. |
a9f027b9 PE |
29 | LC_ALL=C |
30 | export LC_ALL | |
31 | ||
3b2942e6 PE |
32 | |
33 | # Configuration. | |
34 | ||
35 | # List of gnulib modules needed. | |
36 | gnulib_modules= | |
37 | ||
38 | # Any gnulib files needed that are not in modules. | |
39 | gnulib_files= | |
40 | ||
41 | # Translation Project URL, for the registry of all projects | |
42 | # and for the translation-team master directory. | |
43 | TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain=' | |
44 | TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/' | |
45 | ||
46 | extract_package_name=' | |
47 | /^AC_INIT(/{ | |
48 | /.*,.*,.*,/{ | |
49 | s/// | |
50 | s/[][]//g | |
51 | p | |
52 | q | |
53 | } | |
54 | s/AC_INIT(\[*// | |
55 | s/]*,.*// | |
56 | s/^GNU // | |
57 | y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ | |
58 | s/[^A-Za-z0-9_]/-/g | |
59 | p | |
60 | } | |
61 | ' | |
62 | package=`sed -n "$extract_package_name" configure.ac` || exit | |
63 | ||
64 | # Extra files from gnulib, which override files from other sources. | |
65 | gnulib_extra_files=' | |
66 | build-aux/install-sh | |
67 | build-aux/missing | |
68 | build-aux/mdate-sh | |
69 | build-aux/texinfo.tex | |
70 | build-aux/depcomp | |
71 | build-aux/config.guess | |
72 | build-aux/config.sub | |
73 | doc/INSTALL | |
74 | ' | |
75 | ||
76 | # Other locale categories that need message catalogs. | |
77 | EXTRA_LOCALE_CATEGORIES= | |
78 | ||
79 | # Additional xgettext options to use. Use "\\\newline" to break lines. | |
80 | XGETTEXT_OPTIONS='\\\ | |
81 | --flag=_:1:pass-c-format\\\ | |
82 | --flag=N_:1:pass-c-format\\\ | |
83 | --flag=error:3:c-format --flag=error_at_line:5:c-format\\\ | |
84 | ' | |
85 | ||
86 | # Files we don't want to import. | |
87 | excluded_files= | |
88 | ||
89 | # Override the default configuration, if necessary. | |
90 | test -r bootstrap.conf && . ./bootstrap.conf | |
91 | ||
92 | # Translate configuration into internal form. | |
93 | ||
1f65350a PE |
94 | # Parse options. |
95 | ||
96 | for option | |
97 | do | |
98 | case $option in | |
99 | --help) | |
100 | echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]" | |
101 | exit;; | |
102 | --gnulib-srcdir=*) | |
e23d0dd7 | 103 | GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;; |
1f65350a | 104 | --cvs-user=*) |
e23d0dd7 | 105 | CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;; |
1f65350a PE |
106 | --skip-po) |
107 | SKIP_PO=t;; | |
108 | *) | |
109 | echo >&2 "$0: $option: unknown option" | |
110 | exit 1;; | |
111 | esac | |
112 | done | |
113 | ||
114 | echo "$0: Bootstrapping CVS $package..." | |
115 | ||
e10a80ee PE |
116 | cleanup_gnulib() { |
117 | status=$? | |
118 | rm -fr gnulib | |
119 | exit $status | |
120 | } | |
121 | ||
1f65350a PE |
122 | # Get gnulib files. |
123 | ||
124 | case ${GNULIB_SRCDIR--} in | |
125 | -) | |
126 | if [ ! -d gnulib ]; then | |
127 | echo "$0: getting gnulib files..." | |
128 | ||
26546b42 PE |
129 | case ${CVS_AUTH-pserver} in |
130 | pserver) | |
131 | CVS_PREFIX=':pserver:anonymous@';; | |
1f65350a PE |
132 | ssh) |
133 | CVS_PREFIX="$CVS_USER${CVS_USER+@}";; | |
134 | *) | |
135 | echo "$0: $CVS_AUTH: Unknown CVS access method" >&2 | |
136 | exit 1;; | |
137 | esac | |
138 | ||
139 | case $CVS_RSH in | |
3b2942e6 | 140 | '') CVS_RSH=ssh; export CVS_RSH;; |
1f65350a PE |
141 | esac |
142 | ||
e10a80ee PE |
143 | trap cleanup_gnulib 1 2 13 15 |
144 | ||
26546b42 | 145 | cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/gnulib co gnulib || |
e10a80ee | 146 | cleanup_gnulib |
1f65350a | 147 | |
e10a80ee | 148 | trap - 1 2 13 15 |
1f65350a PE |
149 | fi |
150 | GNULIB_SRCDIR=gnulib | |
151 | esac | |
152 | ||
284d8a13 PE |
153 | gnulib_tool=$GNULIB_SRCDIR/gnulib-tool |
154 | <$gnulib_tool || exit | |
1f65350a | 155 | |
1f65350a PE |
156 | # Get translations. |
157 | ||
5a2baae7 PE |
158 | get_translations() { |
159 | subdir=$1 | |
160 | domain=$2 | |
161 | ||
3b2942e6 PE |
162 | case $WGET_COMMAND in |
163 | '') | |
164 | echo "$0: wget not available; skipping translations";; | |
165 | ?*) | |
166 | echo "$0: getting translations into $subdir for $domain..." && | |
167 | ||
168 | (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) && | |
169 | $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" && | |
170 | ||
171 | sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" | | |
172 | sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 | | |
173 | awk -F. ' | |
174 | { if (lang && $1 != lang) print lang, ver } | |
175 | { lang = $1; ver = substr($0, index($0, ".") + 1) } | |
176 | END { if (lang) print lang, ver } | |
177 | ' | awk -v domain="$domain" -v subdir="$subdir" ' | |
178 | { | |
179 | lang = $1 | |
180 | ver = $2 | |
181 | urlfmt = "" | |
182 | printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\'' &&\n", subdir, lang, lang, domain, ver, lang | |
183 | printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang | |
184 | printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang | |
185 | printf " rm -f %s/%s.po; }; } &&\n", subdir, lang | |
186 | } | |
187 | END { print ":" } | |
188 | ' | WGET_COMMAND="$WGET_COMMAND" sh;; | |
189 | esac && | |
190 | ls "$subdir"/*.po 2>/dev/null | | |
191 | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" && | |
192 | rm -f "$subdir/$domain.html" | |
5a2baae7 PE |
193 | } |
194 | ||
1f65350a PE |
195 | case $SKIP_PO in |
196 | '') | |
b5240ba5 PE |
197 | case `wget --help` in |
198 | *'--no-cache'*) | |
3b2942e6 | 199 | WGET_COMMAND='wget -nv --no-cache';; |
b5240ba5 | 200 | *'--cache=on/off'*) |
3b2942e6 PE |
201 | WGET_COMMAND='wget -nv --cache=off';; |
202 | *'--non-verbose'*) | |
203 | WGET_COMMAND='wget -nv';; | |
b5240ba5 | 204 | *) |
3b2942e6 | 205 | WGET_COMMAND='';; |
b5240ba5 PE |
206 | esac |
207 | ||
5a2baae7 | 208 | get_translations po $package || exit |
f7ab6a50 | 209 | |
3b2942e6 | 210 | if test -d runtime-po; then |
5a2baae7 | 211 | get_translations runtime-po $package-runtime || exit |
3b2942e6 | 212 | fi;; |
1f65350a PE |
213 | esac |
214 | ||
e70f46d1 PE |
215 | symlink_to_gnulib() |
216 | { | |
217 | src=$GNULIB_SRCDIR/$1 | |
218 | dst=${2-$1} | |
219 | dot_dots= | |
220 | ||
221 | case $src in | |
222 | /*) ;; | |
223 | *) | |
224 | case /$dst/ in | |
225 | *//* | */../* | */./* | /*/*/*/*/*/) | |
226 | echo >&2 "$0: invalid symlink calculation: $src -> $dst" | |
227 | exit 1;; | |
228 | /*/*/*/*/) dot_dots=../../../;; | |
229 | /*/*/*/) dot_dots=../../;; | |
230 | /*/*/) dot_dots=../;; | |
231 | esac;; | |
232 | esac | |
233 | ||
234 | test -f "$src" && { | |
235 | test -h "$dst" && | |
236 | src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && | |
237 | dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && | |
238 | test "$src_i" = "$dst_i" || { | |
239 | echo "$0: ln -fs $dot_dots$src $dst" && | |
240 | ln -fs "$dot_dots$src" "$dst" | |
241 | } | |
242 | } | |
243 | } | |
244 | ||
3b2942e6 PE |
245 | cp_mark_as_generated() |
246 | { | |
247 | cp_src=$1 | |
248 | cp_dst=$2 | |
1f65350a | 249 | |
e70f46d1 PE |
250 | if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then |
251 | symlink_to_gnulib "$cp_dst" | |
252 | else | |
253 | case $cp_dst in | |
254 | *.[ch]) c1='/* '; c2=' */';; | |
255 | *.texi) c1='@c '; c2= ;; | |
256 | *.m4|*/Make*|Make*) c1='# ' ; c2= ;; | |
257 | *) c1= ; c2= ;; | |
258 | esac | |
1f65350a | 259 | |
e70f46d1 PE |
260 | if test -z "$c1"; then |
261 | cmp -s "$cp_src" "$cp_dst" || { | |
262 | echo "$0: cp -f $cp_src $cp_dst" && | |
263 | cp -f "$cp_src" "$cp_dst" | |
264 | } | |
265 | else | |
266 | # Copy the file first to get proper permissions if it | |
267 | # doesn't already exist. Then overwrite the copy. | |
268 | cp "$cp_src" "$cp_dst-t" && | |
269 | ( | |
270 | echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" && | |
271 | echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" && | |
272 | cat "$cp_src" | |
273 | ) > $cp_dst-t && | |
274 | if cmp -s "$cp_dst-t" "$cp_dst"; then | |
275 | rm -f "$cp_dst-t" | |
276 | else | |
277 | echo "$0: cp $cp_src $cp_dst # with edits" && | |
278 | mv -f "$cp_dst-t" "$cp_dst" | |
279 | fi | |
280 | fi | |
281 | fi | |
3b2942e6 | 282 | } |
1f65350a | 283 | |
3b2942e6 PE |
284 | slurp() { |
285 | for dir in . `(cd $1 && find * -type d -print)`; do | |
286 | copied= | |
287 | sep= | |
288 | for file in `ls $1/$dir`; do | |
289 | test -d $1/$dir/$file && continue | |
290 | for excluded_file in $excluded_files; do | |
291 | test "$dir/$file" = "$excluded_file" && continue 2 | |
292 | done | |
293 | if test $file = Makefile.am; then | |
e70f46d1 PE |
294 | copied=$copied${sep}gnulib.mk; sep=$nl |
295 | remove_intl='/^[^#].*\/intl/s/^/#/' | |
296 | sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || { | |
297 | echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." && | |
298 | rm -f $dir/gnulib.mk && | |
299 | sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk | |
300 | } | |
301 | elif { test "${2+set}" = set && test -r $2/$dir/$file; } || | |
3b2942e6 PE |
302 | grep -F "/$file/" $dir/CVS/Entries 2>/dev/null | |
303 | grep -q '^/[^/]*/[0-9]'; then | |
304 | echo "$0: $dir/$file overrides $1/$dir/$file" | |
305 | else | |
306 | copied=$copied$sep$file; sep=$nl | |
307 | if test $file = gettext.m4; then | |
308 | echo "$0: patching m4/gettext.m4 to remove need for intl/* ..." | |
309 | rm -f $dir/$file | |
310 | sed ' | |
311 | /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\ | |
312 | AC_DEFUN([AM_INTL_SUBDIR], [ | |
313 | /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\ | |
314 | AC_DEFUN([gt_INTL_SUBDIR_CORE], []) | |
315 | $a\ | |
316 | AC_DEFUN([gl_LOCK_EARLY], []) | |
317 | ' $1/$dir/$file >$dir/$file | |
318 | else | |
3b2942e6 PE |
319 | cp_mark_as_generated $1/$dir/$file $dir/$file |
320 | fi | |
321 | fi || exit | |
322 | done | |
323 | ||
324 | ig=$dir/.cvsignore | |
325 | if test -n "$copied" && test -f $ig; then | |
326 | echo "$copied" | sort -u - $ig | cmp -s - $ig || | |
327 | echo "$copied" | sort -u - $ig -o $ig || exit | |
328 | fi | |
329 | done | |
330 | } | |
1f65350a PE |
331 | |
332 | ||
3b2942e6 PE |
333 | # Create boot temporary directories to import from gnulib and gettext. |
334 | ||
335 | bt='.#bootmp' | |
336 | bt2=${bt}2 | |
337 | rm -fr $bt $bt2 && | |
338 | mkdir $bt $bt2 || exit | |
339 | ||
340 | # Import from gnulib. | |
341 | ||
342 | gnulib_tool_options="\ | |
343 | --import\ | |
344 | --no-changelog\ | |
345 | --aux-dir $bt/build-aux\ | |
346 | --doc-base $bt/doc\ | |
347 | --lib lib$package\ | |
348 | --m4-base $bt/m4/\ | |
349 | --source-base $bt/lib/\ | |
350 | --tests-base $bt/tests\ | |
351 | " | |
352 | echo "$0: $gnulib_tool $gnulib_tool_options --import ..." | |
353 | $gnulib_tool $gnulib_tool_options --import $gnulib_modules && | |
354 | slurp $bt || exit | |
355 | ||
356 | for file in $gnulib_files; do | |
e70f46d1 | 357 | symlink_to_gnulib $file || exit |
3b2942e6 | 358 | done |
1f65350a | 359 | |
e23d0dd7 | 360 | |
3b2942e6 | 361 | # Import from gettext. |
62a9592d | 362 | |
3b2942e6 PE |
363 | echo "$0: (cd $bt2; autopoint) ..." |
364 | cp configure.ac $bt2 && | |
365 | (cd $bt2 && autopoint && rm configure.ac) && | |
366 | slurp $bt2 $bt || exit | |
b4068c7c | 367 | |
3b2942e6 PE |
368 | rm -fr $bt $bt2 || exit |
369 | ||
370 | ||
371 | # Reconfigure, getting other files. | |
62a9592d PE |
372 | |
373 | for command in \ | |
374 | 'aclocal --force -I m4' \ | |
375 | 'autoconf --force' \ | |
376 | 'autoheader --force' \ | |
377 | 'automake --add-missing --copy --force-missing'; | |
378 | do | |
379 | echo "$0: $command ..." | |
380 | $command || exit | |
381 | done | |
382 | ||
383 | ||
3b2942e6 PE |
384 | # Get some extra files from gnulib, overriding existing files. |
385 | ||
386 | for file in $gnulib_extra_files; do | |
3b2942e6 | 387 | case $file in |
e70f46d1 PE |
388 | */INSTALL) dst=INSTALL;; |
389 | *) dst=$file;; | |
3b2942e6 | 390 | esac |
e70f46d1 | 391 | symlink_to_gnulib $file $dst || exit |
3b2942e6 PE |
392 | done |
393 | ||
394 | ||
395 | # Create gettext configuration. | |
11daa4e7 | 396 | echo "$0: Creating po/Makevars from po/Makevars.template ..." |
3b2942e6 | 397 | rm -f po/Makevars |
11daa4e7 | 398 | sed ' |
3b2942e6 PE |
399 | /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/ |
400 | /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ | |
11daa4e7 PE |
401 | /^XGETTEXT_OPTIONS *=/{ |
402 | s/$/ \\/ | |
403 | a\ | |
3b2942e6 | 404 | '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} |
11daa4e7 PE |
405 | } |
406 | ' po/Makevars.template >po/Makevars | |
1f65350a | 407 | |
3b2942e6 PE |
408 | if test -d runtime-po; then |
409 | # Likewise for runtime-po/Makevars, except also change a few other parameters. | |
410 | rm -f runtime-po/Makevars | |
411 | sed ' | |
412 | s/^\(DOMAIN\) *=.*/\1 = '"$package"'-runtime/ | |
413 | s/^\(subdir\) *=.*/\1 = runtime-po/ | |
414 | s/^\(XGETTEXT_OPTIONS\) *=.*/\1 = '"$XGETTEXT_OPTIONS_RUNTIME"'/ | |
415 | ' <po/Makevars >runtime-po/Makevars | |
416 | ||
417 | # Copy identical files from po to runtime-po. | |
418 | (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po) | |
419 | fi | |
1f65350a PE |
420 | |
421 | echo "$0: done. Now you can run './configure'." |