diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2001-10-31 17:40:07 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2001-10-31 17:40:07 +0000 |
commit | 5b7874aa2ee37af18571327281cc28b3acb702f7 (patch) | |
tree | 3017201abd1c4ed2778e3fb3aa8d07ca90a83188 /gcc/po/exgettext | |
parent | 5fb566020a0d67fd3b911e6b53530b34b2ec5c38 (diff) | |
download | gcc-5b7874aa2ee37af18571327281cc28b3acb702f7.zip gcc-5b7874aa2ee37af18571327281cc28b3acb702f7.tar.gz gcc-5b7874aa2ee37af18571327281cc28b3acb702f7.tar.bz2 |
Makefile.in (INTL_TARGETS, POSUB): Delete all references.
* Makefile.in (INTL_TARGETS, POSUB): Delete all references.
(INTL_SUBDIRS): Just intl.
(.SUFFIXES): Add .gmo .po .pox.
(native): Also depend on build-@POSUB@.
(intl.all, intl.install): Depend on config.h and things it includes.
(po-generated): New target; depend on c-parse.c and tradcif.c.
(install-normal): Also depend on install-@POSUB@.
(XGETTEXT, GMSGFMT, MSGMERGE, PACKAGE, CATALOGS): New variables.
(build-, install-, build-po, update-po, install-po,
.po.gmo, .po.pox, $(PACKAGE).pot, po/$(PACKAGE).pot): New rules.
* aclocal.m4: Prefix each entry in CATALOGS with "po/"
* configure.in: Don't munge XGETTEXT. Don't generate
po/Makefile.in.
* configure: Regenerate.
* exgettext: Delete.
* config/m68k/m68k.h: Add doc strings for -msky and -mnosky.
* cp/Make-lang.in, java/Make-lang.in, objc/Make-lang.in: Replace
$(INTL_TARGETS) with po-generated.
po:
* EXCLUDES: New file.
* exgettext: New helper script; completely rewritten.
* Makefile.in.in, POTFILES.in: Delete.
From-SVN: r46680
Diffstat (limited to 'gcc/po/exgettext')
-rw-r--r-- | gcc/po/exgettext | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/gcc/po/exgettext b/gcc/po/exgettext new file mode 100644 index 0000000..824763f --- /dev/null +++ b/gcc/po/exgettext @@ -0,0 +1,156 @@ +#! /bin/sh +# Wrapper around gettext for GCC sources. +# Copyright 1998, 2001 Free Software Foundation, Inc. + +# Written by Paul Eggert <eggert@twinsun.com>. +# Revised by Zack Weinberg <zackw@stanford.edu> for no-POTFILES operation. + +# This file is part of GNU CC. + +# GNU CC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# GNU CC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU CC; see the file COPYING. If not, write to +# the Free Software Foundation, 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Set environment to default value, if not already set. +: ${AWK=awk} + +# The arguments to this wrapper are: the program to execute, the +# name of the "package", and the path to the source directory. + +if [ $# -ne 3 ] +then echo "usage: $0 <xgettext> <package> <srcdir>" + exit 1 +fi + +xgettext=$1 +package=$2 +srcdir=$3 + +nl=' +' + +set -e + +# Create temporary directory for scratch files. +T=exg$$.d +mkdir $T +trap "rm -r $T" 0 + +pwd=`pwd` +kopt=$pwd/$T/keyword-options +emsg=$pwd/$T/emsgids.c +posr=$pwd/$T/po-sources + +# Locate files to scan, and generate the list. All .c and .h files in +# $srcdir are examined, likewise $srcdir/config and $srcdir/config/* +# (directories). Also, all subdirectories of $srcdir that contain a +# config-lang.in. Exclusions come from $srcdir/po/EXCLUDE. +# +# Then generate keyword options for xgettext, by scanning for declarations +# of functions whose parameter names end in "msgid". +# +# Finally, generate a source file containing all %e strings from +# driver specs, so those can be translated too. +# +# All in one huge awk script. + +echo "scanning for keywords and %e strings..." >&2 + +( cd $srcdir + lang_subdirs=`echo */config-lang.in | sed -e 's|/config-lang\.in||g'` + { echo *.[ch] + echo config/*.[ch] + echo config/*/*.[ch] + for l in $lang_subdirs + do echo $l/*.[ch] + done + } | tr ' ' "$nl" | + $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v emsg=$emsg ' +function keyword_option(line) { + paren_index = index(line, "(") + name = substr(line, 1, paren_index - 1) + sub(/[^0-9A-Z_a-z]*$/, "", name) + sub(/[ ]+PARAMS/, "", name) + sub(/[ ]+VPARAMS/, "", name) + sub(/.*[^0-9A-Z_a-z]/, "", name) + + args = substr(line, paren_index) + sub(/msgid[,\)].*/, "", args) + for (n = 1; sub(/^[^,]*,/, "", args); n++) { + continue + } + + if (n == 1) { keyword = name } + else { keyword = name ":" n } + + if (! keyword_seen[keyword]++) { + print "--keyword=" keyword > kopt + } +} + +function spec_error_string (line) { + while ((percent_index = index(line, "%e")) != 0) { + escape = substr(line, percent_index - 1, 1) + line = substr(line, percent_index + 2) + if (escape == "%") return + + bracket_index = index(line, "}") + if (bracket_index == 0) return + + msgid = substr(line, 1, bracket_index - 1) + if (index(msgid, "%") != 0) return + + printf("#line %d \"%s\"\n", lineno, file) > emsg + printf("_(\"%s\")\n", msgid) > emsg + + line = substr(line, bracket_index + 1) + } +} + +BEGIN { + while ((getline < excl) > 0) { + if ($0 ~ /^#/ || $0 ~ /^[ ]*$/) + continue + excludes[$1] = 1 + } +} + +{ if (!($0 in excludes)) { + print > posr + files[NR] = $0 + } +} + +END { + for (f in files) { + file = files[f] + lineno = 1 + while (getline < file) { + if (/^(#[ ]*define[ ]*)?[A-Za-z_].*\(.*msgid[,\)]/) { + keyword_option($0) + } else if (/%e/) { + spec_error_string($0) + } + lineno++ + } + } + print emsg > posr +}' +) + +# Run the xgettext command, with temporary added as a file to scan. +echo "running xgettext..." >&2 +$xgettext --default-domain=$package --directory=$srcdir \ + --add-comments `cat $kopt` --files-from=$posr \ + -o $package.pot |