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.5";
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.
93
my $SRCDIR = $ENV{"srcdir"} || ".";
96
$POTFILES_in = "<$SRCDIR/POTFILES.in";
98
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
103
"help" => \$HELP_ARG,
104
"version" => \$VERSION_ARG,
105
"dist|d" => \$DIST_ARG,
106
"pot|p" => \$POT_ARG,
107
"headers|s" => \$HEADERS_ARG,
108
"maintain|m" => \$MAINTAIN_ARG,
109
"report|r" => \$REPORT_ARG,
110
"verbose|x" => \$VERBOSE,
111
"gettext-package|g=s" => \$GETTEXT_PACKAGE,
112
"output-file|o=s" => \$OUTPUT_FILE,
113
) or &Console_WriteError_InvalidOption;
115
&Console_Write_IntltoolHelp if $HELP_ARG;
116
&Console_Write_IntltoolVersion if $VERSION_ARG;
118
my $arg_count = ($DIST_ARG > 0)
121
+ ($MAINTAIN_ARG > 0)
124
&Console_Write_IntltoolHelp if $arg_count > 1;
126
my $PKGNAME = FindPackageName ();
128
# --version and --help don't require a module name
129
my $MODULE = $GETTEXT_PACKAGE || $PKGNAME || "unknown";
140
elsif ($MAINTAIN_ARG)
148
&Console_Write_CoverageReport;
150
elsif ((defined $ARGV[0]) && $ARGV[0] =~ /^[a-z]/)
154
## Report error if the language file supplied
155
## to the command line is non-existent
156
&Console_WriteError_NotExisting("$SRCDIR/$lang.po")
157
if ! -s "$SRCDIR/$lang.po";
161
print "Working, please wait..." if $VERBOSE;
165
&POFile_Update ($lang, $OUTPUT_FILE);
166
&Console_Write_TranslationStatus ($lang, $OUTPUT_FILE);
170
&Console_Write_IntltoolHelp;
177
sub Console_Write_IntltoolVersion
180
${PROGRAM} (${PACKAGE}) $VERSION
181
Written by Kenneth Christiansen, Maciej Stachowiak, and Darin Adler.
183
Copyright (C) 2000-2003 Free Software Foundation, Inc.
184
This is free software; see the source for copying conditions. There is NO
185
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
190
sub Console_Write_IntltoolHelp
193
Usage: ${PROGRAM} [OPTION]... LANGCODE
194
Updates PO template files and merge them with the translations.
196
Mode of operation (only one is allowed):
197
-p, --pot generate the PO template only
198
-s, --headers generate the header files in POTFILES.in
199
-m, --maintain search for left out files from POTFILES.in
200
-r, --report display a status report for the module
201
-d, --dist merge LANGCODE.po with existing PO template
204
-g, --gettext-package=NAME override PO template name, useful with --pot
205
-o, --output-file=FILE write merged translation to FILE
206
-x, --verbose display lots of feedback
207
--help display this help and exit
208
--version output version information and exit
211
${PROGRAM} --pot just create a new PO template
212
${PROGRAM} xy create new PO template and merge xy.po with it
214
Report bugs to http://bugzilla.gnome.org/ (product name "$PACKAGE")
215
or send email to <xml-i18n-tools\@gnome.org>.
223
my $ret = `echo "$str"`;
225
$ret =~ s/\n$//; # do we need the "s" flag?
230
sub POFile_DetermineType ($)
235
my $xml_regex = "(?:" . $xml_support . ")";
236
my $ini_regex = "(?:" . $ini_support . ")";
237
my $buildin_regex = "(?:" . $buildin_gettext_support . ")";
239
if ($type =~ /\[type: gettext\/([^\]].*)]/)
243
elsif ($type =~ /schemas(\.in)+$/)
245
$gettext_type="schemas";
247
elsif ($type =~ /glade2?(\.in)*$/)
249
$gettext_type="glade";
251
elsif ($type =~ /scm(\.in)*$/)
253
$gettext_type="scheme";
255
elsif ($type =~ /keys(\.in)+$/)
257
$gettext_type="keys";
262
elsif ($type =~ /$xml_regex$/)
266
elsif ($type =~ /$ini_regex$/)
270
elsif ($type =~ /$buildin_regex$/)
272
$gettext_type="buildin";
276
$gettext_type="unknown";
279
return "gettext\/$gettext_type";
282
sub TextFile_DetermineEncoding ($)
284
my $gettext_code="ASCII"; # All files are ASCII by default
285
my $filetype=`file $_ | cut -d ' ' -f 2`;
289
if ($filetype =~ /^(ISO|UTF)/)
291
chomp ($gettext_code = $filetype);
293
elsif ($filetype =~ /^XML/)
295
$gettext_code="UTF-8"; # We asume that .glade and other .xml files are UTF-8
299
return $gettext_code;
302
sub isNotValidMissing
306
return if $file =~ /^\{arch\}\/.*$/;
307
return if $file =~ /^$varhash{"PACKAGE"}-$varhash{"VERSION"}\/.*$/;
314
@buf_i18n_xml_unmarked,
317
@buf_potfiles_ignore,
319
@buf_allfiles_sorted,
320
@buf_potfiles_sorted,
321
@buf_potfiles_ignore_sorted
324
## Search and find all translatable files
326
push @buf_i18n_plain, "$File::Find::name" if /\.($buildin_gettext_support)$/;
327
push @buf_i18n_xml, "$File::Find::name" if /\.($xml_support)$/;
328
push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
329
push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
333
open POTFILES, $POTFILES_in or die "$PROGRAM: there's no POTFILES.in!\n";
334
@buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
337
foreach (@buf_potfiles) {
341
print "Searching for missing translatable files...\n" if $VERBOSE;
343
## Check if we should ignore some found files, when
344
## comparing with POTFILES.in
345
foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
347
(-s "$SRCDIR/$ignore") or next;
349
if ("$ignore" eq "POTFILES.ignore")
351
print "The usage of POTFILES.ignore is deprecated. Please consider moving the\n".
352
"content of this file to POTFILES.skip.\n";
355
print "Found $ignore: Ignoring files...\n" if $VERBOSE;
356
open FILE, "<$SRCDIR/$ignore" or die "ERROR: Failed to open $SRCDIR/$ignore!\n";
360
push @buf_potfiles_ignore, $_ unless /^(#|\s*$)/;
364
@buf_potfiles_ignore_sorted = sort (@buf_potfiles_ignore);
367
foreach my $file (@buf_i18n_plain)
375
# Handle continued multi-line comment.
378
next unless s-.*\*/--;
382
# Handle continued macro.
385
$in_macro = 0 unless /\\$/;
389
# Handle start of macro (or any preprocessor directive).
392
$in_macro = 1 if /^([^\\]|\\.)*\\$/;
396
# Handle comments and quoted text.
397
while (m-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy
408
elsif ($match eq "//")
414
if (!s-$match([^\\]|\\.)*?$match-QUOTEDTEXT-)
416
warn "mismatched quotes at line $. in $file\n";
422
if (/\w\.GetString *\(QUOTEDTEXT/)
424
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
425
## Remove the first 3 chars and add newline
426
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
431
## N_ Q_ and _ are the three macros defined in gi8n.h
432
if (/[NQ]?_ *\(QUOTEDTEXT/)
434
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
435
## Remove the first 3 chars and add newline
436
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
444
foreach my $file (@buf_i18n_xml)
450
# FIXME: share the pattern matching code with intltool-extract
451
if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
453
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
454
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
462
foreach my $file (@buf_i18n_ini)
469
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
470
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
478
foreach my $file (@buf_i18n_xml_unmarked)
480
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
481
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
486
@buf_allfiles_sorted = sort (@buf_allfiles);
487
@buf_potfiles_sorted = sort (@buf_potfiles);
490
foreach (@buf_potfiles_sorted)
495
foreach (@buf_potfiles_ignore_sorted)
502
foreach (@buf_allfiles_sorted)
504
if (!exists($in2{$_}))
510
my @buf_potfiles_notexist;
512
foreach (@buf_potfiles_sorted)
514
chomp (my $dummy = $_);
515
if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
517
push @buf_potfiles_notexist, $_;
521
## Save file with information about the files missing
522
## if any, and give information about this procedure.
523
if (@result + @buf_potfiles_notexist > 0)
527
print "\n" if $VERBOSE;
529
open OUT, ">missing";
532
warn "\e[1mThe following files contain translations and are currently not in use. Please\e[0m\n".
533
"\e[1mconsider adding these to the POTFILES.in file, located in the po/ directory.\e[0m\n\n";
534
print STDERR @result, "\n";
535
warn "If some of these files are left out on purpose then please add them to\n".
536
"POTFILES.skip instead of POTFILES.in. A file \e[1m'missing'\e[0m containing this list\n".
537
"of left out files has been written in the current directory.\n";
539
if (@buf_potfiles_notexist)
542
open OUT, ">notexist";
543
print OUT @buf_potfiles_notexist;
545
warn "\n" if ($VERBOSE or @result);
546
warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
547
warn @buf_potfiles_notexist, "\n";
548
warn "Please remove them from POTFILES.in. A file \e[1m'notexist'\e[0m\n".
549
"containing this list of absent files has been written in the current directory.\n";
553
## If there is nothing to complain about, notify the user
555
print "\nAll files containing translations are present in POTFILES.in.\n" if $VERBOSE;
559
sub Console_WriteError_InvalidOption
561
## Handle invalid arguments
562
print STDERR "Try `${PROGRAM} --help' for more information.\n";
568
my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
570
## Generate the .h header files, so we can allow glade and
571
## xml translation support
574
print STDERR "\n *** The intltool-extract script wasn't found!"
575
."\n *** Without it, intltool-update can not generate files.\n";
580
open (FILE, $POTFILES_in) or die "$PROGRAM: POTFILES.in not found.\n";
585
next if /^\[\s*encoding/;
587
## Find xml files in POTFILES.in and generate the
588
## files with help from the extract script
590
my $gettext_type= &POFile_DetermineType ($1);
592
if (/\.($xml_support|$ini_support)$/ || /^\[/)
596
my $filename = "../$_";
600
system ($EXTRACT, "--update", "--srcdir=$SRCDIR",
601
"--type=$gettext_type", $filename);
605
system ($EXTRACT, "--update", "--type=$gettext_type",
606
"--srcdir=$SRCDIR", "--quiet", $filename);
615
# Generate .pot file from POTFILES.in
617
sub GeneratePOTemplate
619
my $XGETTEXT = $ENV{"XGETTEXT"} || "@INTLTOOL_XGETTEXT@";
620
my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
625
print STDERR " *** xgettext is not found on this system!\n".
626
" *** Without it, intltool-update can not extract strings.\n";
630
print "Building $MODULE.pot...\n" if $VERBOSE;
632
open INFILE, $POTFILES_in;
633
unlink "POTFILES.in.temp";
634
open OUTFILE, ">POTFILES.in.temp" or die("Cannot open POTFILES.in.temp for writing");
636
my $gettext_support_nonascii = 0;
638
# checks for GNU gettext >= 0.12
639
my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
642
$gettext_support_nonascii = 1;
646
# urge everybody to upgrade gettext
647
print STDERR "WARNING: This version of gettext does not support extracting non-ASCII\n".
648
" strings. That means you should install a version of gettext\n".
649
" that supports non-ASCII strings (such as GNU gettext >= 0.12),\n".
650
" or have to let non-ASCII strings untranslated. (If there is any)\n";
653
my $encoding = "ASCII";
654
my $forced_gettext_code;
656
my $encoding_problem_is_reported = 0;
660
next if (/^#/ or /^\s*$/);
666
if (/^\[\s*encoding:\s*(.*)\s*\]/)
668
$forced_gettext_code=$1;
670
elsif (/\.($xml_support|$ini_support)$/ || /^\[/)
673
print OUTFILE "../$_.h\n";
674
push @temp_headers, "../$_.h";
675
$gettext_code = &TextFile_DetermineEncoding ("../$_.h") if ($gettext_support_nonascii and not defined $forced_gettext_code);
679
print OUTFILE "$SRCDIR/../$_\n";
680
$gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
683
next if (! $gettext_support_nonascii);
685
if (defined $forced_gettext_code)
687
$encoding=$forced_gettext_code;
689
elsif (defined $gettext_code and "$encoding" ne "$gettext_code")
691
if ($encoding eq "ASCII")
693
$encoding=$gettext_code;
695
elsif ($gettext_code ne "ASCII")
697
# Only report once because the message is quite long
698
if (! $encoding_problem_is_reported)
700
print STDERR "WARNING: You should use the same file encoding for all your project files,\n".
701
" but $PROGRAM thinks that most of the source files are in\n".
702
" $encoding encoding, while \"$_\" is (likely) in\n".
703
" $gettext_code encoding. If you are sure that all translatable strings\n".
704
" are in same encoding (say UTF-8), please \e[1m*prepend*\e[0m the following\n".
705
" line to POTFILES.in:\n\n".
706
" [encoding: UTF-8]\n\n".
707
" and make sure that configure.in/ac checks for $PACKAGE >= 0.27 .\n".
708
"(such warning message will only be reported once.)\n";
709
$encoding_problem_is_reported = 1;
718
unlink "$MODULE.pot";
719
my @xgettext_argument=("$XGETTEXT",
722
"--output\=$MODULE\.pot",
723
"--files-from\=\.\/POTFILES\.in\.temp");
724
my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
725
push @xgettext_argument, $XGETTEXT_KEYWORDS;
726
my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
727
push @xgettext_argument, "--msgid-bugs-address\=$MSGID_BUGS_ADDRESS" if $MSGID_BUGS_ADDRESS;
728
push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
729
push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
730
my $xgettext_command = join ' ', @xgettext_argument;
732
# intercept xgettext error message
733
print "Running $xgettext_command\n" if $VERBOSE;
734
my $xgettext_error_msg = `$xgettext_command 2>\&1`;
735
my $command_failed = $?;
737
unlink "POTFILES.in.temp";
739
print "Removing generated header (.h) files..." if $VERBOSE;
740
unlink foreach (@temp_headers);
741
print "done.\n" if $VERBOSE;
743
if (! $command_failed)
745
if (! -e "$MODULE.pot")
747
print "None of the files in POTFILES.in contain strings marked for translation.\n" if $VERBOSE;
751
print "Wrote $MODULE.pot\n" if $VERBOSE;
756
if ($xgettext_error_msg =~ /--from-code/)
758
# replace non-ASCII error message with a more useful one.
759
print STDERR "ERROR: xgettext failed to generate PO template file because there is non-ASCII\n".
760
" string marked for translation. Please make sure that all strings marked\n".
761
" for translation are in uniform encoding (say UTF-8), then \e[1m*prepend*\e[0m the\n".
762
" following line to POTFILES.in and rerun $PROGRAM:\n\n".
763
" [encoding: UTF-8]\n\n";
767
print STDERR "$xgettext_error_msg";
768
if (-e "$MODULE.pot")
771
print STDERR "ERROR: xgettext failed but still managed to generate PO template file.\n".
772
" Please consult error message above if there is any.\n";
776
print STDERR "ERROR: xgettext failed to generate PO template file. Please consult\n".
777
" error message above if there is any.\n";
786
-f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
788
my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
789
my ($lang, $outfile) = @_;
791
print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
793
my $infile = "$SRCDIR/$lang.po";
794
$outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
796
# I think msgmerge won't overwrite old file if merge is not successful
797
system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
800
sub Console_WriteError_NotExisting
804
## Report error if supplied language file is non-existing
805
print STDERR "$PROGRAM: $file does not exist!\n";
806
print STDERR "Try '$PROGRAM --help' for more information.\n";
812
my @po_files = glob ("./*.po");
814
@languages = map (&POFile_GetLanguage, @po_files);
816
foreach my $lang (@languages)
818
$po_files_by_lang{$lang} = shift (@po_files);
822
sub POFile_GetLanguage ($)
824
s/^(.*\/)?(.+)\.po$/$2/;
828
sub Console_Write_TranslationStatus
830
my ($lang, $output_file) = @_;
831
my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
833
$output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
835
system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
838
sub Console_Write_CoverageReport
840
my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
844
foreach my $lang (@languages)
847
&POFile_Update ($lang, "");
850
print "\n\n * Current translation support in $MODULE \n\n";
852
foreach my $lang (@languages)
855
system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
859
sub SubstituteVariable
863
# always need to rewind file whenever it has been accessed
866
# cache each variable. varhash is global to we can add
867
# variables elsewhere.
872
($varhash{$1} = $2) =~ s/^["'](.*)["']$/$1/;
876
if ($str =~ /^(.*)\${?([A-Z_]+)}?(.*)$/)
881
# Ignore recursive definitions of variables
882
$sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
884
return SubstituteVariable ("$untouched$sub$rest");
887
# We're using Perl backticks ` and "echo -n" here in order to
888
# expand any shell escapes (such as backticks themselves) in every variable
889
return echo_n ($str);
894
my $base_dirname = getcwd();
895
$base_dirname =~ s@.*/@@;
897
my ($conf_in, $src_dir);
899
if ($base_dirname =~ /^po(-.+)?$/)
906
open (IN, "<Makevars") || die "can't open Makevars: $!";
910
if (/^top_builddir[ \t]*=/)
913
$src_dir =~ s/^top_builddir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
916
if (-f "$src_dir" . "/configure.ac") {
917
$conf_in = "$src_dir" . "/configure.ac" . "\n";
919
$conf_in = "$src_dir" . "/configure.in" . "\n";
926
$conf_in || die "Cannot find top_builddir in Makevars.";
928
elsif (-f "../configure.ac")
930
$conf_in = "../configure.ac";
932
elsif (-f "../configure.in")
934
$conf_in = "../configure.in";
941
open (IN, "<Makefile") || return;
945
if (/^top_srcdir[ \t]*=/)
948
$src_dir =~ s/^top_srcdir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
951
$conf_in = "$src_dir" . "/configure.in" . "\n";
958
$conf_in || die "Cannot find top_srcdir in Makefile.";
961
open (CONF, "<$conf_in");
965
print STDERR "$PROGRAM: Unable to proceed.\n" .
966
"Make sure to run this script inside the po directory.\n";
974
my $domain = &FindMakevarsDomain;
975
my $name = $domain || "untitled";
981
open (IN, "<&CONF") || return $name;
983
local $/; # slurp mode
988
# priority for getting package name:
990
# 2. first argument of AC_INIT (with >= 2 arguments)
991
# 3. first argument of AM_INIT_AUTOMAKE (with >= 2 argument)
993
# /^AM_INIT_AUTOMAKE\([\s\[]*([^,\)\s\]]+)/m
994
# the \s makes this not work, why?
995
if ($conf_source =~ /^AM_INIT_AUTOMAKE\(([^,\)]+),([^,\)]+)/m)
997
($name, $version) = ($1, $2);
998
$name =~ s/[\[\]\s]//g;
999
$version =~ s/[\[\]\s]//g;
1000
$varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1001
$varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1002
$varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1003
$varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1006
if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m)
1008
($name, $version) = ($1, $2);
1009
$name =~ s/[\[\]\s]//g;
1010
$version =~ s/[\[\]\s]//g;
1011
$varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1012
$varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1013
$varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1014
$varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1017
# \s makes this not work, why?
1018
$name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1020
# m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
1021
# as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
1022
$name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1024
$name = $domain if $domain;
1026
$name = SubstituteVariable ($name);
1027
$name =~ s/^["'](.*)["']$/$1/;
1029
return $name if $name;
1036
my $keywords = "--keyword\=\_ --keyword\=N\_ --keyword\=U\_ --keyword\=Q\_";
1037
my $varname = "XGETTEXT_OPTIONS";
1040
open (IN, "<Makevars") || (open(IN, "<Makefile.in.in") && ($varname = "XGETTEXT_KEYWORDS")) || return $keywords;
1042
local $/; # slurp mode
1043
$make_source = <IN>;
1047
$keywords = $1 if $make_source =~ /^$varname[ ]*=\[?([^\n\]]+)/m;
1052
sub FindMakevarsDomain
1056
my $makevars_source; {
1058
open (IN, "<Makevars") || return $domain;
1060
local $/; # slurp mode
1061
$makevars_source = <IN>;
1065
$domain = $1 if $makevars_source =~ /^DOMAIN[ ]*=\[?([^\n\]\$]+)/m;
1066
$domain =~ s/^\s+//;
1067
$domain =~ s/\s+$//;
1072
sub FindMakevarsBugAddress
1076
my $makevars_source; {
1078
open (IN, "<Makevars") || return undef;
1080
local $/; # slurp mode
1081
$makevars_source = <IN>;
1085
$address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
1086
$address =~ s/^\s+//;
1087
$address =~ s/\s+$//;