]> git.ipfire.org Git - thirdparty/tar.git/blame - bootstrap
Remove trailing white space.
[thirdparty/tar.git] / bootstrap
CommitLineData
88ffc135
PE
1#! /bin/sh
2
94de7c4c 3# Bootstrap this package from CVS.
88ffc135 4
c17a9f91 5# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
88ffc135
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
120e96c4
PE
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20# 02110-1301, USA.
88ffc135 21
7347b4f5 22# Written by Paul Eggert and Sergey Poznyakoff.
88ffc135 23
94de7c4c 24package=tar
9771467d 25
94de7c4c
PE
26# Translation Project URL, for the registry of all projects.
27TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
28
29# Ensure file names are sorted consistently across platforms.
30# Also, ensure diagnostics are in English, e.g., "wget --help" below.
e24d4efe
PE
31LC_ALL=C
32export LC_ALL
33
9771467d
SP
34usage() {
35 cat <<EOF
7347b4f5 36 usage: $0 [--gnulib-srcdir=DIR][--paxutils-srcdir=DIR][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
9771467d 37 Options are:
7347b4f5
SP
38 --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
39 sources reside. Use this if you already
40 have paxutils sources on your machine, and
41 do not want to waste your bandwidth dowloading
42 them again.
9771467d
SP
43 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
44 sources reside. Use this if you already
45 have gnulib sources on your machine, and
46 do not want to waste your bandwidth dowloading
47 them again.
48 --cvs-auth=METHOD Set the CVS access method used for downloading
49 gnulib files. METHOD is one of the keywords
50 accepted by cvs -d option (see info cvs
51 repository).
52 --cvs-user=USERNAME Set the CVS username to be used when accessing
53 the gnulib repository.
54 --no-po Do not download po files.
df2c78e3 55 --update-po[=LANG] Update po file(s) and exit.
86c379f7 56
c2552c6c 57If the file \`.bootstrap' exists in the current working directory, its
64aea5de
SP
58contents is read, comments and empty lines removed, shell variables expanded
59and the result is prepended to the command line options.
60
9771467d 61Running without arguments will suffice in most cases. It is equivalent
2bda83b4 62to
9771467d 63
c17a9f91 64 ./bootstrap --cvs-auth=pserver
2bda83b4 65
9771467d
SP
66EOF
67}
88ffc135 68
64aea5de
SP
69# Read configuration file
70if [ -r .bootstrap ]; then
71 echo "$0: Reading configuration file .bootstrap"
72 eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
73fi
74
88ffc135
PE
75# Parse options.
76
7631b4e5 77DOWNLOAD_PO=yes
54e32211
PE
78for option
79do
88ffc135
PE
80 case $option in
81 --help)
9771467d 82 usage
88ffc135
PE
83 exit;;
84 --gnulib-srcdir=*)
0ad27d19 85 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
7347b4f5
SP
86 --paxutils-srcdir=*)
87 PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
a0c65636 88 --cvs-auth=*)
0ad27d19 89 CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
a0c65636 90 --cvs-user=*)
0ad27d19 91 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
7631b4e5
SP
92 --no-po)
93 DOWNLOAD_PO=no;;
df2c78e3
SP
94 --update-po=*)
95 DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
325a45f0
SP
96 --update-po)
97 DOWNLOAD_PO=only;;
88ffc135
PE
98 *)
99 echo >&2 "$0: $option: unknown option"
100 exit 1;;
101 esac
102done
103
94de7c4c
PE
104# Get translations.
105
106get_translations() {
107 subdir=$1
108 domain=$2
109 po_file=$3
110
111 echo "$0: getting translations into $subdir for $domain..."
c732eb58
PE
112
113 case $po_file in
114 '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);;
115 esac &&
94de7c4c
PE
116
117 $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
118
119 sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
120 sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
121 awk -F. '
122 { if (lang && $1 != lang) print lang, ver }
123 { lang = $1; ver = substr($0, index($0, ".") + 1) }
124 END { if (lang) print lang, ver }
125 ' |
126 awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
127 {
128 lang = $1
c732eb58 129 if (po_file && po_file != (lang ".po")) next
94de7c4c
PE
130
131 # Work around bugs in translations uncovered by gettext 0.15.
132 # This workaround can be removed once the translations are fixed.
f1309bff 133 if (lang == "hu" || lang == "zh_TW") next
94de7c4c
PE
134
135 ver = $2
136 urlfmt = ""
137 printf "$WGET_COMMAND -O %s/%s.po 'http://www.iro.umontreal.ca/translation/teams/PO/%s/%s-%s.%s.po' &&\n", subdir, lang, lang, domain, ver, lang
138 }
139 END { print ":" }
140 ' |
141 sh &&
142 ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
1942370a 143 rm "$subdir/$domain.html"
94de7c4c
PE
144}
145
146update_po() {
147 if [ $# = 1 ]; then
148 case $1 in
149 *.po) POFILE=$1;;
150 *) POFILE=${1}.po;;
151 esac
c732eb58 152 get_translations po $package "$POFILE"
94de7c4c
PE
153 else
154 get_translations po $package
155 fi
156}
157
158case $DOWNLOAD_PO in
159no) ;;
160*)
161 case `wget --help` in
162 *'--no-cache'*)
163 no_cache='--no-cache';;
164 *'--cache=on/off'*)
165 no_cache='--cache=off';;
166 *)
167 no_cache='';;
168 esac
169
170 WGET_COMMAND="wget -nv $no_cache"
171 export WGET_COMMAND
172esac
173
df2c78e3
SP
174case $DOWNLOAD_PO in
175only) update_po
94de7c4c 176 exit
df2c78e3
SP
177 ;;
178no|yes) ;;
86c379f7 179*) update_po $DOWNLOAD_PO
94de7c4c 180 exit
df2c78e3 181esac
325a45f0 182
94de7c4c
PE
183
184echo "$0: Bootstrapping CVS $package..."
659f70a3 185
a0c65636
SP
186build_cvs_prefix() {
187 CVS_PREFIX=:${1}:
188 if [ "${2}" != - ]; then
189 CVS_PREFIX=${CVS_PREFIX}${2}@
190 fi
9771467d
SP
191 if [ "$1" = "ext" ]; then
192 if [ -z "${CVS_RSH}" ]; then
193 CVS_RSH=ssh
194 export CVS_RSH
195 fi
2bda83b4 196 fi
a0c65636
SP
197}
198
7347b4f5
SP
199# checkout package
200checkout() {
201 if [ ! -d $1 ]; then
202 echo "$0: getting $1 files..."
659f70a3 203
88ffc135 204 trap exit 1 2 13 15
7347b4f5 205 trap 'rm -fr $1; exit 1' 0
2bda83b4 206
c17a9f91
PE
207 case "${CVS_AUTH-pserver}" in
208 pserver) build_cvs_prefix pserver ${CVS_USER:-anonymous}
7347b4f5 209 ;;
659f70a3 210 gserver|server)
7347b4f5
SP
211 build_cvs_prefix $CVS_AUTH ${CVS_USER--}
212 ;;
213 ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
214 ;;
659f70a3 215 *) echo "$0: Unknown CVS access method" >&2
2bda83b4 216 exit 1;;
659f70a3 217 esac
c17a9f91 218 cvs -q -d ${CVS_PREFIX}cvs.sv.gnu.org:/cvsroot/$1 co $1 || exit
659f70a3 219
67c7284d 220 trap - 0
88ffc135 221 fi
7347b4f5
SP
222}
223
18850a18
PE
224gnulib_modules=
225newline='
226'
4d8ddc72
SP
227
228get_modules() {
18850a18
PE
229 new_gnulib_modules=`sed '/^[ ]*#/d; /^[ ]*$/d' $*`
230 case $gnulib_modules,$new_gnulib_modules in
231 ?*,?*) new_gnulib_modules=$newline$new_gnulib_modules;;
232 esac
233 gnulib_modules=$gnulib_modules$new_gnulib_modules
4d8ddc72
SP
234}
235
236# Get paxutils files
237case ${PAXUTILS_SRCDIR--} in
238-) checkout paxutils
239 PAXUTILS_SRCDIR=paxutils
240esac
241
242if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
243 get_modules $PAXUTILS_SRCDIR/gnulib.modules
244fi
245
246# copy_files srcdir dstdir
247copy_files() {
248 for file in `cat $1/DISTFILES`
249 do
250 case $file in
251 "#*") continue;;
252 esac
8f1f0955
SP
253 dst=`echo $file | sed 's^.*/^^'`
254 if [ $# -eq 3 ]; then
c17a9f91 255 case $dst in
8f1f0955
SP
256 ${3}*) ;;
257 *) dst=${3}$dst;;
258 esac
c17a9f91 259 fi
8f1f0955
SP
260 echo "$0: Copying file $1/$file to $2/$dst"
261 cp -p $1/$file $2/$dst
4d8ddc72
SP
262 done
263}
264
265copy_files ${PAXUTILS_SRCDIR}/m4 m4
266echo "$0: Creating m4/paxutils.m4"
267(echo "# This file is generated automatically. Please, do not edit."
268 echo "#"
82b2829e 269 echo "AC_DEFUN([${package}_PAXUTILS],["
4d8ddc72
SP
270 cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
271 echo "])") > ./m4/paxutils.m4
272
273if [ -d rmt ]; then
274 :
275else
276 mkdir rmt
277fi
278
cfe4eef5
SP
279for dir in doc rmt lib tests
280do
281 copy_files ${PAXUTILS_SRCDIR}/$dir $dir
282done
4d8ddc72 283
8f1f0955
SP
284copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
285
7347b4f5
SP
286# Get gnulib files.
287
288case ${GNULIB_SRCDIR--} in
289-) checkout gnulib
290 GNULIB_SRCDIR=gnulib
88ffc135
PE
291esac
292
94de7c4c
PE
293gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
294<$gnulib_tool || exit
88ffc135 295
4d8ddc72 296get_modules gnulib.modules
88ffc135 297
18850a18 298gnulib_modules=`echo "$gnulib_modules" | sort -u`
88ffc135
PE
299previous_gnulib_modules=
300while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
301 previous_gnulib_modules=$gnulib_modules
302 gnulib_modules=`
303 (echo "$gnulib_modules"
304 for gnulib_module in $gnulib_modules; do
fce454b5 305 $gnulib_tool --extract-dependencies $gnulib_module
86c379f7 306 done) | sort -u
88ffc135
PE
307 `
308done
309
310gnulib_files=`
311 (for gnulib_module in $gnulib_modules; do
fce454b5 312 $gnulib_tool --extract-filelist $gnulib_module
88ffc135
PE
313 done) | sort -u
314`
315
316gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
317mkdir -p $gnulib_dirs || exit
318
319for gnulib_file in $gnulib_files; do
320 dest=$gnulib_file
88ffc135
PE
321 rm -f $dest &&
322 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
323 cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
324done
325
94de7c4c
PE
326# This suppresses a bogus diagnostic
327# "warning: macro `AM_LANGINFO_CODESET' not found in library".
328echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
329sed '
330 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
331 AC_DEFUN([AM_INTL_SUBDIR], [])
332 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
333 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
334' m4/gettext.m4 >m4/gettext_gl.m4 || exit
335
c5997e92
SP
336echo "$0: Creating m4/gnulib.m4"
337(echo "# This file is generated automatically. Please, do not edit."
338 echo "#"
82b2829e 339 echo "AC_DEFUN([${package}_GNULIB],["
c5997e92
SP
340 for gnulib_module in $gnulib_modules; do
341 echo "# $gnulib_module"
fce454b5 342 $gnulib_tool --extract-autoconf-snippet $gnulib_module
c5997e92
SP
343 done | sed '/AM_GNU_GETTEXT/d'
344 echo "])") > ./m4/gnulib.m4
345
346echo "$0: Creating lib/Makefile.am"
cad45a0b 347(echo "# This file is generated automatically. Do not edit!"
5be8e9d4 348 cat lib/Makefile.tmpl
86c379f7 349
c5997e92
SP
350 for gnulib_module in $gnulib_modules; do
351 echo "# $gnulib_module"
fce454b5 352 $gnulib_tool --extract-automake-snippet $gnulib_module
82b2829e 353 done | sed "s/lib_SOURCES/lib${package}_a_SOURCES/g" ) > lib/Makefile.am
88ffc135
PE
354
355# Get translations.
7631b4e5 356if test "$DOWNLOAD_PO" = "yes"; then
325a45f0 357 update_po
7631b4e5 358fi
88ffc135
PE
359
360# Reconfigure, getting other files.
361
94de7c4c
PE
362echo "$0: autopoint --force ..."
363autopoint --force || exit
364
365# We don't need intl, so remove it.
366intl_files_to_remove='
367 intl
368 m4/gettext.m4
369 m4/glibc2.m4
370 m4/intdiv0.m4
371 m4/intmax.m4
94de7c4c
PE
372 m4/lcmessage.m4
373 m4/lock.m4
374 m4/printf-posix.m4
375 m4/visibility.m4
376'
377echo $0: rm -fr $intl_files_to_remove ...
378rm -fr $intl_files_to_remove || exit
379
380
381# Undo changes to gnulib files that autoreconf made.
c8c35168 382
94de7c4c
PE
383for gnulib_file in $gnulib_files; do
384 test ! -f $gnulib_file || cmp -s $gnulib_file $GNULIB_SRCDIR/$gnulib_file || {
385 rm -f $gnulib_file &&
386 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file again" &&
387 cp -p $GNULIB_SRCDIR/$gnulib_file $gnulib_file || exit
388 }
389done
390
391# Make sure aclocal.m4 is not older than input files.
392sleep 1
393
394for command in \
395 'aclocal --force -I m4' \
396 'autoconf --force' \
397 'autoheader --force' \
398 'automake --add-missing --copy --force-missing';
399do
400 echo "$0: $command ..."
401 $command || exit
402done
403
404
01b6fb98
PE
405# Create gettext configuration.
406echo "$0: Creating po/Makevars from po/Makevars.template ..."
407sed '
408 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
409 /^XGETTEXT_OPTIONS *=/{
410 s/$/ \\/
411 a\
412 --flag=_:1:pass-c-format \\\
413 --flag=N_:1:pass-c-format \\\
414 --flag=error:3:c-format --flag=error_at_line:5:c-format \\\
415 --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format \\\
416 --flag=argp_error:2:c-format \\\
417 --flag=__argp_error:2:c-format \\\
418 --flag=argp_failure:4:c-format \\\
419 --flag=__argp_failure:4:c-format \\\
420 --flag=argp_fmtstream_printf:2:c-format \\\
421 --flag=__argp_fmtstream_printf:2:c-format
422 }
423' po/Makevars.template >po/Makevars
88ffc135
PE
424
425
426echo "$0: done. Now you can run './configure'."