#! /bin/sh ############################ ## Configuration ############################ GNULIB_DATE=2007-05-12 MODLIST="argp\ fprintftime\ getline\ gettext\ malloc\ memrchr\ mkdtemp\ obstack\ realloc\ regex\ save-cwd\ snprintf\ strtok_r" MODAVOID="xalloc-die openat-die" # Other locale categories that need message catalogs. EXTRA_LOCALE_CATEGORIES= NLS_MARKERS="\ MF_THROW:2\ MF_ASSERT:3\ parse_error:1\ parse_error_locus:2\ mu_error:1\ gacopyz_io_log:3\ gacopyz_logmsg:2\ gacopyz_log:3" # Additional xgettext options to use. Use "\\\newline" to break lines. XGETTEXT_OPTIONS='\\\ --flag=_:1:pass-c-format\\\ --flag=N_:1:pass-c-format\\\ --flag=error:3:c-format --flag=error_at_line:5:c-format\\\ ' COPYRIGHT_HOLDER="Sergey Poznyakoff" # Translation Project URL, for the registry of all projects # and for the translation-team master directory. # (for future use) tp_url() { echo "http://translationproject.org/domain/$1.html" } ############################ ## Implementation ############################ usage() { echo >&2 "\ Usage: $0 [OPTION]... GNULIB_DIR Bootstrap this package from the checked-out sources. --copy Copy files instead of creating symbolic links. --force Attempt to bootstrap even if the sources seem not to have been checked out. --skip-po Do not download po files. --update-po[=LANG] Update po file(s) and exit. The only argument specifes the file name of the directory were gnulib sources are located. You will have to check out them beforehand, \`bootstrap' won't do this for you. Local defaults can be provided by placing the file \`.bootstrap' in the current working directory. The file is read, comments and empty lines are removed, shell variables expanded and the result is prepended to the command line options. Running without arguments will suffice in most cases. " } # Read local configuration file if [ -r .bootstrap ]; then echo "$0: Reading configuration file .bootstrap" eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*" fi extract_package_name=' /^AC_INIT(/{ /.*,.*,.*,/{ s/// s/[][]//g p q } s/AC_INIT(\[*// s/]*,.*// s/^GNU // y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ s/[^A-Za-z0-9_]/-/g p } ' package=`sed -n "$extract_package_name" configure.ac` || exit # Whether to use copies instead of symlinks. copy=false GNULIB_OPTION= DOWNLOAD_PO= for option do case $option in --help) usage exit;; --skip-po | --no-po) # --no-po is for compatibility with 'tar' tradition. DOWNLOAD_PO=skip;; --update-po=*) DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;; --update-po) DOWNLOAD_PO=only;; --copy) copy=true;; -*) echo >&2 "$0: $option: unknown option" exit 1;; *) if [ -n "$NULIB_OPTION" ]; then echo "$0: gnulib directory specified twice">&2 exit 1 fi GNULIB_DIR=$option;; esac done datecmp() { test `echo "1 $1 2 $2" | tr '-' ' ' | sort -n -k2 -k3 -k4 -k1 | sed -n '1s/ .*//p'` -eq 1 } if [ -n "$GNULIB_DIR" ]; then if [ -d "$GNULIB_DIR" ]; then PATH="$GNULIB_DIR:$PATH" if [ -r "$GNULIB_DIR/ChangeLog" ]; then GNULIB_REV=`sed '/^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/q' "$GNULIB_DIR/ChangeLog"` if datecmp "$GNULIB_DATE" "$GNULIB_REV"; then :; else echo "$0: Gnulib version is too old: $GNULIB_REV">&2 echo "$0: It should not be older than $GNULIB_DATE">&2 echo "$0: Please, update gnulib and retry">&2 exit fi else echo "$0: No $GNULIB_DIR/ChangeLog file found">&2 fi else echo "$0: specified gnulib location is not a directory">&2 fi else echo "$0: warning: gnulib source directory not specified">&2 echo "$0: warning: looking for gnulib-tool in PATH...">&2 fi gnulib-tool --version >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "$0: Cannot run gnulib-tool. Try \`$0 --help' for more info.">&2 exit 1 fi echo "$0: Bootstrapping $package" echo "$0: Running autopoint" autopoint -f || exit 1 # Create gettext configuration. echo "$0: Creating po/Makevars from po/Makevars.template ..." rm -f po/Makevars if [ -n "$NLS_MARKERS" ]; then XGETTEXT_OPTIONS="$XGETTEXT_OPTIONS "`echo $NLS_MARKERS | tr ' ' '\n' | sed 's/.*/ --flag=&:pass-c-format\\\\\\\\\\\\/'`" " fi sed ' 1i\ # -*- buffer-read-only: t -*- vi: set ro:\ # DO NOT EDIT! GENERATED AUTOMATICALLY! /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/ /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/ /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ /^XGETTEXT_OPTIONS *=/{ s/$/ \\/ a\ '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} } ' po/Makevars.template >po/Makevars # Get translations. get_translations() { subdir=$1 domain=$2 po_file=$3 case $WGET_COMMAND in '') echo "$0: wget not available; skipping translations";; ?*) url=`tp_url $domain` baseurl=`expr "$url" : '\(.*\)/.*'` echo "$0: getting translations into $subdir for $domain..." && case $po_file in '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);; esac && $WGET_COMMAND -O "$subdir/$domain.html" "$url" && sed -n 's|.*href="\(.*\)/\([^/][^/]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\2:\3:\1|p' <"$subdir/$domain.html" | sort -t: -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 | awk -F: ' { if (lang && $1 != lang) print lang, ver, $3 } { lang = $1; ver = $2 } END { if (lang) print lang, ver, $3 } ' | awk -v domain="$domain" -v baseurl="$baseurl" -v subdir="$subdir" \ -v po_file="$po_file" ' { lang = $1 if (po_file && po_file != (lang ".po")) next ver = $2 printf "{ $WGET_COMMAND -O %s/%s.po %s/%s/%s/%s-%s.%s.po &&\n", subdir, lang, baseurl, $3, lang, domain, ver, lang printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang printf " rm -f %s/%s.po; }; } &&\n", subdir, lang } END { print ":" } ' | WGET_COMMAND="$WGET_COMMAND" sh ;; esac && ls "$subdir"/*.po 2>/dev/null | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" && rm -f "$subdir/$domain.html" } save_LC_ALL="$LC_ALL" LC_ALL=C case `wget --help` in *'--no-cache'*) WGET_COMMAND='wget -nv --no-cache';; *'--cache=on/off'*) WGET_COMMAND='wget -nv --cache=off';; *'--non-verbose'*) WGET_COMMAND='wget -nv';; *) WGET_COMMAND='';; esac LC_ALL="$save_LC_ALL" case $DOWNLOAD_PO in 'skip') ;; '') get_translations po $package || exit ;; 'only') get_translations po $package exit ;; *.po) get_translations po $package "$DOWNLOAD_PO" exit ;; *) get_translations po $package "${DOWNLOAD_PO}.po" exit esac echo "$0: Importing gnulib files ..." if [ -n "$MODAVOID" ]; then gnulib_tool_options="`echo $MODAVOID | sed 's/\([^ ][^ ]*\)/--avoid &/g'`" fi gnulib-tool --import $gnulib_tool_options $MODLIST echo "$0: Reconfiguring ..." for command in \ 'aclocal --force -I m4' \ 'autoconf --force' \ 'autoheader --force' \ 'automake --add-missing --copy --force-missing'; do echo "$0: $command ..." $command || exit done echo "$0: done. Now you can run './configure'."