Fixed expansion of [<char0>-<char1>] filename pattern ranges.
[macros.git] / AutoGen.pm
index 5c3c10f..45f6d7e 100644 (file)
@@ -19,6 +19,7 @@
 
 
 package AutoGen;
+require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway
 use vars qw($VERSION);
 $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
 use strict;
@@ -158,7 +159,7 @@ my($class,%args)=@_;
        $spec=~s/\\\n/ /gs;
        $class->run(%Options,
                        "ARGV"=>["--copy"],
-                       "configure_args"=>[split /\s+/,($spec=~/^%configure\s+(.*)$/m)[0]],
+                       "configure_args"=>[split /\s+/,($spec=~/^[%]configure\b[ \t]*(.*)$/m)[0]],
                        );
        _remove "ChangeLog";    # force its rebuild by Makefile/rcs2log
        _system "make dist $name.spec";
@@ -172,7 +173,7 @@ my($class,%args)=@_;
                        ));
        _system "make dist-tarZ" if $Options{"dist-tarZ"};
        _move _rpmeval("_srcrpmdir")."/$name-*.src.rpm",".";
-       _move _rpmeval("_rpmdir")."/"._rpmeval("_arch")."/$name-*."._rpmeval("_arch").".rpm",".";
+       _move _rpmeval("_rpmdir")."/"._rpmeval("_target_cpu")."/$name-*."._rpmeval("_target_cpu").".rpm",".";
   _system "ls -l $name-*";
        exit 0; # should never return
 }
@@ -218,7 +219,7 @@ sub _cleanfiles
                                                ./stamp-h ./stamp-h.in ./stamp-h1
                                                ./install-sh
                                                ./aclocal.m4
-                                               ./autom4te-*.cache
+                                               ./autom4te.cache ./autom4te-*.cache
                                                ./m4
                                                ./missing
                                                ./mkinstalldirs
@@ -332,8 +333,10 @@ sub _expandclass
 my($patt)=@_;
 
        return $patt if $patt!~/\Q[\E(.*?)\Q]\E/;
-       my($pre,$post)=($`,$'); # FIXME: local($`,$') doesn't work - why?
-       return map({ _expandclass("$pre$_$post"); } split("",$1));
+       my($pre,$range,$post)=($`,$1,$');       # FIXME: local($`,$1,$') doesn't work - why?
+       1 while $range=~s#(.)-(.)# join("",map(chr,(ord($1)..ord($2))));
+                       #ge;
+       return map({ _expandclass("$pre$_$post"); } split("",$range));
 }
 
 sub run
@@ -375,6 +378,8 @@ my($class,%options)=@_;
        my $configure_in=_readfile("configure.in");
        do { $$_=1 if !defined($$_) && $configure_in=~/^AM_GNU_GETTEXT\b/m; }
                        for (\$Options{"want-gettextize"});
+       do { $$_=1 if !defined($$_) && $configure_in=~/^AM_GLIB_GNU_GETTEXT\b/m; }
+                       for (\$Options{"want-glib-gettextize"});
        do { $$_=1 if !defined($$_) && $configure_in=~/^AM_PROG_LIBTOOL\b/m; }
                        for (\$Options{"want-libtoolize"}); 
        do { $$_=1 if !defined($$_) && $configure_in=~/^A[CM]_CONFIG_HEADER\b/m; }
@@ -426,6 +431,11 @@ my($class,%options)=@_;
                        _writefile $Makefile_in_in,$file;
                        }
                }
+       if ($Options{"want-glib-gettextize"}) {
+               _system "glib-gettextize",@copy_arg;
+               # "po/ChangeLog" is somehow missing at this point
+               File::Touch->new("atime_only"=>1)->touch("po/ChangeLog");
+               }
        _system "aclocal",map((!$_ ? () : @$_),$Options{"aclocal_args"});
        _system qw(libtoolize),@copy_arg if $Options{"want-libtoolize"};
        _system qw(autoheader) if $Options{"want-autoheader"};
@@ -439,9 +449,12 @@ my($class,%options)=@_;
 
        return if $Options{"ARGV_dist"};
 
+       # 'configure' defaults to CFLAGS '-g -O2' but our --enable-maintainer-mode
+       # should force '-ggdb3'
+       $ENV{"CFLAGS"}||="";
        # shared/static switching cannot be based on maintainer-mode in configure
        _system(qw(./configure --enable-maintainer-mode),
-                       ($Options{"want-libtoolize"} && qw(--enable-shared --disable-static)),
+                       (!$Options{"want-libtoolize"} ? () : qw(--enable-shared --disable-static)),
                        map((!$_ ? () : @$_),$Options{"configure_args"}),
                        );
 }