Utilize gtkdocize(1) of gtk-doc-1.1.
[macros.git] / AutoGen.pm
index aa28398..f2e6978 100644 (file)
@@ -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=<F>;
+       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 &copy 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\b[ \t]*(.*)$/m)[0]],
+                       "configure_args"=>[split /\s+/,$configure_args],
                        );
        _remove "ChangeLog";    # force its rebuild by Makefile/rcs2log
        _system "make dist $name.spec";
@@ -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