Author: stevehay
Date: Tue Feb 14 14:04:05 2012
New Revision: 1243923

URL: http://svn.apache.org/viewvc?rev=1243923&view=rev
Log:
Correct the initialization of the build config in ModPerl::MM, simply borrowing 
the style of ModPerl::BuildMM to do so.

Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/lib/ModPerl/MM.pm

Modified: perl/modperl/trunk/Changes
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/Changes?rev=1243923&r1=1243922&r2=1243923&view=diff
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Tue Feb 14 14:04:05 2012
@@ -12,6 +12,12 @@ Also refer to the Apache::Test changes l
 
 =item 2.0.6-dev
 
+Correct the initialization of the build config in ModPerl::MM. The global
+variable was only being set once on loading the module, which was before
+Apache2::BuildConfig.pm had been written, leading to cwd and MP_LIBNAME
+being unset when writing the Reload and SizeLimit makefiles.
+[Steve Hay]
+
 Discover apr-2-config from Apache 2.4 onwards. [Gozer]
 
 Apache 2.4 and onwards doesn't require linking the MPM module directly in

Modified: perl/modperl/trunk/lib/ModPerl/MM.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/lib/ModPerl/MM.pm?rev=1243923&r1=1243922&r2=1243923&view=diff
==============================================================================
--- perl/modperl/trunk/lib/ModPerl/MM.pm (original)
+++ perl/modperl/trunk/lib/ModPerl/MM.pm Tue Feb 14 14:04:05 2012
@@ -69,10 +69,12 @@ sub add_dep_after {
     $$string =~ s/($targ\s+::.*?$after_targ)/$1 $add/;
 }
 
+my $build;
+
 sub build_config {
     my $key = shift;
     require Apache2::Build;
-    my $build = Apache2::Build->build_config;
+    $build ||= Apache2::Build->build_config;
     return $build unless $key;
     $build->{$key};
 }
@@ -97,15 +99,14 @@ sub my_import {
 my @default_opts = qw(CCFLAGS LIBS INC OPTIMIZE LDDLFLAGS TYPEMAPS);
 my @default_dlib_opts = qw(OTHERLDFLAGS);
 my @default_macro_opts = ();
-my $b = build_config();
 my %opts = (
-    CCFLAGS      => sub { $b->{MODPERL_CCOPTS}                        },
-    LIBS         => sub { join ' ', $b->apache_libs, $b->modperl_libs },
-    INC          => sub { $b->inc;                                    },
-    OPTIMIZE     => sub { $b->perl_config('optimize');                },
-    LDDLFLAGS    => sub { $b->perl_config('lddlflags');               },
-    TYPEMAPS     => sub { $b->typemaps;                               },
-    OTHERLDFLAGS => sub { $b->otherldflags;                           },
+    CCFLAGS      => sub { $build->{MODPERL_CCOPTS}                            
},
+    LIBS         => sub { join ' ', $build->apache_libs, $build->modperl_libs 
},
+    INC          => sub { $build->inc;                                        
},
+    OPTIMIZE     => sub { $build->perl_config('optimize');                    
},
+    LDDLFLAGS    => sub { $build->perl_config('lddlflags');                   
},
+    TYPEMAPS     => sub { $build->typemaps;                                   
},
+    OTHERLDFLAGS => sub { $build->otherldflags;                               
},
 );
 
 sub get_def_opt {
@@ -128,7 +129,7 @@ sub WriteMakefile {
         $eu_mm_mv_all_methods_overriden++;
     }
 
-    my $build = build_config();
+    $build ||= build_config();
     my_import(__PACKAGE__);
 
     # set top-level WriteMakefile's values if weren't set already
@@ -158,7 +159,7 @@ sub WriteMakefile {
 sub ModPerl::MM::MY::post_initialize {
     my $self = shift;
 
-    my $build = build_config();
+    $build ||= build_config();
     my $pm = $self->{PM};
 
     while (my ($k, $v) = each %PM) {


Reply via email to