diff options
author | jlam <jlam@pkgsrc.org> | 2006-04-13 16:35:57 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2006-04-13 16:35:57 +0000 |
commit | 0f4967eb59854511c3cbd3d80e3a886dd7fb7fc7 (patch) | |
tree | 05edb3a0d35814dcd46fc6d587c479a7a041b561 /devel | |
parent | 56e51ad6bcbe62feec59ad6d8300df92c2e40784 (diff) | |
download | pkgsrc-0f4967eb59854511c3cbd3d80e3a886dd7fb7fc7.tar.gz |
Overhaul the way packages can ask for "msgfmt". If a package needs
msgfmt, then it should set the following in the package Makefile:
USE_TOOLS+= msgfmt
To deal with message files that use the "msgid_plural" statement,
which isn't supported in NetBSD<=3.x and also in gettext<=0.10.35, we
determine if the built-in "msgfmt" is sufficiently new enough to
understand "msgid_plural". If it isn't, then we use the msgfmt.sh
script to transform the msgid_plural statements to an equivalent
construct that's understood by older msgfmt tools.
The msgfmt.sh script is a straightforward translation of the original
perl script msgfmt.pl script by Julio M. Merino Vidal into shell and
awk, which are more lightweight dependencies than perl.
We remove the USE_MSGFMT_PLURALS bits in gettext-lib/builtin.mk as they
are made obsolete by the new code in mk/tools/msgfmt.mk.
BUILD_USE_MSGFMT is still supported but will be removed in a separate
commit.
Diffstat (limited to 'devel')
-rw-r--r-- | devel/gettext-lib/builtin.mk | 36 | ||||
-rw-r--r-- | devel/gettext/files/msgfmt.pl | 170 |
2 files changed, 1 insertions, 205 deletions
diff --git a/devel/gettext-lib/builtin.mk b/devel/gettext-lib/builtin.mk index 8503d268d27..781b69613be 100644 --- a/devel/gettext-lib/builtin.mk +++ b/devel/gettext-lib/builtin.mk @@ -1,4 +1,4 @@ -# $NetBSD: builtin.mk,v 1.31 2006/04/06 06:21:49 reed Exp $ +# $NetBSD: builtin.mk,v 1.32 2006/04/13 16:35:58 jlam Exp $ BUILTIN_PKG:= gettext @@ -206,38 +206,4 @@ CONFIGURE_ARGS+= --without-libintl-prefix . endif . endif -. if defined(USE_MSGFMT_PLURALS) && !empty(USE_MSGFMT_PLURALS:M[Yy][Ee][Ss]) -USE_TOOLS+= perl -CONFIGURE_ENV+= MSGFMT=${BUILDLINK_DIR}/bin/msgfmt - -# XXX _USE_NEW_TOOLS=yes should make "msgfmt" and "msgfmt-plural" into -# XXX tools that can be specified via USE_TOOLS. They would replace -# XXX BUILD_USES_MSGFMT and USE_MSGFMT_PLURALS. -# XXX -BUILDLINK_TARGETS+= buildlink-msgfmt - -buildlink-msgfmt: ${BUILDLINK_DIR}/bin/msgfmt - -${BUILDLINK_DIR}/bin/msgfmt: ${.CURDIR}/../../devel/gettext/files/msgfmt.pl - @ver=`${BUILDLINK_PREFIX.gettext:Q}/bin/msgfmt --version | \ - ${HEAD} -n 1 | ${CUT} -d ' ' -f 4`; \ - ${MKDIR} ${.TARGET:H}; \ - case $${ver} in \ - 0.10.[1-3][0-5]|0.[0-9].*) \ - ${ECHO} "=> Creating msgfmt wrapper to work-around" \ - "plurals"; \ - ${CAT} ${.ALLSRC} | \ - ${SED} -e "s|@PERL@|"${PERL5:Q}"|g" \ - -e "s|@MSGFMT@|"${BUILDLINK_PREFIX.gettext:Q}/bin/msgfmt"|g" \ - > ${.TARGET}; \ - ;; \ - *) \ - ${ECHO} "#! ${SH}" >${.TARGET}; \ - ${ECHO} "${BUILDLINK_PREFIX.gettext:Q}/bin/msgfmt" \ - '"$$@"' >>${.TARGET}; \ - ;; \ - esac; \ - ${CHMOD} +x ${.TARGET} -. endif - .endif # CHECK_BUILTIN.gettext diff --git a/devel/gettext/files/msgfmt.pl b/devel/gettext/files/msgfmt.pl deleted file mode 100644 index 332f851d2cd..00000000000 --- a/devel/gettext/files/msgfmt.pl +++ /dev/null @@ -1,170 +0,0 @@ -#!@PERL@ -# -# $NetBSD: msgfmt.pl,v 1.3 2006/04/06 21:42:23 jmmv Exp $ -# -# msgfmt.pl - Workaround uses of msgid_plural to work with implementations -# that don't support it. -# -# Copyright (c) 2004, 2005, 2006 Julio M. Merino Vidal <jmmv@NetBSD.org> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name of author nor the names of its contributors may -# be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# Parse command line. We copy almost everything as is in the @args array, -# which will be used later when calling the real "msgfmt" utility. As an -# exception, the file name is transformed to the temporary file we will -# use, and the original one is stored in the $file variable. -@args = (); -$file = ""; -$skip = 0; -foreach (@ARGV) { - if ($skip) { - $skip = 0; - } elsif (/^-(a|D|o)$/) { - $skip = 1; - } elsif (/^--(alignment|directory|output-file)$/) { - $skip = 1; - } elsif (/^[^-]/) { - $file = $_; - $_ = "$file.tmp"; - } - - push @args, $_; -} - -# Parse the catalog file to convert msgid_plural entries to the "old" -# format, which handles each of the translations independantly. -open INFILE, $file; -open OUTFILE, ">$file.tmp"; - -printf "Working-around plural forms in $file\n"; -while (<INFILE>) { - @msgid_singular = (); - @msgid_plural = (); - - s/^#~//; - - if (/^msgid[ \t]+(.*)$/) { - push @msgid_singular, "$1\n"; - while (<INFILE>) { - next if /^$/; - - if (/^[ \t]*"/) { - push @msgid_singular, $_; - } else { - last; - } - } - } - - if (/^msgid_plural[ \t]+(.*)$/) { - push @msgid_plural, "$1\n"; - while (<INFILE>) { - if (/^[ \t]*"/) { - push @msgid_plural, $_; - } else { - last; - } - } - } - - if (/^msgstr[ \t]+(.*)$/) { - print OUTFILE "msgid "; - foreach $line (@msgid_singular) { print OUTFILE $line; } - print OUTFILE "msgstr $1\n"; - while (<INFILE>) { - if (/^[ \t]*"/) { - print OUTFILE; - } else { - last; - } - } - } - - if (/^msgstr\[0\][ \t]+(.*)$/) { - print OUTFILE "msgid "; - foreach $line (@msgid_singular) { print OUTFILE $line; } - print OUTFILE "msgstr $1\n"; - while (<INFILE>) { - if (/^[ \t]*"/) { - print OUTFILE; - } else { - last; - } - } - } - - if (/^msgstr\[1\][ \t]+(.*)$/) { - $equal = (@msgid_singular == @msgid_plural); - if ($equal) { - for ($i = 0; $i < @msgid_singular; $i++) { - if (@msgid_singular[$i] ne @msgid_plural[$i]) { - $equal = 0; - last; - } - } - } - - if (! $equal) { - print OUTFILE "msgid "; - foreach $line (@msgid_plural) { print OUTFILE $line; } - print OUTFILE "msgstr $1\n"; - while (<INFILE>) { - if (/^[ \t]*"/) { - print OUTFILE; - } else { - last; - } - } - } else { - while (<INFILE>) { - last if (! /^[ \t]*"/); - } - } - } - - if (/^msgstr\[2\][ \t]+(.*)$/) { - } - - if (/^#/ || /^[ \t]*$/) { - print OUTFILE; - next; - } -} - -close OUTFILE; -close INFILE; - -# Call the real msgfmt utility, using the temporary file as the source -# catalog. -printf "Running `@MSGFMT@ @args'\n"; -$ret = system("@MSGFMT@ @args") >> 8; - -if ($ret == 0) { - unlink "$file.tmp"; -} - -exit $ret; |