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.34.2";
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;
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 = "@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"} || "@INTLTOOL_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 push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
726 push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
727 my $xgettext_command = join ' ', @xgettext_argument;
729 # intercept xgettext error message
730 print "Running $xgettext_command\n" if $VERBOSE;
731 my $xgettext_error_msg = `$xgettext_command 2>\&1`;
732 my $command_failed = $?;
734 unlink "POTFILES.in.temp";
736 print "Removing generated header (.h) files..." if $VERBOSE;
737 unlink foreach (@temp_headers);
738 print "done.\n" if $VERBOSE;
740 if (! $command_failed)
742 if (! -e "$MODULE.pot")
744 print "None of the files in POTFILES.in contain strings marked for translation.\n" if $VERBOSE;
748 print "Wrote $MODULE.pot\n" if $VERBOSE;
753 if ($xgettext_error_msg =~ /--from-code/)
755 # replace non-ASCII error message with a more useful one.
756 print STDERR "ERROR: xgettext failed to generate PO template file because there is non-ASCII\n".
757 " string marked for translation. Please make sure that all strings marked\n".
758 " for translation are in uniform encoding (say UTF-8), then \e[1m*prepend*\e[0m the\n".
759 " following line to POTFILES.in and rerun $PROGRAM:\n\n".
760 " [encoding: UTF-8]\n\n";
764 print STDERR "$xgettext_error_msg";
765 if (-e "$MODULE.pot")
768 print STDERR "ERROR: xgettext failed but still managed to generate PO template file.\n".
769 " Please consult error message above if there is any.\n";
773 print STDERR "ERROR: xgettext failed to generate PO template file. Please consult\n".
774 " error message above if there is any.\n";
783 -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
785 my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
786 my ($lang, $outfile) = @_;
788 print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
790 my $infile = "$SRCDIR/$lang.po";
791 $outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
793 # I think msgmerge won't overwrite old file if merge is not successful
794 system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
797 sub Console_WriteError_NotExisting
801 ## Report error if supplied language file is non-existing
802 print STDERR "$PROGRAM: $file does not exist!\n";
803 print STDERR "Try '$PROGRAM --help' for more information.\n";
809 my @po_files = glob ("./*.po");
811 @languages = map (&POFile_GetLanguage, @po_files);
813 foreach my $lang (@languages)
815 $po_files_by_lang{$lang} = shift (@po_files);
819 sub POFile_GetLanguage ($)
821 s/^(.*\/)?(.+)\.po$/$2/;
825 sub Console_Write_TranslationStatus
827 my ($lang, $output_file) = @_;
828 my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
830 $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
832 system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
835 sub Console_Write_CoverageReport
837 my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
841 foreach my $lang (@languages)
844 &POFile_Update ($lang, "");
847 print "\n\n * Current translation support in $MODULE \n\n";
849 foreach my $lang (@languages)
852 system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
856 sub SubstituteVariable
860 # always need to rewind file whenever it has been accessed
863 # cache each variable. varhash is global to we can add
864 # variables elsewhere.
869 ($varhash{$1} = $2) =~ s/^["'](.*)["']$/$1/;
873 if ($str =~ /^(.*)\${?([A-Z_]+)}?(.*)$/)
877 my $sub = $varhash{$2};
879 return SubstituteVariable ("$untouched$sub$rest");
882 # We're using Perl backticks ` and "echo -n" here in order to
883 # expand any shell escapes (such as backticks themselves) in every variable
884 return echo_n ($str);
889 my $base_dirname = getcwd();
890 $base_dirname =~ s@.*/@@;
892 my ($conf_in, $src_dir);
894 if ($base_dirname =~ /^po(-.+)?$/)
901 open (IN, "<Makevars") || die "can't open Makevars: $!";
905 if (/^top_builddir[ \t]*=/)
908 $src_dir =~ s/^top_builddir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
911 if (-f "$src_dir" . "/configure.ac") {
912 $conf_in = "$src_dir" . "/configure.ac" . "\n";
914 $conf_in = "$src_dir" . "/configure.in" . "\n";
921 $conf_in || die "Cannot find top_builddir in Makevars.";
923 elsif (-f "../configure.ac")
925 $conf_in = "../configure.ac";
927 elsif (-f "../configure.in")
929 $conf_in = "../configure.in";
936 open (IN, "<Makefile") || return;
940 if (/^top_srcdir[ \t]*=/)
943 $src_dir =~ s/^top_srcdir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
946 $conf_in = "$src_dir" . "/configure.in" . "\n";
953 $conf_in || die "Cannot find top_srcdir in Makefile.";
956 open (CONF, "<$conf_in");
960 print STDERR "$PROGRAM: Unable to proceed.\n" .
961 "Make sure to run this script inside the po directory.\n";
969 my $domain = &FindMakevarsDomain;
970 my $name = $domain || "untitled";
976 open (IN, "<&CONF") || return $name;
978 local $/; # slurp mode
983 # priority for getting package name:
985 # 2. first argument of AC_INIT (with >= 2 arguments)
986 # 3. first argument of AM_INIT_AUTOMAKE (with >= 2 argument)
988 # /^AM_INIT_AUTOMAKE\([\s\[]*([^,\)\s\]]+)/m
989 # the \s makes this not work, why?
990 if ($conf_source =~ /^AM_INIT_AUTOMAKE\(([^,\)]+),([^,\)]+)/m)
992 ($name, $version) = ($1, $2);
993 $name =~ s/[\[\]\s]//g;
994 $version =~ s/[\[\]\s]//g;
995 $varhash{"PACKAGE_NAME"} = $name;
996 $varhash{"PACKAGE"} = $name;
997 $varhash{"PACKAGE_VERSION"} = $version;
998 $varhash{"VERSION"} = $version;
1001 if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m)
1003 ($name, $version) = ($1, $2);
1004 $name =~ s/[\[\]\s]//g;
1005 $version =~ s/[\[\]\s]//g;
1006 $varhash{"PACKAGE_NAME"} = $name;
1007 $varhash{"PACKAGE"} = $name;
1008 $varhash{"PACKAGE_VERSION"} = $version;
1009 $varhash{"VERSION"} = $version;
1012 # \s makes this not work, why?
1013 $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1015 # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
1016 # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
1017 $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1019 $name = $domain if $domain;
1021 $name = SubstituteVariable ($name);
1022 $name =~ s/^["'](.*)["']$/$1/;
1024 return $name if $name;
1031 my $keywords = "--keyword\=\_ --keyword\=N\_ --keyword\=U\_ --keyword\=Q\_";
1032 my $varname = "XGETTEXT_OPTIONS";
1035 open (IN, "<Makevars") || (open(IN, "<Makefile.in.in") && ($varname = "XGETTEXT_KEYWORDS")) || return $keywords;
1037 local $/; # slurp mode
1038 $make_source = <IN>;
1042 $keywords = $1 if $make_source =~ /^$varname[ ]*=\[?([^\n\]]+)/m;
1047 sub FindMakevarsDomain
1051 my $makevars_source; {
1053 open (IN, "<Makevars") || return $domain;
1055 local $/; # slurp mode
1056 $makevars_source = <IN>;
1060 $domain = $1 if $makevars_source =~ /^DOMAIN[ ]*=\[?([^\n\]\$]+)/m;
1061 $domain =~ s/^\s+//;
1062 $domain =~ s/\s+$//;