X-Git-Url: http://git.jankratochvil.net/?p=macros.git;a=blobdiff_plain;f=AutoGen.pm;h=f2e697839b50ec00752e8ae7972bed9fc4fcc650;hp=4d7428f531bdc2d02d4c41f6f309e3ce516ada39;hb=e9ded2b0602bb3ca136990208f72b21cf4686fd0;hpb=02bad6751e0b4d5bb2f790baa332ad5ce92a05b9 diff --git a/AutoGen.pm b/AutoGen.pm index 4d7428f..f2e6978 100644 --- a/AutoGen.pm +++ b/AutoGen.pm @@ -39,7 +39,7 @@ BEGIN { use File::Touch; # &touch use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG); HERE - eval "$_\n; 1;" or push @missing,(/^\s*use\s+([^\s;]+)/)[0]; + eval "$_\n; 1;" or push @missing,(/^\s*use\s+([^ ;]+)/)[0]; } die "You are missing some modules - install them by:\n" ."\tperl -MCPAN -e 'install qw(".join(" ",@missing).")'\n" @@ -63,6 +63,23 @@ Supported parameters: '.($Options{"help"} || ""); } +sub checkcommandversion +{ +my($class,$command,$version)=@_; + + local *F; + do { open F,$_ or confess "Open $_: $!"; } for ("$command --version|"); + local $/; + undef $/; + my $command_out=; + close F; + my $command_version=($command_out=~m#([\d.]+)#)[0]; + confess "$command(1) version not found in its output" if !$command_version; + confess "'$command' version $version or higher required" + # Do not take 3rd+ numbers as it would not be a number + if ($command_version=~/^(\d+[.]\d+)/)[0]<$version; +} + sub _readfile { my($filename)=@_; @@ -120,6 +137,8 @@ my(@files)=@_; my $nocheck=shift @files if $files[0] eq "nocheck"; my $dest=pop @files; + # expand pattern to properly match © resulting filenames count + @files=map({ glob $_; } @files); @files==copy @files,$dest or $nocheck or confess "$!"; } @@ -130,6 +149,8 @@ my(@files)=@_; my $nocheck=shift @files if $files[0] eq "nocheck"; my $flag=shift @files if ref $files[0]; + # expand pattern to properly match &remove resulting filenames count + @files=map({ glob $_; } @files); @files==remove((!$flag ? () : $flag),@files) or $nocheck or confess "$!"; } @@ -157,9 +178,11 @@ my($class,%args)=@_; my($specsrc)=map((-e $_ ? $_ : "$name.spec.in"),"$name.spec.m4.in"); my $spec=_readfile $specsrc; $spec=~s/\\\n/ /gs; + my $configure_args=($spec=~/^[%]configure\b[ \t]*(.*)$/m)[0]; + $configure_args=~s/--disable-gtk-doc\b/--enable-gtk-doc/g; # optional; gtk-doc reqd for 'make dist' $class->run(%Options, "ARGV"=>["--copy"], - "configure_args"=>[split /\s+/,($spec=~/^%configure\s+(.*)$/m)[0]], + "configure_args"=>[split /\s+/,$configure_args], ); _remove "ChangeLog"; # force its rebuild by Makefile/rcs2log _system "make dist $name.spec"; @@ -219,7 +242,7 @@ sub _cleanfiles ./stamp-h ./stamp-h.in ./stamp-h1 ./install-sh ./aclocal.m4 - ./autom4te-*.cache + ./autom4te.cache ./autom4te-*.cache ./m4 ./missing ./mkinstalldirs @@ -238,11 +261,16 @@ sub _cleanfiles sgml* tmpl* html* + xml *.txt *.txt.bak + *.new + *.sgml *.args *.hierarchy *.signals + *.interfaces + *.prerequisites )); }),$Options{"gtk-doc-dir"}), map((!$_ ? () : do { my $dir=$_; map("$dir/$_",qw( *.html @@ -333,8 +361,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 @@ -429,7 +459,11 @@ my($class,%options)=@_; _writefile $Makefile_in_in,$file; } } - _system "glib-gettextize",@copy_arg if $Options{"want-glib-gettextize"}; + 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"};