perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject [mp2] linking APR::* against APR
Date Sat, 19 Jun 2004 00:53:18 GMT
In the current cvs, there's a couple of things needed to be
done to link APR::* against the APR lib. The problem
existing now (for Win32) is that the APR::* link against
mod_perl.lib, so that mod_perl.so needs always to be
available. We can get around this by removing the linking
against mod_perl.lib, and instead link against APR.lib. This
is relatively straightforward - the diff is below, and also
attached, as it involves some tabs to be used within a
Makefile. This is done (for Win32) for APR::Table,
APR::UUID, APR::Pool, and APR::Pool. Note also that for this
to work, APR.lib must be built before APR::*, so that the
symbols ger resolved at link time. The default behaviour for
me is to build APR::* first, so this diff also involves
introduction of an apr_lib target (xs/APR/APR) to be built
just after mod_perl.lib. This subsequently involves a trick
within the top-level Makefile.PL (as is done for
src/modules/perl/mod_perl.lib) to create a dummy APR.lib to
fool MakeMaker into thinking the lib exists - otherwise, if
it doesn't find it, the linking against the library is
ignored.
===============================================================
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.137
diff -u -r1.137 Makefile.PL
--- Makefile.PL	4 Mar 2004 03:36:18 -0000	1.137
+++ Makefile.PL	19 Jun 2004 00:37:36 -0000
@@ -153,11 +153,19 @@
         #Makefile.PL's in WrapXS/ just need to pass the -e mod_perl.lib test
         #the real mod_perl.lib will be in place when WrapXS/ dll's are
         #actually linked
-        my $lib = "src/modules/perl/$build->{MP_LIBNAME}.lib";
-        unless (-e $lib) {
-            open my $fh, '>', $lib or die "open $lib: $!";
-            print $fh "#this is a dummy file to trick MakeMaker";
-            close $fh;
+        require File::Path;
+        my $lib1 = "src/modules/perl/$build->{MP_LIBNAME}.lib";
+        my $apr_blib = catdir qw(blib arch Apache2 auto APR);
+        unless (-d $apr_blib) {
+            File::Path::mkpath($apr_blib) or die "mkdir $apr_blib failed: $!";
+        }
+        my $lib2 = catfile $apr_blib, 'APR.lib';
+        foreach my $lib ($lib1, $lib2) {
+            unless (-e $lib) {
+                open my $fh, '>', $lib or die "open $lib: $!";
+                print $fh "#this is a dummy file to trick MakeMaker";
+                close $fh;
+            }
         }
     }

@@ -448,6 +456,7 @@
 package MY;

 use Config;
+use File::Spec::Functions qw(catdir);

 my $apache_test_install;
 BEGIN {
@@ -459,6 +468,16 @@
 sub MY::top_targets {
     my $self = shift;
     my $string = $self->ModPerl::BuildMM::MY::top_targets;
+
+    ModPerl::MM::add_dep(\$string, pure_all => 'apr_lib');
+
+    my $apr_lib = catdir qw(xs APR APR);
+    $string .= <<"EOF";
+
+apr_lib:
+	cd "$apr_lib" && \$(MAKE) -f \$(FIRST_MAKEFILE) all \$(PASTHRU)
+
+EOF

     ModPerl::MM::add_dep(\$string, pure_all => 'modperl_lib');

Index: lib/ModPerl/BuildMM.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/BuildMM.pm,v
retrieving revision 1.15
diff -u -r1.15 BuildMM.pm
--- lib/ModPerl/BuildMM.pm	4 Mar 2004 06:01:06 -0000	1.15
+++ lib/ModPerl/BuildMM.pm	19 Jun 2004 00:37:36 -0000
@@ -77,7 +77,25 @@
         }
     }

-    my $libs = join ' ', $build->apache_libs, $build->modperl_libs;
+    my $libs;
+    if (Apache::Build::WIN32) {
+        my %standalone = map {$_ => 1 }
+            qw(APR APR::Table APR::UUID APR::Pool APR::PerlIO);
+        my $apr_blib_lib = catfile $build->{cwd},
+            qw(blib arch Apache2 auto APR APR.lib);
+        if ($standalone{$args{NAME}}) {
+            $libs = $args{NAME} eq 'APR' ?
+                join ' ', $build->apache_libs :
+                    join ' ', $build->apache_libs, $apr_blib_lib;
+        }
+        else {
+            $libs = join ' ', $build->apache_libs, $build->modperl_libs;
+        }
+    }
+    else {
+        $libs = join ' ', $build->apache_libs, $build->modperl_libs;
+    }
+
     my $ccflags = $build->perl_ccopts . $build->ap_ccopts;

     my @opts = (

==========================================================================

-- 
best regards,
randy
Mime
View raw message