Author: pgollucci
Date: Wed Aug 24 11:18:19 2005
New Revision: 239724
URL: http://svn.apache.org/viewcvs?rev=239724&view=rev
Log:
check $ccopts for -Wdeclaration-after-statement
if not already present and the gcc version supports its (3.3.2+)
add it
Modified:
perl/modperl/trunk/lib/Apache2/Build.pm
Modified: perl/modperl/trunk/lib/Apache2/Build.pm
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/lib/Apache2/Build.pm?rev=239724&r1=239723&r2=239724&view=diff
==============================================================================
--- perl/modperl/trunk/lib/Apache2/Build.pm (original)
+++ perl/modperl/trunk/lib/Apache2/Build.pm Wed Aug 24 11:18:19 2005
@@ -523,6 +523,12 @@
$ccopts .= " $Wall -DAP_DEBUG";
$ccopts .= " -DAP_HAVE_DESIGNATED_INITIALIZER";
}
+
+ if ($self->has_gcc_version('3.3.2') &&
+ $ccopts !~ /declaration-after-statement/) {
+ debug "Adding -Wdeclaration-after-statement to ccopts";
+ $ccopts .= " -Wdeclaration-after-statement";
+ }
}
if ($self->{MP_COMPAT_1X}) {
@@ -555,6 +561,33 @@
$ccopts;
}
+sub has_gcc_version {
+
+ my $self = shift;
+ my $requested_version = shift;
+
+ my $has_version = $self->perl_config('gccversion');
+
+ return 0 unless $has_version;
+
+ my @tuples = split /\./, $has_version, 3;
+ my @r_tuples = split /\./, $requested_version, 3;
+
+ return cmp_tuples([EMAIL PROTECTED], [EMAIL PROTECTED]) == 1;
+}
+
+sub cmp_tuples {
+
+ my($a, $b) = @_;
+
+ while (@$a && @$b) {
+ my $cmp = shift @$a <=> shift @$b;
+ return $cmp if $cmp;
+ }
+
+ return @$a <=> @$b;
+}
+
sub perl_ccopts {
my $self = shift;