Fix a few bugs in BSDPAN:

* Fix a bug which prevented the second invocation of overloaded
  subs governed by SelfLoader from functioning.

* Fix a bug with XS modules.  MakeMaker determines where the xsubpp
  preprocessor is located by adding "ExtUtils" string to the Perl's
  system path.  At the same time, BSDPAN has to fool MakeMaker into
  thinking that the Perl's system path is elsewhere.  Now we
  `reverse-adjust' the notion of the Perl's system path for a
  moment, so xsubpp utility is found.

This should fix the breakage with some p5- ports.

Reported by:	vanilla
Submitted by:	Anton Berezin <tobez@tobez.org>
This commit is contained in:
Josef Karthauser 2001-04-05 13:59:51 +00:00
parent 53e11665d9
commit 421b34291f
2 changed files with 30 additions and 10 deletions

View File

@ -93,14 +93,16 @@ sub override ($$) {
# Ouch! Don't ask. :-)
eval <<EOF;
*$name = sub {
\$replacement_sub->( sub {
\$SelfLoader::AUTOLOAD = "$name";
local \$SIG{__WARN__} = sub {};
my \@r = \$sl_autoload->(\@_);
my \$real_addr = "*$name\{CODE}";
*$name = sub { \$replacement_sub->(
\$real_addr, \@_) };
}, \@_)
\$replacement_sub->( sub {
\$SelfLoader::AUTOLOAD = "$name";
local \$SIG{__WARN__} = sub {};
my \@r = \$sl_autoload->(\@_);
my \$real_addr = eval "*$name\{CODE}";
my \$repsub2 = \$replacement_sub;
eval "*\$name = sub {
\\\$repsub2->(
\\\$real_addr, \\\@_) };";
}, \@_)
};
EOF
} else {

View File

@ -24,7 +24,9 @@ sub init_main {
# MakeMaker insist to use perl system path first;
# free it of this misconception, since we know better.
$him->{PERL_LIB} = BSDPAN->path;
$him->{PERL_LIB_REAL} = $him->{PERL_LIB};
$him->{PERL_LIB_BSDPAN} = BSDPAN->path;
$him->{PERL_LIB} = $him->{PERL_LIB_BSDPAN};
# MakeMaker is pretty lame when the user specifies PREFIX.
# It has too fine granularity regarding the various places
@ -57,8 +59,20 @@ sub init_main {
return @r;
}
sub tool_xsubpp {
my $orig = shift;
my $him = $_[0];
$him->{PERL_LIB} = $him->{PERL_LIB_REAL};
my @r = &$orig;
$him->{PERL_LIB} = $him->{PERL_LIB_BSDPAN};
return @r;
}
BEGIN {
override 'init_main', \&init_main;
override 'tool_xsubpp', \&tool_xsubpp;
}
1;
@ -72,7 +86,7 @@ BSDPAN::ExtUtils::MM_Unix - Override ExtUtils::MM_Unix functionality
=head1 DESCRIPTION
BSDPAN::ExtUtils::MM_Unix overrides init_main() sub of the standard perl
BSDPAN::ExtUtils::MM_Unix overrides two subs from the standard perl
module ExtUtils::MM_Unix.
The overridden init_main() first calls the original init_main(). Then,
@ -80,6 +94,10 @@ if the Perl port build is detected, and the PREFIX stored in the
ExtUtils::MM_Unix object is not F</usr/local/>, it proceeds to change
various installation paths ExtUtils::MM_Unix maintains, to match PREFIX.
The overridden tool_xsubpp() sub temporarily undoes the change in the
environment done by the overridden init_main(), so that xsubpp(1) and
other XS tools will be searched in the right place.
Thus, BSDPAN::ExtUtils::MM_Unix is responsible for making p5- ports
PREFIX-clean.