pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/tools Overhaul the way packages can ask for "msgfmt...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/08a6a5906d87
branches:  trunk
changeset: 511362:08a6a5906d87
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Thu Apr 13 16:35:57 2006 +0000

description:
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:

 devel/gettext-lib/builtin.mk  |   36 +-------
 devel/gettext/files/msgfmt.pl |  170 -------------------------------------
 mk/bsd.pkg.use.mk             |    7 +-
 mk/tools/bsd.tools.mk         |    3 +-
 mk/tools/msgfmt.mk            |   86 +++++++++++++++++++
 mk/tools/msgfmt.sh            |  189 ++++++++++++++++++++++++++++++++++++++++++
 mk/tools/replace.mk           |   18 +--
 mk/tools/tools.Linux.mk       |    5 +-
 mk/tools/tools.NetBSD.mk      |    5 +-
 9 files changed, 295 insertions(+), 224 deletions(-)

diffs (truncated from 627 to 300 lines):

diff -r c1231027a798 -r 08a6a5906d87 devel/gettext-lib/builtin.mk
--- a/devel/gettext-lib/builtin.mk      Thu Apr 13 14:47:50 2006 +0000
+++ b/devel/gettext-lib/builtin.mk      Thu Apr 13 16:35:57 2006 +0000
@@ -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 @@
 .    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 -r c1231027a798 -r 08a6a5906d87 devel/gettext/files/msgfmt.pl
--- a/devel/gettext/files/msgfmt.pl     Thu Apr 13 14:47:50 2006 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -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@localhost>
-#
-# 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;
diff -r c1231027a798 -r 08a6a5906d87 mk/bsd.pkg.use.mk
--- a/mk/bsd.pkg.use.mk Thu Apr 13 14:47:50 2006 +0000
+++ b/mk/bsd.pkg.use.mk Thu Apr 13 16:35:57 2006 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.pkg.use.mk,v 1.30 2006/03/11 04:01:27 reed Exp $
+#      $NetBSD: bsd.pkg.use.mk,v 1.31 2006/04/13 16:35:58 jlam Exp $
 #
 # Turn USE_* macros into proper depedency logic.  Included near the top of
 # bsd.pkg.mk, after bsd.prefs.mk.
@@ -61,9 +61,8 @@
 
 ### BUILD_USES_MSGFMT
 
-.if defined(BUILD_USES_MSGFMT) && \
-    (!exists(/usr/bin/msgfmt) || ${_USE_GNU_GETTEXT} == "yes")
-BUILD_DEPENDS+=                gettext-tools>=0.14.5:../../devel/gettext-tools
+.if defined(BUILD_USES_MSGFMT)
+USE_TOOLS+=            msgfmt
 .endif
 
 ### PKG_USE_KERBEROS
diff -r c1231027a798 -r 08a6a5906d87 mk/tools/bsd.tools.mk
--- a/mk/tools/bsd.tools.mk     Thu Apr 13 14:47:50 2006 +0000
+++ b/mk/tools/bsd.tools.mk     Thu Apr 13 16:35:57 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.tools.mk,v 1.32 2005/08/10 20:56:20 jlam Exp $
+# $NetBSD: bsd.tools.mk,v 1.33 2006/04/13 16:35:58 jlam Exp $
 #
 # Copyright (c) 2005 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -111,6 +111,7 @@
 .include "../../mk/tools/automake.mk"
 .include "../../mk/tools/autoconf.mk"
 .include "../../mk/tools/texinfo.mk"
+.include "../../mk/tools/msgfmt.mk"
 .include "../../mk/tools/ldconfig.mk"
 .include "../../mk/tools/rpcgen.mk"
 .include "../../mk/tools/strip.mk"
diff -r c1231027a798 -r 08a6a5906d87 mk/tools/msgfmt.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/tools/msgfmt.mk        Thu Apr 13 16:35:57 2006 +0000
@@ -0,0 +1,86 @@
+# $NetBSD: msgfmt.mk,v 1.1 2006/04/13 16:35:58 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# 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. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#        This product includes software developed by the NetBSD
+#        Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation 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.
+#



Home | Main Index | Thread Index | Old Index