Last change
on this file was
6117,
checked in by westram, 15 years ago
|
- test gcc-version before adding -gnu++0x
|
-
Property svn:executable set to
*
|
File size:
851 bytes
|
Line | |
---|
1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | |
---|
6 | sub version_compare($$); |
---|
7 | sub version_compare($$) { |
---|
8 | my ($v1,$v2) = @_; |
---|
9 | |
---|
10 | if (not defined $v1) { |
---|
11 | $v1 = 0; |
---|
12 | if (not defined $v2) { |
---|
13 | return 0; |
---|
14 | } |
---|
15 | } |
---|
16 | elsif (not defined $v2) { $v2 = 0; } |
---|
17 | |
---|
18 | my ($mj1,$mn1) = ($v1,undef); |
---|
19 | my ($mj2,$mn2) = ($v2,undef); |
---|
20 | |
---|
21 | if ($v1 =~ /\./) { ($mj1,$mn1) = ($`,$'); } |
---|
22 | if ($v2 =~ /\./) { ($mj2,$mn2) = ($`,$'); } |
---|
23 | |
---|
24 | my $cmp = $mj1 <=> $mj2; |
---|
25 | if ($cmp==0) { |
---|
26 | $cmp = version_compare($mn1,$mn2); |
---|
27 | } |
---|
28 | return $cmp; |
---|
29 | } |
---|
30 | |
---|
31 | sub main() { |
---|
32 | my $args = scalar(@ARGV); |
---|
33 | if ($args!=2) { |
---|
34 | die "Usage: requireVersion.pl x.x y.y\n". |
---|
35 | " Prints 1 if y.y is greater equal the required version x.x\n"; |
---|
36 | } |
---|
37 | |
---|
38 | my $req = $ARGV[0]; |
---|
39 | my $test = $ARGV[1]; |
---|
40 | |
---|
41 | my $cmp = version_compare($req,$test); |
---|
42 | if ($cmp<=0) { print "1\n"; } |
---|
43 | else { print "0\n"; } |
---|
44 | } |
---|
45 | main(); |
---|
Note: See
TracBrowser
for help on using the repository browser.