From: short <> Date: Sat, 16 Aug 2003 07:46:44 +0000 (+0000) Subject: +&checkcommandversion X-Git-Tag: lufs_0_9_6_captive1~24 X-Git-Url: http://git.jankratochvil.net/?p=macros.git;a=commitdiff_plain;h=6c5a7edbfb5b833d42f0b9c4c4844ca366f32025 +&checkcommandversion --- diff --git a/AutoGen.pm b/AutoGen.pm index 796733e..cad8cbf 100644 --- a/AutoGen.pm +++ b/AutoGen.pm @@ -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)=@_;