1 #!/scratchbox/tools/bin/perl -w
2 # -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 4 -*-
5 # The Intltool Message Updater
7 # Copyright (C) 2000-2003 Free Software Foundation.
9 # Intltool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # version 2 published by the Free Software Foundation.
13 # Intltool is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
27 # Authors: Kenneth Christiansen <kenneth@gnu.org>
29 # Darin Adler <darin@bentspoon.com>
31 ## Release information
32 my $PROGRAM = "intltool-update";
33 my $VERSION = "0.35.0";
34 my $PACKAGE = "intltool";
43 ## Scalars used by the option stuff
52 my $GETTEXT_PACKAGE = "";
57 my %po_files_by_lang = ();
59 # Regular expressions to categorize file types.
60 # FIXME: Please check if the following is correct
63 "xml(?:\\.in)*|". # http://www.w3.org/XML/ (Note: .in is not required)
64 "ui|". # Bonobo specific - User Interface desc. files
66 "glade2?(?:\\.in)*|". # Glade specific - User Interface desc. files (Note: .in is not required)
67 "scm(?:\\.in)*|". # ? (Note: .in is not required)
68 "oaf(?:\\.in)+|". # DEPRECATED: Replaces by Bonobo .server files
70 "server(?:\\.in)+|". # Bonobo specific
71 "sheet(?:\\.in)+|". # ?
72 "schemas(?:\\.in)+|". # GConf specific
73 "pong(?:\\.in)+|". # DEPRECATED: PONG is not used [by GNOME] any longer.
74 "kbd(?:\\.in)+"; # GOK specific.
77 "icon(?:\\.in)+|". # http://www.freedesktop.org/Standards/icon-theme-spec
78 "desktop(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
79 "caves(?:\\.in)+|". # GNOME Games specific
80 "directory(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
81 "soundlist(?:\\.in)+|". # GNOME specific
82 "keys(?:\\.in)+|". # GNOME Mime database specific
83 "theme(?:\\.in)+|". # http://www.freedesktop.org/Standards/icon-theme-spec
84 "service(?:\\.in)+"; # DBus specific
86 my $buildin_gettext_support =
87 "c|y|cs|cc|cpp|c\\+\\+|h|hh|gob|py";
89 ## Always flush buffer when printing
92 ## Sometimes the source tree will be rooted somewhere else.
96 $SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
97 $POTFILES_in = "<$SRCDIR/POTFILES.in";
99 my $devnull = ($^O
eq 'MSWin32' ?
'NUL:' : '/dev/null');
104 "help" => \
$HELP_ARG,
105 "version" => \
$VERSION_ARG,
106 "dist|d" => \
$DIST_ARG,
107 "pot|p" => \
$POT_ARG,
108 "headers|s" => \
$HEADERS_ARG,
109 "maintain|m" => \
$MAINTAIN_ARG,
110 "report|r" => \
$REPORT_ARG,
111 "verbose|x" => \
$VERBOSE,
112 "gettext-package|g=s" => \
$GETTEXT_PACKAGE,
113 "output-file|o=s" => \
$OUTPUT_FILE,
114 ) or &Console_WriteError_InvalidOption
;
116 &Console_Write_IntltoolHelp
if $HELP_ARG;
117 &Console_Write_IntltoolVersion
if $VERSION_ARG;
119 my $arg_count = ($DIST_ARG > 0)
122 + ($MAINTAIN_ARG > 0)
125 &Console_Write_IntltoolHelp
if $arg_count > 1;
127 # --version and --help don't require a module name
128 my $MODULE = $GETTEXT_PACKAGE || &FindPackageName
|| "unknown";
139 elsif ($MAINTAIN_ARG)
147 &Console_Write_CoverageReport
;
149 elsif ((defined $ARGV[0]) && $ARGV[0] =~ /^[a-z]/)
153 ## Report error if the language file supplied
154 ## to the command line is non-existent
155 &Console_WriteError_NotExisting
("$SRCDIR/$lang.po")
156 if ! -s
"$SRCDIR/$lang.po";
160 print "Working, please wait..." if $VERBOSE;
164 &POFile_Update
($lang, $OUTPUT_FILE);
165 &Console_Write_TranslationStatus
($lang, $OUTPUT_FILE);
169 &Console_Write_IntltoolHelp
;
176 sub Console_Write_IntltoolVersion
179 ${PROGRAM
} (${PACKAGE
}) $VERSION
180 Written by Kenneth Christiansen
, Maciej Stachowiak
, and Darin Adler
.
182 Copyright
(C
) 2000-2003 Free Software Foundation
, Inc
.
183 This is free software
; see the source
for copying conditions
. There is NO
184 warranty
; not even
for MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
.
189 sub Console_Write_IntltoolHelp
192 Usage
: ${PROGRAM
} [OPTION
]... LANGCODE
193 Updates PO template files
and merge them with the translations
.
195 Mode of operation
(only one is allowed
):
196 -p
, --pot generate the PO template only
197 -s
, --headers generate the header files
in POTFILES
.in
198 -m
, --maintain search
for left out files from POTFILES
.in
199 -r
, --report display a status report
for the module
200 -d
, --dist merge LANGCODE
.po with existing PO template
203 -g
, --gettext
-package=NAME override PO template name
, useful with
--pot
204 -o
, --output
-file
=FILE
write merged translation to FILE
205 -x
, --verbose display lots of feedback
206 --help display this help
and exit
207 --version output version information
and exit
210 ${PROGRAM
} --pot just create a new PO template
211 ${PROGRAM
} xy create new PO template
and merge xy
.po with it
213 Report bugs to http
://bugzilla
.gnome
.org
/ (product name
"$PACKAGE")
214 or send email to
<xml
-i18n
-tools\
@gnome.org
>.
222 my $ret = `echo "$str"`;
224 $ret =~ s/\n$//; # do we need the "s" flag?
229 sub POFile_DetermineType
($)
234 my $xml_regex = "(?:" . $xml_support . ")";
235 my $ini_regex = "(?:" . $ini_support . ")";
236 my $buildin_regex = "(?:" . $buildin_gettext_support . ")";
238 if ($type =~ /\[type: gettext\/([^\
]].*)]/)
242 elsif ($type =~ /schemas(\.in)+$/)
244 $gettext_type="schemas";
246 elsif ($type =~ /glade2?(\.in)*$/)
248 $gettext_type="glade";
250 elsif ($type =~ /scm(\.in)*$/)
252 $gettext_type="scheme";
254 elsif ($type =~ /keys(\.in)+$/)
256 $gettext_type="keys";
261 elsif ($type =~ /$xml_regex$/)
265 elsif ($type =~ /$ini_regex$/)
269 elsif ($type =~ /$buildin_regex$/)
271 $gettext_type="buildin";
275 $gettext_type="unknown";
278 return "gettext\/$gettext_type";
281 sub TextFile_DetermineEncoding
($)
283 my $gettext_code="ASCII"; # All files are ASCII by default
284 my $filetype=`file $_ | cut -d ' ' -f 2`;
288 if ($filetype =~ /^(ISO|UTF)/)
290 chomp ($gettext_code = $filetype);
292 elsif ($filetype =~ /^XML/)
294 $gettext_code="UTF-8"; # We asume that .glade and other .xml files are UTF-8
298 return $gettext_code;
301 sub isNotValidMissing
305 return if $file =~ /^\{arch\}\/.*$/;
306 return if $file =~ /^$varhash{"PACKAGE"}-$varhash{"VERSION"}\/.*$/;
313 @buf_i18n_xml_unmarked,
316 @buf_potfiles_ignore,
318 @buf_allfiles_sorted,
322 ## Search and find all translatable files
324 push @buf_i18n_plain, "$File::Find::name" if /\.($buildin_gettext_support)$/;
325 push @buf_i18n_xml, "$File::Find::name" if /\.($xml_support)$/;
326 push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
327 push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
331 open POTFILES
, $POTFILES_in or die "$PROGRAM: there's no POTFILES.in!\n";
332 @buf_potfiles = grep !/^(#|\s*$)/, <POTFILES
>;
335 foreach (@buf_potfiles) {
339 print "Searching for missing translatable files...\n" if $VERBOSE;
341 ## Check if we should ignore some found files, when
342 ## comparing with POTFILES.in
343 foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
345 (-s
$ignore) or next;
347 if ("$ignore" eq "POTFILES.ignore")
349 print "The usage of POTFILES.ignore is deprecated. Please consider moving the\n".
350 "content of this file to POTFILES.skip.\n";
353 print "Found $ignore: Ignoring files...\n" if $VERBOSE;
354 open FILE
, "<$ignore" or die "ERROR: Failed to open $ignore!\n";
358 push @buf_potfiles_ignore, $_ unless /^(#|\s*$)/;
362 @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
365 foreach my $file (@buf_i18n_plain)
373 # Handle continued multi-line comment.
376 next unless s
-.*\
*/--;
380 # Handle continued macro.
383 $in_macro = 0 unless /\\$/;
387 # Handle start of macro (or any preprocessor directive).
390 $in_macro = 1 if /^([^\\]|\\.)*\\$/;
394 # Handle comments and quoted text.
395 while (m
-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy
406 elsif ($match eq "//")
412 if (!s
-$match([^\\]|\\.)*?
$match-QUOTEDTEXT
-)
414 warn "mismatched quotes at line $. in $file\n";
420 if (/\.GetString ?\(QUOTEDTEXT/)
422 if (defined isNotValidMissing
(unpack("x3 A*", $file))) {
423 ## Remove the first 3 chars and add newline
424 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
431 if (defined isNotValidMissing
(unpack("x3 A*", $file))) {
432 ## Remove the first 3 chars and add newline
433 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
441 foreach my $file (@buf_i18n_xml)
447 # FIXME: share the pattern matching code with intltool-extract
448 if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
450 if (defined isNotValidMissing
(unpack("x3 A*", $file))) {
451 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
459 foreach my $file (@buf_i18n_ini)
466 if (defined isNotValidMissing
(unpack("x3 A*", $file))) {
467 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
475 foreach my $file (@buf_i18n_xml_unmarked)
477 if (defined isNotValidMissing
(unpack("x3 A*", $file))) {
478 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
483 @buf_allfiles_sorted = sort (@buf_allfiles);
484 @buf_potfiles_sorted = sort (@buf_potfiles);
487 foreach (@buf_potfiles_sorted)
494 foreach (@buf_allfiles_sorted)
496 if (!exists($in2{$_}))
502 my @buf_potfiles_notexist;
504 foreach (@buf_potfiles_sorted)
506 chomp (my $dummy = $_);
507 if ("$dummy" ne "" and ! -f
"../$dummy")
509 push @buf_potfiles_notexist, $_;
513 ## Save file with information about the files missing
514 ## if any, and give information about this procedure.
515 if (@result + @buf_potfiles_notexist > 0)
519 print "\n" if $VERBOSE;
521 open OUT
, ">missing";
524 warn "\e[1mThe following files contain translations and are currently not in use. Please\e[0m\n".
525 "\e[1mconsider adding these to the POTFILES.in file, located in the po/ directory.\e[0m\n\n";
526 print STDERR
@result, "\n";
527 warn "If some of these files are left out on purpose then please add them to\n".
528 "POTFILES.skip instead of POTFILES.in. A file \e[1m'missing'\e[0m containing this list\n".
529 "of left out files has been written in the current directory.\n";
531 if (@buf_potfiles_notexist)
534 open OUT
, ">notexist";
535 print OUT
@buf_potfiles_notexist;
537 warn "\n" if ($VERBOSE or @result);
538 warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
539 warn @buf_potfiles_notexist, "\n";
540 warn "Please remove them from POTFILES.in or POTFILES.skip. A file \e[1m'notexist'\e[0m\n".
541 "containing this list of absent files has been written in the current directory.\n";
545 ## If there is nothing to complain about, notify the user
547 print "\nAll files containing translations are present in POTFILES.in.\n" if $VERBOSE;
551 sub Console_WriteError_InvalidOption
553 ## Handle invalid arguments
554 print STDERR
"Try `${PROGRAM} --help' for more information.\n";
560 my $EXTRACT = "/home/thp/pkg/maemopadplus-0.34/intltool-extract";
563 $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
565 ## Generate the .h header files, so we can allow glade and
566 ## xml translation support
569 print STDERR
"\n *** The intltool-extract script wasn't found!"
570 ."\n *** Without it, intltool-update can not generate files.\n";
575 open (FILE
, $POTFILES_in) or die "$PROGRAM: POTFILES.in not found.\n";
580 next if /^\[\s*encoding/;
582 ## Find xml files in POTFILES.in and generate the
583 ## files with help from the extract script
585 my $gettext_type= &POFile_DetermineType
($1);
587 if (/\.($xml_support|$ini_support)$/ || /^\[/)
591 my $filename = "../$_";
595 system ($EXTRACT, "--update", "--srcdir=$SRCDIR",
596 "--type=$gettext_type", $filename);
600 system ($EXTRACT, "--update", "--type=$gettext_type",
601 "--srcdir=$SRCDIR", "--quiet", $filename);
610 # Generate .pot file from POTFILES.in
612 sub GeneratePOTemplate
614 my $XGETTEXT = $ENV{"XGETTEXT"} || "/scratchbox/tools/bin/xgettext";
615 my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
620 print STDERR
" *** xgettext is not found on this system!\n".
621 " *** Without it, intltool-update can not extract strings.\n";
625 print "Building $MODULE.pot...\n" if $VERBOSE;
627 open INFILE
, $POTFILES_in;
628 unlink "POTFILES.in.temp";
629 open OUTFILE
, ">POTFILES.in.temp" or die("Cannot open POTFILES.in.temp for writing");
631 my $gettext_support_nonascii = 0;
633 # checks for GNU gettext >= 0.12
634 my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
637 $gettext_support_nonascii = 1;
641 # urge everybody to upgrade gettext
642 print STDERR
"WARNING: This version of gettext does not support extracting non-ASCII\n".
643 " strings. That means you should install a version of gettext\n".
644 " that supports non-ASCII strings (such as GNU gettext >= 0.12),\n".
645 " or have to let non-ASCII strings untranslated. (If there is any)\n";
648 my $encoding = "ASCII";
649 my $forced_gettext_code;
651 my $encoding_problem_is_reported = 0;
655 next if (/^#/ or /^\s*$/);
661 if (/^\[\s*encoding:\s*(.*)\s*\]/)
663 $forced_gettext_code=$1;
665 elsif (/\.($xml_support|$ini_support)$/ || /^\[/)
668 print OUTFILE
"../$_.h\n";
669 push @temp_headers, "../$_.h";
670 $gettext_code = &TextFile_DetermineEncoding
("../$_.h") if ($gettext_support_nonascii and not defined $forced_gettext_code);
674 if ($SRCDIR eq ".") {
675 print OUTFILE
"../$_\n";
677 print OUTFILE
"$SRCDIR/../$_\n";
679 $gettext_code = &TextFile_DetermineEncoding
("../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
682 next if (! $gettext_support_nonascii);
684 if (defined $forced_gettext_code)
686 $encoding=$forced_gettext_code;
688 elsif (defined $gettext_code and "$encoding" ne "$gettext_code")
690 if ($encoding eq "ASCII")
692 $encoding=$gettext_code;
694 elsif ($gettext_code ne "ASCII")
696 # Only report once because the message is quite long
697 if (! $encoding_problem_is_reported)
699 print STDERR
"WARNING: You should use the same file encoding for all your project files,\n".
700 " but $PROGRAM thinks that most of the source files are in\n".
701 " $encoding encoding, while \"$_\" is (likely) in\n".
702 " $gettext_code encoding. If you are sure that all translatable strings\n".
703 " are in same encoding (say UTF-8), please \e[1m*prepend*\e[0m the following\n".
704 " line to POTFILES.in:\n\n".
705 " [encoding: UTF-8]\n\n".
706 " and make sure that configure.in/ac checks for $PACKAGE >= 0.27 .\n".
707 "(such warning message will only be reported once.)\n";
708 $encoding_problem_is_reported = 1;
717 unlink "$MODULE.pot";
718 my @xgettext_argument=("$XGETTEXT",
721 "--output\=$MODULE\.pot",
722 "--files-from\=\.\/POTFILES\.in\.temp");
723 my $XGETTEXT_KEYWORDS = &FindPOTKeywords
;
724 push @xgettext_argument, $XGETTEXT_KEYWORDS;
725 my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress
;
726 push @xgettext_argument, "--msgid-bugs-address\=$MSGID_BUGS_ADDRESS" if $MSGID_BUGS_ADDRESS;
727 push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
728 push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
729 my $xgettext_command = join ' ', @xgettext_argument;
731 # intercept xgettext error message
732 print "Running $xgettext_command\n" if $VERBOSE;
733 my $xgettext_error_msg = `$xgettext_command 2>\&1`;
734 my $command_failed = $?
;
736 unlink "POTFILES.in.temp";
738 print "Removing generated header (.h) files..." if $VERBOSE;
739 unlink foreach (@temp_headers);
740 print "done.\n" if $VERBOSE;
742 if (! $command_failed)
744 if (! -e
"$MODULE.pot")
746 print "None of the files in POTFILES.in contain strings marked for translation.\n" if $VERBOSE;
750 print "Wrote $MODULE.pot\n" if $VERBOSE;
755 if ($xgettext_error_msg =~ /--from-code/)
757 # replace non-ASCII error message with a more useful one.
758 print STDERR
"ERROR: xgettext failed to generate PO template file because there is non-ASCII\n".
759 " string marked for translation. Please make sure that all strings marked\n".
760 " for translation are in uniform encoding (say UTF-8), then \e[1m*prepend*\e[0m the\n".
761 " following line to POTFILES.in and rerun $PROGRAM:\n\n".
762 " [encoding: UTF-8]\n\n";
766 print STDERR
"$xgettext_error_msg";
767 if (-e
"$MODULE.pot")
770 print STDERR
"ERROR: xgettext failed but still managed to generate PO template file.\n".
771 " Please consult error message above if there is any.\n";
775 print STDERR
"ERROR: xgettext failed to generate PO template file. Please consult\n".
776 " error message above if there is any.\n";
785 -f
"$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
787 my $MSGMERGE = $ENV{"MSGMERGE"} || "/scratchbox/tools/bin/msgmerge";
788 my ($lang, $outfile) = @_;
790 print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
792 my $infile = "$SRCDIR/$lang.po";
793 $outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
795 # I think msgmerge won't overwrite old file if merge is not successful
796 system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
799 sub Console_WriteError_NotExisting
803 ## Report error if supplied language file is non-existing
804 print STDERR
"$PROGRAM: $file does not exist!\n";
805 print STDERR
"Try '$PROGRAM --help' for more information.\n";
811 my @po_files = glob ("./*.po");
813 @languages = map (&POFile_GetLanguage
, @po_files);
815 foreach my $lang (@languages)
817 $po_files_by_lang{$lang} = shift (@po_files);
821 sub POFile_GetLanguage
($)
823 s/^(.*\/)?(.+)\.po$/$2/;
827 sub Console_Write_TranslationStatus
829 my ($lang, $output_file) = @_;
830 my $MSGFMT = $ENV{"MSGFMT"} || "/scratchbox/tools/bin/msgfmt";
832 $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
834 system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
837 sub Console_Write_CoverageReport
839 my $MSGFMT = $ENV{"MSGFMT"} || "/scratchbox/tools/bin/msgfmt";
843 foreach my $lang (@languages)
846 &POFile_Update
($lang, "");
849 print "\n\n * Current translation support in $MODULE \n\n";
851 foreach my $lang (@languages)
854 system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
858 sub SubstituteVariable
862 # always need to rewind file whenever it has been accessed
865 # cache each variable. varhash is global to we can add
866 # variables elsewhere.
871 ($varhash{$1} = $2) =~ s/^["'](.*)["']$/$1/;
875 if ($str =~ /^(.*)\${?([A-Z_]+)}?(.*)$/)
880 # Ignore recursive definitions of variables
881 $sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
883 return SubstituteVariable
("$untouched$sub$rest");
886 # We're using Perl backticks ` and "echo -n" here in order to
887 # expand any shell escapes (such as backticks themselves) in every variable
888 return echo_n
($str);
893 my $base_dirname = getcwd
();
894 $base_dirname =~ s@
.*/@@
;
896 my ($conf_in, $src_dir);
898 if ($base_dirname =~ /^po(-.+)?$/)
905 open (IN
, "<Makevars") || die "can't open Makevars: $!";
909 if (/^top_builddir[ \t]*=/)
912 $src_dir =~ s/^top_builddir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
915 if (-f
"$src_dir" . "/configure.ac") {
916 $conf_in = "$src_dir" . "/configure.ac" . "\n";
918 $conf_in = "$src_dir" . "/configure.in" . "\n";
925 $conf_in || die "Cannot find top_builddir in Makevars.";
927 elsif (-f
"../configure.ac")
929 $conf_in = "../configure.ac";
931 elsif (-f
"../configure.in")
933 $conf_in = "../configure.in";
940 open (IN
, "<Makefile") || return;
944 if (/^top_srcdir[ \t]*=/)
947 $src_dir =~ s/^top_srcdir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
950 $conf_in = "$src_dir" . "/configure.in" . "\n";
957 $conf_in || die "Cannot find top_srcdir in Makefile.";
960 open (CONF
, "<$conf_in");
964 print STDERR
"$PROGRAM: Unable to proceed.\n" .
965 "Make sure to run this script inside the po directory.\n";
973 my $domain = &FindMakevarsDomain
;
974 my $name = $domain || "untitled";
980 open (IN
, "<&CONF") || return $name;
982 local $/; # slurp mode
987 # priority for getting package name:
989 # 2. first argument of AC_INIT (with >= 2 arguments)
990 # 3. first argument of AM_INIT_AUTOMAKE (with >= 2 argument)
992 # /^AM_INIT_AUTOMAKE\([\s\[]*([^,\)\s\]]+)/m
993 # the \s makes this not work, why?
994 if ($conf_source =~ /^AM_INIT_AUTOMAKE\(([^,\)]+),([^,\)]+)/m)
996 ($name, $version) = ($1, $2);
997 $name =~ s/[\[\]\s]//g;
998 $version =~ s/[\[\]\s]//g;
999 $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1000 $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1001 $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1002 $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1005 if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m)
1007 ($name, $version) = ($1, $2);
1008 $name =~ s/[\[\]\s]//g;
1009 $version =~ s/[\[\]\s]//g;
1010 $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1011 $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1012 $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1013 $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1016 # \s makes this not work, why?
1017 $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1019 # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
1020 # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
1021 $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1023 $name = $domain if $domain;
1025 $name = SubstituteVariable
($name);
1026 $name =~ s/^["'](.*)["']$/$1/;
1028 return $name if $name;
1035 my $keywords = "--keyword\=\_ --keyword\=N\_ --keyword\=U\_ --keyword\=Q\_";
1036 my $varname = "XGETTEXT_OPTIONS";
1039 open (IN
, "<Makevars") || (open(IN
, "<Makefile.in.in") && ($varname = "XGETTEXT_KEYWORDS")) || return $keywords;
1041 local $/; # slurp mode
1042 $make_source = <IN
>;
1046 $keywords = $1 if $make_source =~ /^$varname[ ]*=\[?([^\n\]]+)/m;
1051 sub FindMakevarsDomain
1055 my $makevars_source; {
1057 open (IN
, "<Makevars") || return $domain;
1059 local $/; # slurp mode
1060 $makevars_source = <IN
>;
1064 $domain = $1 if $makevars_source =~ /^DOMAIN[ ]*=\[?([^\n\]\$]+)/m;
1065 $domain =~ s/^\s+//;
1066 $domain =~ s/\s+$//;
1071 sub FindMakevarsBugAddress
1075 my $makevars_source; {
1077 open (IN
, "<Makevars") || return undef;
1079 local $/; # slurp mode
1080 $makevars_source = <IN
>;
1084 $address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
1085 $address =~ s/^\s+//;
1086 $address =~ s/\s+$//;