On Sun, 1 Aug 2004, Stas Bekman wrote:
> Randy Kobes wrote:
> > 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.
[ ... ]
>
> Nice work, Randy
>
> The only comment I have is that there is a lot of code
> duplication going on in Makefile.PL. It think it should be
> abstracted into a sub.
Thanks, Stas - that's a good idea. In the attached, I put
the code to get the directory and name of the built aprext
lib into an Apache::Build sub.
--
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 17:59:58 -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,17 @@
# (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 ($apr_blib, $full_libname) = $build->mp_apr_blib();
+ my $lib2 = catfile $apr_blib, $full_libname;
unless (-d $apr_blib) {
File::Path::mkpath($apr_blib) or die "mkdir $apr_blib failed: $!";
}
@@ -484,10 +485,12 @@
system(@args) == 0 or die "system @args failed: $?";
}
+
package MY;
use Config;
use constant WIN32 => $^O eq 'MSWin32';
+use constant BUILD_APREXT => Apache::Build::BUILD_APREXT;
my $apache_test_install;
BEGIN {
@@ -500,24 +503,24 @@
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 ($apr_blib, $full_libname) = $build->mp_apr_blib();
+ 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), 'aprext');
$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 +598,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/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 17:59:58 -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: 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 18:00:02 -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 ();
@@ -1392,17 +1393,38 @@
$libs->($self);
}
+# returns the directory and name of the aprext lib built under blib/
+sub mp_apr_blib {
+ my $self = shift;
+ return unless (my $mp_apr_lib = $self->{MP_APR_LIB});
+ my $lib_mp_apr_lib = 'lib' . $mp_apr_lib;
+ my @dirs = $self->{MP_INST_APACHE2} ?
+ qw(blib arch Apache2 auto) : qw(blib arch auto);
+ my $apr_blib = catdir $self->{cwd}, @dirs, $lib_mp_apr_lib;
+ my $full_libname = $lib_mp_apr_lib . $Config{lib_ext};
+ return ($apr_blib, $full_libname);
+}
+
sub mp_apr_lib_MSWin32 {
my $self = shift;
+ # The MP_APR_LIB will be installed into MP_AP_PREFIX/lib
+ # for use by 3rd party xs modules
+ my ($dir, $lib) = $self->mp_apr_blib();
+ $lib =~ s[^lib(\w+)$Config{lib_ext}$][$1];
+ $dir = Win32::GetShortPathName($dir);
+ return qq{ -L$dir -l$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);
- return catdir $self->{cwd}, @dirs, $mp_apr_lib, "$mp_apr_lib.lib";
+ my ($dir, $lib) = $self->mp_apr_blib();
+ $lib =~ s[^lib(\w+)$Config{lib_ext}$][$1];
+ return qq{ -L$dir -l$lib };
}
-# name of lib used to build APR/APR::*
+# linking used for the aprext lib used to build APR/APR::*
sub mp_apr_lib {
my $self = shift;
my $libs = \&{"mp_apr_lib_$^O"};
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 18:00:02 -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 18:00:02 -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]