I've attached a patch (as it includes tabs) for building the
static aprext lib for Win32 (and perhaps others) when need
be in providing symbols to APR/APR::* so as to be usable
outside of mod_perl.so. What this does is hopfully make it
easier to configure other platforms (than Win32) to build it
this way - a constant BUILD_APREXT is defined in
Apache::Build, so to add another platform to this way of
building, one just has to modify this constant, as well as
provide a mp_apr_lib_$^O sub in Apache::Build to instruct
how to link to the aprext lib.

I've changed the actual name of the lib used to libaprext,
to make it easier on *nix to use "-laprext" linking.

-- 
best regards,
randy
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.150
diff -u -r1.150 Makefile.PL
--- Makefile.PL 23 Jul 2004 23:24:55 -0000      1.150
+++ Makefile.PL 1 Aug 2004 05:49:52 -0000
@@ -39,6 +39,7 @@
 use ModPerl::BuildMM ();
 
 use constant WIN32 => Apache::Build::WIN32;
+use constant BUILD_APREXT => Apache::Build::BUILD_APREXT;
 
 our $VERSION;
 
@@ -165,17 +166,21 @@
     # (see the aprext target in the MY::top_targets sub below), as 
     # symbols must get resolved at link time.
 
-    if (WIN32()) {
-        require File::Basename;
+    if (BUILD_APREXT()) {
         require File::Path;
         #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
         # this must also be done for aprext.lib, build in xs/APR/aprext/;
         # we must create a dummy aprext.lib to pass the -e test.
-        my $lib1 = "src/modules/perl/$build->{MP_LIBNAME}.lib";
-        my $lib2 = $build->mp_apr_lib;
-        my $apr_blib = File::Basename::dirname($lib2);
+        my $lib1 = catfile qw(src modules perl), 
+            "$build->{MP_LIBNAME}$Config{lib_ext}";
+        my $mp_apr_lib = $build->{MP_APR_LIB};
+        my $lib_mp_apr_lib = 'lib' . $mp_apr_lib;
+        my $apr_blib = $build->{MP_INST_APACHE2} ?
+            catdir(qw/blib arch Apache2 auto/, $lib_mp_apr_lib) :
+            catdir(qw/blib arch auto/, $lib_mp_apr_lib);
+        my $lib2 = catfile $apr_blib, $lib_mp_apr_lib . $Config{lib_ext};
         unless (-d $apr_blib) {
             File::Path::mkpath($apr_blib) or die "mkdir $apr_blib failed: $!";
         }
@@ -488,6 +493,7 @@
 
 use Config;
 use constant WIN32 => $^O eq 'MSWin32';
+use constant BUILD_APREXT => Apache::Build::BUILD_APREXT;
 
 my $apache_test_install;
 BEGIN {
@@ -500,24 +506,29 @@
     my $self = shift;
     my $string = $self->ModPerl::BuildMM::MY::top_targets;
 
-    if (WIN32) {
+    if (BUILD_APREXT) {
         ModPerl::MM::add_dep(\$string, pure_all => 'aprext');
 
         # must not import File::Spec functions inside MY, it breaks
         # 5.6.x builds
-        my $from = $build->mp_apr_lib;
-        my $apr_lib = $build->{MP_APR_LIB} . $Config{lib_ext};
+        my $mp_apr_lib = $build->{MP_APR_LIB};
+        my $lib_mp_apr_lib = 'lib' . $mp_apr_lib;
+        my $apr_blib = $build->{MP_INST_APACHE2} ?
+            File::Spec->catdir(qw/blib arch Apache2 auto/, $lib_mp_apr_lib) :
+            File::Spec->catdir(qw/blib arch auto/, $lib_mp_apr_lib);
+        my $full_libname = $lib_mp_apr_lib . $Config{lib_ext};
+        my $from = File::Spec->catfile($apr_blib, $full_libname);
         (my $ap_lib = $build->ap_includedir()) =~ s{include$}{lib};
-        my $to = File::Spec->catfile($ap_lib, $apr_lib);
-        my $src_dir = File::Spec->catdir(qw(xs APR aprext));
+        my $to = File::Spec->catfile($ap_lib, $full_libname);
+        my $src_dir = File::Spec->catdir(qw(xs APR), $mp_apr_lib);
         $string .= <<"EOF";
 
 aprext:
-        cd "$src_dir" && \$(MAKE) all \$(PASTHRU)
+       cd "$src_dir" && \$(MAKE) all \$(PASTHRU) LINKTYPE="static"
 
 aprext_install:
-        [EMAIL PROTECTED](MKPATH) "$ap_lib"
-        \$(CP) "$from" "$to"
+       [EMAIL PROTECTED](MKPATH) "$ap_lib"
+       \$(CP) "$from" "$to"
 
 EOF
     }
@@ -595,7 +606,7 @@
     ModPerl::MM::add_dep(\$string, pure_install => 'modperl_lib_install');
     ModPerl::MM::add_dep(\$string, pure_install => 'modperl_xs_h_install');
     # ModPerl::MM::add_dep(\$string, pure_install => 'aprext_install')
-    #    if WIN32;
+    #    if BUILD_APREXT;
 
     ModPerl::MM::add_dep(\$string, pure_install => 'nuke_Apache__test')
           if $apache_test_install;
Index: lib/Apache/Build.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
retrieving revision 1.165
diff -u -r1.165 Build.pm
--- lib/Apache/Build.pm 23 Jul 2004 23:24:55 -0000      1.165
+++ lib/Apache/Build.pm 1 Aug 2004 05:49:53 -0000
@@ -37,6 +37,7 @@
 use constant REQUIRE_ITHREADS => grep { $^O eq $_ } qw(MSWin32);
 use constant PERL_HAS_ITHREADS =>
     $Config{useithreads} && ($Config{useithreads} eq 'define');
+use constant BUILD_APREXT => (WIN32 || AIX);
 
 use ModPerl::Code ();
 use ModPerl::BuildOptions ();
@@ -1399,7 +1400,19 @@
     my $mp_apr_lib = $self->{MP_APR_LIB};
     my @dirs = $self->{MP_INST_APACHE2} ?
         qw(blib arch Apache2 auto) : qw(blib arch auto);
-    return catdir $self->{cwd}, @dirs, $mp_apr_lib, "$mp_apr_lib.lib";
+    my $dir = catdir $self->{cwd}, @dirs, 'lib' . $mp_apr_lib;
+    return qq{ -L"$dir" -l$mp_apr_lib };
+}
+
+sub mp_apr_lib_aix {
+    my $self = shift;
+    # MP_APR_LIB.lib will be installed into MP_AP_PREFIX/lib
+    # for use by 3rd party xs modules
+    my $mp_apr_lib = $self->{MP_APR_LIB};
+    my @dirs = $self->{MP_INST_APACHE2} ?
+        qw(blib arch Apache2 auto) : qw(blib arch auto);
+    my $dir = catdir $self->{cwd}, @dirs, 'lib' . $mp_apr_lib;
+    return qq{ -L$dir -l$mp_apr_lib };
 }
 
 # name of lib used to build APR/APR::*
Index: lib/ModPerl/BuildMM.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/BuildMM.pm,v
retrieving revision 1.17
diff -u -r1.17 BuildMM.pm
--- lib/ModPerl/BuildMM.pm      4 Jul 2004 18:44:49 -0000       1.17
+++ lib/ModPerl/BuildMM.pm      1 Aug 2004 05:49:53 -0000
@@ -79,7 +79,7 @@
 
     my $libs;
     my @libs = ();
-    if (Apache::Build::WIN32) {
+    if (Apache::Build::BUILD_APREXT) {
         # in order to decouple APR/APR::* from mod_perl.so,
         # link these modules against the static MP_APR_LIB lib,
         # rather than the mod_perl lib (which would demand mod_perl.so
Index: xs/APR/APR/Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/APR/Makefile.PL,v
retrieving revision 1.25
diff -u -r1.25 Makefile.PL
--- xs/APR/APR/Makefile.PL      4 Jul 2004 18:44:49 -0000       1.25
+++ xs/APR/APR/Makefile.PL      1 Aug 2004 05:49:53 -0000
@@ -9,6 +9,7 @@
 use File::Spec::Functions;
 
 use constant WIN32   => Apache::Build::WIN32;
+use constant BUILD_APREXT   => Apache::Build::BUILD_APREXT;
 use constant SOLARIS => $^O eq 'solaris';
 
 my %args = (
@@ -30,14 +31,13 @@
 }
 
 if (WIN32) {
-    require File::Basename;
     $libs =~ s{/libpath:}{-L}g;
     $libs =~ s{(\w+)\.lib}{-l$1}g;
-    # include the static MP_APR_LIB lib
-    my ($lib, $dir, $ext) =
-        File::Basename::fileparse($build->mp_apr_lib, qr{\.lib});
-    $dir =~ s!\\$!!;
-    $libs .= qq{ -L"$dir" -l$lib };
+}
+
+if (BUILD_APREXT) {
+    my $mp_apr_lib = $build->mp_apr_lib;
+    $libs .= qq{ $mp_apr_lib };
 }
 
 if (SOLARIS && $libs) {
@@ -76,7 +76,7 @@
     $src{$cfile} = "$srcdir/$cfile";
 }
 
-$args{OBJECT} = WIN32 ? "APR.o" : "APR.o @obj";
+$args{OBJECT} = BUILD_APREXT() ? "APR.o" : "APR.o @obj";
 $args{clean}  = { FILES => "@clean" };
 
 ModPerl::BuildMM::WriteMakefile(%args);
Index: xs/APR/aprext/Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/aprext/Makefile.PL,v
retrieving revision 1.4
diff -u -r1.4 Makefile.PL
--- xs/APR/aprext/Makefile.PL   4 Jul 2004 18:44:49 -0000       1.4
+++ xs/APR/aprext/Makefile.PL   1 Aug 2004 05:49:53 -0000
@@ -20,9 +20,10 @@
 }
 
 my @skip = qw(dynamic test);
-push @skip, q{static} unless Apache::Build::WIN32;
+push @skip, q{static}
+    unless (Apache::Build::BUILD_APREXT);
 
-my %args = (NAME          => $build->{MP_APR_LIB},
+my %args = (NAME          => 'lib' . $build->{MP_APR_LIB},
             VERSION_FROM  => '../APR/APR.pm',
             SKIP          =>  [ @skip ] ,
             LINKTYPE      =>  'static',
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to