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