]>
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 | ||
e3ddc1e3 PE |
32 | usage() { |
33 | echo >&2 "\ | |
34 | Usage: $0 [OPTION]... | |
35 | Bootstrap this package from the CVS sources. | |
36 | ||
37 | Options: | |
38 | --gnulib-srcdir=DIRNAME Specify the local directory where gnulib | |
39 | sources reside. Use this if you already | |
40 | have gnulib sources on your machine, and | |
41 | do not want to waste your bandwidth dowloading | |
42 | them again. | |
46356ea4 | 43 | --copy Copy files instead of creating symbolic links. |
e3ddc1e3 PE |
44 | --force Bootstrap even if the sources didn't come from CVS. |
45 | --skip-po Do not download po files. | |
46 | --cvs-user=USERNAME Set the CVS username to be used when accessing | |
47 | the gnulib repository. | |
48 | ||
49 | If the file .bootstrap.conf exists in the current working directory, its | |
50 | contents are read as shell variables to configure the bootstrap. | |
51 | ||
52 | Running without arguments will suffice in most cases. | |
53 | " | |
54 | } | |
3b2942e6 PE |
55 | |
56 | # Configuration. | |
57 | ||
58 | # List of gnulib modules needed. | |
59 | gnulib_modules= | |
60 | ||
61 | # Any gnulib files needed that are not in modules. | |
62 | gnulib_files= | |
63 | ||
64 | # Translation Project URL, for the registry of all projects | |
65 | # and for the translation-team master directory. | |
66 | TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain=' | |
67 | TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/' | |
68 | ||
69 | extract_package_name=' | |
70 | /^AC_INIT(/{ | |
71 | /.*,.*,.*,/{ | |
72 | s/// | |
73 | s/[][]//g | |
74 | p | |
75 | q | |
76 | } | |
77 | s/AC_INIT(\[*// | |
78 | s/]*,.*// | |
79 | s/^GNU // | |
80 | y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ | |
81 | s/[^A-Za-z0-9_]/-/g | |
82 | p | |
83 | } | |
84 | ' | |
85 | package=`sed -n "$extract_package_name" configure.ac` || exit | |
86 | ||
87 | # Extra files from gnulib, which override files from other sources. | |
88 | gnulib_extra_files=' | |
89 | build-aux/install-sh | |
90 | build-aux/missing | |
91 | build-aux/mdate-sh | |
92 | build-aux/texinfo.tex | |
93 | build-aux/depcomp | |
94 | build-aux/config.guess | |
95 | build-aux/config.sub | |
96 | doc/INSTALL | |
97 | ' | |
98 | ||
99 | # Other locale categories that need message catalogs. | |
100 | EXTRA_LOCALE_CATEGORIES= | |
101 | ||
102 | # Additional xgettext options to use. Use "\\\newline" to break lines. | |
103 | XGETTEXT_OPTIONS='\\\ | |
104 | --flag=_:1:pass-c-format\\\ | |
105 | --flag=N_:1:pass-c-format\\\ | |
106 | --flag=error:3:c-format --flag=error_at_line:5:c-format\\\ | |
107 | ' | |
108 | ||
109 | # Files we don't want to import. | |
110 | excluded_files= | |
111 | ||
e3ddc1e3 PE |
112 | # File that should exist with CVS checkout, but not with |
113 | # the distributed version. | |
114 | CVS_only_file=CVS | |
115 | ||
46356ea4 PE |
116 | # Whether to use copies instead of symlinks. |
117 | copy=false | |
118 | ||
3b2942e6 PE |
119 | # Override the default configuration, if necessary. |
120 | test -r bootstrap.conf && . ./bootstrap.conf | |
121 | ||
122 | # Translate configuration into internal form. | |
123 | ||
1f65350a PE |
124 | # Parse options. |
125 | ||
126 | for option | |
127 | do | |
128 | case $option in | |
129 | --help) | |
e3ddc1e3 | 130 | usage |
1f65350a PE |
131 | exit;; |
132 | --gnulib-srcdir=*) | |
e23d0dd7 | 133 | GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;; |
1f65350a | 134 | --cvs-user=*) |
e23d0dd7 | 135 | CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;; |
1f65350a PE |
136 | --skip-po) |
137 | SKIP_PO=t;; | |
e3ddc1e3 PE |
138 | --force) |
139 | CVS_only_file=;; | |
46356ea4 PE |
140 | --copy) |
141 | copy=true;; | |
1f65350a PE |
142 | *) |
143 | echo >&2 "$0: $option: unknown option" | |
144 | exit 1;; | |
145 | esac | |
146 | done | |
147 | ||
e3ddc1e3 PE |
148 | if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then |
149 | echo "$0: Bootstrapping from a non-CVS distribution is a bit risky." >&2 | |
150 | exit 1 | |
151 | fi | |
152 | ||
1f65350a PE |
153 | echo "$0: Bootstrapping CVS $package..." |
154 | ||
e10a80ee PE |
155 | cleanup_gnulib() { |
156 | status=$? | |
157 | rm -fr gnulib | |
158 | exit $status | |
159 | } | |
160 | ||
1f65350a PE |
161 | # Get gnulib files. |
162 | ||
163 | case ${GNULIB_SRCDIR--} in | |
164 | -) | |
165 | if [ ! -d gnulib ]; then | |
166 | echo "$0: getting gnulib files..." | |
167 | ||
26546b42 PE |
168 | case ${CVS_AUTH-pserver} in |
169 | pserver) | |
170 | CVS_PREFIX=':pserver:anonymous@';; | |
1f65350a PE |
171 | ssh) |
172 | CVS_PREFIX="$CVS_USER${CVS_USER+@}";; | |
173 | *) | |
174 | echo "$0: $CVS_AUTH: Unknown CVS access method" >&2 | |
175 | exit 1;; | |
176 | esac | |
177 | ||
178 | case $CVS_RSH in | |
3b2942e6 | 179 | '') CVS_RSH=ssh; export CVS_RSH;; |
1f65350a PE |
180 | esac |
181 | ||
e10a80ee PE |
182 | trap cleanup_gnulib 1 2 13 15 |
183 | ||
26546b42 | 184 | cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/gnulib co gnulib || |
e10a80ee | 185 | cleanup_gnulib |
1f65350a | 186 | |
e10a80ee | 187 | trap - 1 2 13 15 |
1f65350a PE |
188 | fi |
189 | GNULIB_SRCDIR=gnulib | |
190 | esac | |
191 | ||
284d8a13 PE |
192 | gnulib_tool=$GNULIB_SRCDIR/gnulib-tool |
193 | <$gnulib_tool || exit | |
1f65350a | 194 | |
1f65350a PE |
195 | # Get translations. |
196 | ||
5a2baae7 PE |
197 | get_translations() { |
198 | subdir=$1 | |
199 | domain=$2 | |
200 | ||
3b2942e6 PE |
201 | case $WGET_COMMAND in |
202 | '') | |
203 | echo "$0: wget not available; skipping translations";; | |
204 | ?*) | |
205 | echo "$0: getting translations into $subdir for $domain..." && | |
206 | ||
207 | (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) && | |
208 | $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" && | |
209 | ||
210 | sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" | | |
211 | sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 | | |
212 | awk -F. ' | |
213 | { if (lang && $1 != lang) print lang, ver } | |
214 | { lang = $1; ver = substr($0, index($0, ".") + 1) } | |
215 | END { if (lang) print lang, ver } | |
216 | ' | awk -v domain="$domain" -v subdir="$subdir" ' | |
217 | { | |
218 | lang = $1 | |
219 | ver = $2 | |
220 | urlfmt = "" | |
221 | printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\'' &&\n", subdir, lang, lang, domain, ver, lang | |
222 | printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang | |
223 | printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang | |
224 | printf " rm -f %s/%s.po; }; } &&\n", subdir, lang | |
225 | } | |
226 | END { print ":" } | |
227 | ' | WGET_COMMAND="$WGET_COMMAND" sh;; | |
228 | esac && | |
229 | ls "$subdir"/*.po 2>/dev/null | | |
230 | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" && | |
231 | rm -f "$subdir/$domain.html" | |
5a2baae7 PE |
232 | } |
233 | ||
1f65350a PE |
234 | case $SKIP_PO in |
235 | '') | |
b5240ba5 PE |
236 | case `wget --help` in |
237 | *'--no-cache'*) | |
3b2942e6 | 238 | WGET_COMMAND='wget -nv --no-cache';; |
b5240ba5 | 239 | *'--cache=on/off'*) |
3b2942e6 PE |
240 | WGET_COMMAND='wget -nv --cache=off';; |
241 | *'--non-verbose'*) | |
242 | WGET_COMMAND='wget -nv';; | |
b5240ba5 | 243 | *) |
3b2942e6 | 244 | WGET_COMMAND='';; |
b5240ba5 PE |
245 | esac |
246 | ||
5a2baae7 | 247 | get_translations po $package || exit |
f7ab6a50 | 248 | |
3b2942e6 | 249 | if test -d runtime-po; then |
5a2baae7 | 250 | get_translations runtime-po $package-runtime || exit |
3b2942e6 | 251 | fi;; |
1f65350a PE |
252 | esac |
253 | ||
e70f46d1 PE |
254 | symlink_to_gnulib() |
255 | { | |
256 | src=$GNULIB_SRCDIR/$1 | |
257 | dst=${2-$1} | |
e70f46d1 PE |
258 | |
259 | test -f "$src" && { | |
46356ea4 PE |
260 | if $copy; then |
261 | { | |
262 | test ! -h "$dst" || { | |
263 | echo "$0: rm -f $dst" && | |
264 | rm -f "$dst" | |
265 | } | |
266 | } && | |
267 | test -f "$dst" && | |
268 | cmp -s "$src" "$dst" || { | |
269 | echo "$0: cp -fp $src $dst" && | |
270 | cp -fp "$src" "$dst" | |
271 | } | |
272 | else | |
273 | test -h "$dst" && | |
274 | src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && | |
275 | dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && | |
276 | test "$src_i" = "$dst_i" || { | |
277 | dot_dots= | |
278 | case $src in | |
279 | /*) ;; | |
280 | *) | |
281 | case /$dst/ in | |
282 | *//* | */../* | */./* | /*/*/*/*/*/) | |
283 | echo >&2 "$0: invalid symlink calculation: $src -> $dst" | |
284 | exit 1;; | |
285 | /*/*/*/*/) dot_dots=../../../;; | |
286 | /*/*/*/) dot_dots=../../;; | |
287 | /*/*/) dot_dots=../;; | |
288 | esac;; | |
289 | esac | |
290 | ||
291 | echo "$0: ln -fs $dot_dots$src $dst" && | |
292 | ln -fs "$dot_dots$src" "$dst" | |
293 | } | |
294 | fi | |
e70f46d1 PE |
295 | } |
296 | } | |
297 | ||
3b2942e6 PE |
298 | cp_mark_as_generated() |
299 | { | |
300 | cp_src=$1 | |
301 | cp_dst=$2 | |
1f65350a | 302 | |
e70f46d1 PE |
303 | if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then |
304 | symlink_to_gnulib "$cp_dst" | |
305 | else | |
306 | case $cp_dst in | |
307 | *.[ch]) c1='/* '; c2=' */';; | |
308 | *.texi) c1='@c '; c2= ;; | |
309 | *.m4|*/Make*|Make*) c1='# ' ; c2= ;; | |
310 | *) c1= ; c2= ;; | |
311 | esac | |
1f65350a | 312 | |
e70f46d1 PE |
313 | if test -z "$c1"; then |
314 | cmp -s "$cp_src" "$cp_dst" || { | |
315 | echo "$0: cp -f $cp_src $cp_dst" && | |
316 | cp -f "$cp_src" "$cp_dst" | |
317 | } | |
318 | else | |
319 | # Copy the file first to get proper permissions if it | |
320 | # doesn't already exist. Then overwrite the copy. | |
321 | cp "$cp_src" "$cp_dst-t" && | |
322 | ( | |
323 | echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" && | |
324 | echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" && | |
325 | cat "$cp_src" | |
326 | ) > $cp_dst-t && | |
327 | if cmp -s "$cp_dst-t" "$cp_dst"; then | |
328 | rm -f "$cp_dst-t" | |
329 | else | |
330 | echo "$0: cp $cp_src $cp_dst # with edits" && | |
331 | mv -f "$cp_dst-t" "$cp_dst" | |
332 | fi | |
333 | fi | |
334 | fi | |
3b2942e6 | 335 | } |
1f65350a | 336 | |
3b2942e6 PE |
337 | slurp() { |
338 | for dir in . `(cd $1 && find * -type d -print)`; do | |
339 | copied= | |
340 | sep= | |
341 | for file in `ls $1/$dir`; do | |
342 | test -d $1/$dir/$file && continue | |
343 | for excluded_file in $excluded_files; do | |
344 | test "$dir/$file" = "$excluded_file" && continue 2 | |
345 | done | |
346 | if test $file = Makefile.am; then | |
e70f46d1 PE |
347 | copied=$copied${sep}gnulib.mk; sep=$nl |
348 | remove_intl='/^[^#].*\/intl/s/^/#/' | |
46356ea4 | 349 | sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || { |
e70f46d1 PE |
350 | echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." && |
351 | rm -f $dir/gnulib.mk && | |
46356ea4 | 352 | sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk |
e70f46d1 PE |
353 | } |
354 | elif { test "${2+set}" = set && test -r $2/$dir/$file; } || | |
3b2942e6 PE |
355 | grep -F "/$file/" $dir/CVS/Entries 2>/dev/null | |
356 | grep -q '^/[^/]*/[0-9]'; then | |
357 | echo "$0: $dir/$file overrides $1/$dir/$file" | |
358 | else | |
359 | copied=$copied$sep$file; sep=$nl | |
360 | if test $file = gettext.m4; then | |
361 | echo "$0: patching m4/gettext.m4 to remove need for intl/* ..." | |
362 | rm -f $dir/$file | |
363 | sed ' | |
364 | /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\ | |
365 | AC_DEFUN([AM_INTL_SUBDIR], [ | |
366 | /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\ | |
367 | AC_DEFUN([gt_INTL_SUBDIR_CORE], []) | |
368 | $a\ | |
369 | AC_DEFUN([gl_LOCK_EARLY], []) | |
370 | ' $1/$dir/$file >$dir/$file | |
371 | else | |
3b2942e6 PE |
372 | cp_mark_as_generated $1/$dir/$file $dir/$file |
373 | fi | |
374 | fi || exit | |
375 | done | |
376 | ||
377 | ig=$dir/.cvsignore | |
378 | if test -n "$copied" && test -f $ig; then | |
379 | echo "$copied" | sort -u - $ig | cmp -s - $ig || | |
380 | echo "$copied" | sort -u - $ig -o $ig || exit | |
381 | fi | |
382 | done | |
383 | } | |
1f65350a PE |
384 | |
385 | ||
3b2942e6 PE |
386 | # Create boot temporary directories to import from gnulib and gettext. |
387 | ||
388 | bt='.#bootmp' | |
389 | bt2=${bt}2 | |
390 | rm -fr $bt $bt2 && | |
391 | mkdir $bt $bt2 || exit | |
392 | ||
393 | # Import from gnulib. | |
394 | ||
395 | gnulib_tool_options="\ | |
396 | --import\ | |
397 | --no-changelog\ | |
398 | --aux-dir $bt/build-aux\ | |
399 | --doc-base $bt/doc\ | |
400 | --lib lib$package\ | |
401 | --m4-base $bt/m4/\ | |
402 | --source-base $bt/lib/\ | |
403 | --tests-base $bt/tests\ | |
e3ddc1e3 | 404 | --local-dir gl\ |
3b2942e6 PE |
405 | " |
406 | echo "$0: $gnulib_tool $gnulib_tool_options --import ..." | |
407 | $gnulib_tool $gnulib_tool_options --import $gnulib_modules && | |
408 | slurp $bt || exit | |
409 | ||
410 | for file in $gnulib_files; do | |
e70f46d1 | 411 | symlink_to_gnulib $file || exit |
3b2942e6 | 412 | done |
1f65350a | 413 | |
e23d0dd7 | 414 | |
3b2942e6 | 415 | # Import from gettext. |
62a9592d | 416 | |
3b2942e6 PE |
417 | echo "$0: (cd $bt2; autopoint) ..." |
418 | cp configure.ac $bt2 && | |
419 | (cd $bt2 && autopoint && rm configure.ac) && | |
420 | slurp $bt2 $bt || exit | |
b4068c7c | 421 | |
3b2942e6 PE |
422 | rm -fr $bt $bt2 || exit |
423 | ||
424 | ||
425 | # Reconfigure, getting other files. | |
62a9592d PE |
426 | |
427 | for command in \ | |
428 | 'aclocal --force -I m4' \ | |
429 | 'autoconf --force' \ | |
430 | 'autoheader --force' \ | |
431 | 'automake --add-missing --copy --force-missing'; | |
432 | do | |
433 | echo "$0: $command ..." | |
434 | $command || exit | |
435 | done | |
436 | ||
437 | ||
3b2942e6 PE |
438 | # Get some extra files from gnulib, overriding existing files. |
439 | ||
440 | for file in $gnulib_extra_files; do | |
3b2942e6 | 441 | case $file in |
e70f46d1 PE |
442 | */INSTALL) dst=INSTALL;; |
443 | *) dst=$file;; | |
3b2942e6 | 444 | esac |
e70f46d1 | 445 | symlink_to_gnulib $file $dst || exit |
3b2942e6 PE |
446 | done |
447 | ||
448 | ||
449 | # Create gettext configuration. | |
11daa4e7 | 450 | echo "$0: Creating po/Makevars from po/Makevars.template ..." |
3b2942e6 | 451 | rm -f po/Makevars |
11daa4e7 | 452 | sed ' |
3b2942e6 PE |
453 | /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/ |
454 | /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ | |
11daa4e7 PE |
455 | /^XGETTEXT_OPTIONS *=/{ |
456 | s/$/ \\/ | |
457 | a\ | |
3b2942e6 | 458 | '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} |
11daa4e7 PE |
459 | } |
460 | ' po/Makevars.template >po/Makevars | |
1f65350a | 461 | |
3b2942e6 | 462 | if test -d runtime-po; then |
0e2f006a | 463 | # Similarly for runtime-po/Makevars, but not quite the same. |
3b2942e6 PE |
464 | rm -f runtime-po/Makevars |
465 | sed ' | |
0e2f006a PE |
466 | /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/ |
467 | /^subdir *=.*/s/=.*/= runtime-po/ | |
468 | /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ | |
469 | /^XGETTEXT_OPTIONS *=/{ | |
470 | s/$/ \\/ | |
471 | a\ | |
472 | '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+} | |
473 | } | |
474 | ' <po/Makevars.template >runtime-po/Makevars | |
3b2942e6 PE |
475 | |
476 | # Copy identical files from po to runtime-po. | |
477 | (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po) | |
478 | fi | |
1f65350a PE |
479 | |
480 | echo "$0: done. Now you can run './configure'." |