stas 2004/08/06 12:34:37
Modified: lib/Apache Build.pm
lib/ModPerl Config.pm
xs/APR/APR Makefile.PL
Log:
refactoring the ap(r|u)(-1?)config code and acquiring of the linking flags
Revision Changes Path
1.169 +45 -16 modperl-2.0/lib/Apache/Build.pm
Index: Build.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -u -r1.168 -r1.169
--- Build.pm 6 Aug 2004 12:55:48 -0000 1.168
+++ Build.pm 6 Aug 2004 19:34:37 -0000 1.169
@@ -933,23 +933,52 @@
$self->{apr_bindir};
}
-# XXX: we assume that apr-config and apu-config reside in the same
-# directory
+sub apr_generation {
+ my($self) = @_;
+ return $self->httpd_version_as_int =~ m/21\d+/ ? 1 : 0;
+}
+
+# returns an array of apr/apu linking flags (--link-ld --libs) if found
+# an empty array otherwise
+my @apru_link_flags = ();
+sub apru_link_flags {
+ my($self) = @_;
+
+ return @apru_link_flags if @apru_link_flags;
+
+ for ($self->apr_config_path, $self->apu_config_path) {
+ if (my $link = $_ && -x $_ && qx{$_ --link-ld --libs}) {
+ chomp $link;
+ push @apru_link_flags, $link;
+ }
+ }
+
+ return @apru_link_flags;
+}
+
sub apr_config_path {
- my ($self) = @_;
+ shift->apru_config_path("apr");
+}
+
+sub apu_config_path {
+ shift->apru_config_path("apu");
+}
+
+sub apru_config_path {
+ my ($self, $what) = @_;
+
+ my $key = "${what}_config_path"; # apr_config_path
+ my $mp_key = "MP_" . uc($what) . "_CONFIG"; # MP_APR_CONFIG
- return $self->{apr_config_path}
- if $self->{apr_config_path} and -x $self->{apr_config_path};
+ return $self->{$key} if $self->{$key} and -x $self->{$key};
- if (exists $self->{MP_APR_CONFIG} and -x $self->{MP_APR_CONFIG}) {
- $self->{apr_config_path} = $self->{MP_APR_CONFIG};
+ if (exists $self->{$mp_key} and -x $self->{$mp_key}) {
+ $self->{$key} = $self->{$mp_key};
}
- my $config = $self->httpd_version_as_int =~ m/21\d+/
- ? 'apr-1-config'
- : 'apr-config';
+ my $config = $self->apr_generation ? "$what-1-config" : "$what-config";
- if (!$self->{apr_config_path}) {
+ if (!$self->{$key}) {
my @tries = ();
if ($self->httpd_is_source_tree) {
push @tries, grep { -d $_ }
@@ -974,22 +1003,22 @@
for my $try (@tries) {
next unless -x $try;
- $self->{apr_config_path} = $try;
+ $self->{$key} = $try;
}
}
- $self->{apr_config_path} ||= Apache::TestConfig::which($config);
+ $self->{$key} ||= Apache::TestConfig::which($config);
# apr_bindir makes sense only if httpd/apr is installed, if we are
# building against the source tree we can't link against
# apr/aprutil libs
unless ($self->httpd_is_source_tree) {
- $self->{apr_bindir} = $self->{apr_config_path}
- ? dirname $self->{apr_config_path}
+ $self->{apr_bindir} = $self->{$key}
+ ? dirname $self->{$key}
: '';
}
- $self->{apr_config_path};
+ $self->{$key};
}
sub apr_includedir {
1.14 +9 -16 modperl-2.0/lib/ModPerl/Config.pm
Index: Config.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Config.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -u -r1.13 -r1.14
--- Config.pm 6 Aug 2004 12:55:48 -0000 1.13
+++ Config.pm 6 Aug 2004 19:34:37 -0000 1.14
@@ -23,7 +23,7 @@
use constant WIN32 => Apache::Build::WIN32;
sub as_string {
- my $build_config = Apache::Build->build_config;
+ my $build = Apache::Build->build_config;
my $cfg = '';
@@ -34,15 +34,15 @@
# the widest key length
my $max_len = 0;
- for (map {length} grep /^MP_/, keys %$build_config) {
+ for (map {length} grep /^MP_/, keys %$build) {
$max_len = $_ if $_ > $max_len;
}
# mod_perl opts
$cfg .= "*** Makefile.PL options:\n";
$cfg .= join '',
- map {sprintf " %-${max_len}s => %s\n", $_, $build_config->{$_}}
- grep /^MP_/, sort keys %$build_config;
+ map {sprintf " %-${max_len}s => %s\n", $_, $build->{$_}}
+ grep /^MP_/, sort keys %$build;
my $command = '';
@@ -58,24 +58,17 @@
# apr
$cfg .= "\n\n*** (apr|apu)-config linking info\n\n";
- if (my $apr_bindir = $build_config->apr_bindir()) {
- my @configs = $build_config->httpd_version_as_int =~ m/21\d+/
- ? qw(apr-1 apu-1)
- : qw(apr apu);
-
- my $ext = WIN32 ? '.bat' : '';
- my @libs = grep $_, map { -x $_ && qx{$_ --link-ld --libs} }
- map { qq{$apr_bindir/$_-config$ext} } @configs;
- chomp @libs;
- my $libs = join "\n", @libs;
+ my @apru_link_flags = $build->apru_link_flags;
+ if (@apru_link_flags) {
+ my $libs = join "\n", @apru_link_flags;
$cfg .= "$libs\n\n";
}
else {
- $cfg .= "config scripts were not found\n\n";
+ $cfg .= "(apr|apu)-config scripts were not found\n\n";
}
# perl opts
- my $perl = $build_config->{MODPERL_PERLPATH};
+ my $perl = $build->{MODPERL_PERLPATH};
$command = "$perl -V";
$cfg .= "\n\n*** $command\n";
$cfg .= qx{$command};
1.28 +2 -13 modperl-2.0/xs/APR/APR/Makefile.PL
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/APR/Makefile.PL,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -u -r1.27 -r1.28
--- Makefile.PL 6 Aug 2004 12:55:48 -0000 1.27
+++ Makefile.PL 6 Aug 2004 19:34:37 -0000 1.28
@@ -20,19 +20,8 @@
my $libs = '';
my $build = ModPerl::BuildMM::build_config();
-if (my $apr_bindir = $build->apr_bindir()) {
-
- my @configs = $build->httpd_version_as_int =~ m/21\d+/
- ? qw(apr-1 apu-1)
- : qw(apr apu);
-
- # XXX: this works only with libapr 0.9.2+
- my $ext = WIN32 ? '.bat' : '';
- my @libs = grep $_, map { -x $_ && qx{$_ --link-ld --libs} }
- map { qq{$apr_bindir/$_-config$ext} } @configs;
- chomp @libs;
- $libs = join ' ', @libs;
-}
+my @apru_link_flags = $build->apru_link_flags;
+$libs .= join ' ', @apru_link_flags if @apru_link_flags;
if (WIN32) {
$libs =~ s{/libpath:}{-L}g;