--- ExtUtils-CXX/CXX.pm 2017/08/14 04:30:22 1.1 +++ ExtUtils-CXX/CXX.pm 2018/03/25 06:06:48 1.3 @@ -66,12 +66,14 @@ use common::sense; -our $VERSION = 0.02; +our $VERSION = '1.0'; -use parent Exporter::; +use Exporter 'import'; our @EXPORT = qw(extutils_cxx); +use ExtUtils::MakeMaker::Config (); + =item extutils_cxx BLOCK; This function temporarily does hideous things so you can call @@ -90,6 +92,8 @@ c89 => "g++", ); +our $PREFIX = qr{(?:\S+[\/\\])? (?:ccache|distcc)}x; + sub _ccrepl { my ($cfgvar, $env) = @_; @@ -104,11 +108,11 @@ } else { keys %cc; while (my ($k, $v) = each %cc) { - $val =~ s/^ (\S*[\/\\])? $k (-|\s|\d|$) /$1$v$2/x + $val =~ s/^ ((?:$PREFIX\s+)? \S*[\/\\])? $k (-|\s|\d|$) /$1$v$2/x and goto done; } - $val =~ s/^\S+/g++/; + $val =~ s/^($PREFIX\s+)? \S+/$1g++/x; done: ; } @@ -126,10 +130,12 @@ # now dive into internals of Config and temporarily patch those values - $tie->{ld} = "/uasr/bin/gcc-4.6 -O"; local $tie->{cc} = $Config{cc}; _ccrepl cc => "CXX"; local $tie->{ld} = $Config{ld}; _ccrepl ld => ($ENV{PERL_CXXLD} ? "CXXLD" : "CXX"); + local $ExtUtils::MakeMaker::Config::Config{cc} = $tie->{cc}; + local $ExtUtils::MakeMaker::Config::Config{ld} = $tie->{ld}; + eval { $cb->(); };