Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Wednesday December 11, 2002
08:21 PM

Telling MakeMaker to take a hike

[ #9395 ]

MakeMaker is amazingly flexible. I can override a lot of the settings when I run the Makefile.PL script.

Some things no one ever thought of changing though. Who would ever use their own xsubpp? Mac users, the perennial special cases. Matthias created on for something, and Chris Nandor uses it Mac::Carbon, which, despite its youth, is extremely cool. The problem is that I had to get it to use the special xsubpp.

This was not working for me, and I am still really ignorant of a lot of XS stuff. The idea of replacing something I do not understand with something else I do not understand sends me to FUDsville. At one point I was on the verge of entering Chris's killfile, I think.

I knew there had to be a better way. I mucked around in ExtUtils::MM_Unix and rewrote my own tool_xsubpp function. Inside the Makefile.PL, I can override MakeMaker methods by defining a method of the same name in the MY package.

After a bit of fiddling, I came up with a stripped down tool_xsubpp that worked for the AppleEvent directory in the Mac::Carbon distribution. I am not very confident it is the right way to do things, or that it works with the other Makefile.PLs (about 10 or so in the distribution), but I did not have to replace the stock xsubpp because the Makefile finds the one in the distribution instead.

package MY;
 
sub tool_xsubpp
   {
    my($self) = shift;
 
    return "" unless $self->needs_linking;
 
    my($xsdir)  = File::Spec->catdir( '..', 'xsubpps' );
 
    my(@tmdeps) = File::Spec->catdir(
        $self->{PERL_LIB}, "ExtUtils", 'typemap' );
 
    push @tmdeps, "typemap" if -f "typemap";
    my @tmargs = map "-typemap $_", @tmdeps;
 
    unshift @tmargs, $self->{XSOPT} if exists $self->{XSOPT};
 
    my $xsubpp = $] =~ /8/ ? 'xsubpp-5.8.0' : 'xsubpp-5.6.1';
 
    $self->{XSPROTOARG} ||= "";
 
    return <<"HERE";
XSUBPPDIR = $xsdir
XSUBPP = \$(XSUBPPDIR)/$xsubpp
XSPROTOARG = $self->{XSPROTOARG}
XSUBPPDEPS = @tmdeps \$(XSUBPP)
XSUBPPARGS = @tmargs
XSUBPP_EXTRA_ARGS =
HERE
    };