ExtUtils::MakeMaker and Debugging Makefiles

Ovid on 2007-12-21T10:30:41

I've been going absolutely nuts trying to debug a CPAN script we use at work. In order to make sure that we have complete control over our dependencies, we bundle them with our application. We do this with a setup_cpan shell script. Unfortunately, it doesn't quite do what we want and many hours of struggle has gotten me closer, but not quite there. To test it, I have a shell script which forces an install of YAML:

#!/usr/bin/bash

# setup cpan
./script/setup_cpan.sh

# force install YAML
perl -I/home/ovid/work/trunk/deps/perl5lib/ /opt/bin/cpan -fi YAML

# remove YAML
builtin cd deps
svn status | grep '^?' | sed -e 's/^?//' | xargs rm -fr
for file in `svn status | grep '^M' | sed -e 's/^M//'`; do
    svn revert $file
done

I've bound that to a key in vim which allows me to constantly tweak our setup_cpan script and rerun the configuration. The closest I can get is to set INSTALLDIRS to site, but that gives me this error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/opt/lib/perl/site_perl/auto/YAML'
Do not have write permissions on '/opt/lib/perl/site_perl/auto/YAML'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

&ExtUtils::Install::install gets the following first argument:

$VAR1 = {
          'blib/arch' => '/opt/lib/perl/site_perl',
          'blib/lib' => '/home/ovid/work/trunk/deps/perl5lib',
          'blib/man3' => '/home/ovid/work/trunk/deps/perl5lib/man/man3',
          'read' => '/opt/lib/perl/site_perl/auto/YAML/.packlist',
          'blib/script' => '/home/ovid/work/trunk/deps/perl5lib/bin',
          'blib/man1' => '/home/ovid/work/trunk/deps/perl5lib/man/man1',
          'write' => '/opt/lib/perl/site_perl/auto/YAML/.packlist',
          'blib/bin' => '/home/ovid/work/trunk/deps/perl5lib/bin'
        };

As you can see, the read and write keys are wrong, but after trolling through make files, adding a 'dump' target, reading through ExtUtils::MakeMaker, I'll be damned if I can figure out how to set those correctly. Once I finally figure this out, then I'll have to turn my attention to Module::Build. Oh, now that I look, I see that the man/ and bin/ directories are wrong, too. Sigh.

What we want is the following:

$ROOT/deps/man/man1/
$ROOT/deps/man/man3/
$ROOT/deps/bin/
$ROOT/deps/perl5lib/

This shouldn't be hard, but it is :( Oh, and I guess that doesn't account for architecture dependent files.


Steal some code from Smolder (or Krang)

mpeters on 2007-12-21T13:34:33

Smolder does this too (and it stole the code/ideas from Krang). Feel free to borrow them as you'd like:

It's done by the smolder_build script which uses the Smolder::Platform module. You're probably most interested in the build_perl_module() sub.

I don't know if you deal with different platforms in your build, but Smolder and Krang do. If something needs to be changed for a certain platform then that's overridden in a subclass of Smolder::Platform that's loaded by smolder_build.

http://smolder.svn.sourceforge.net/viewvc/smolder/trunk/bin/smolder_build?view=m arkup
http://smolder.svn.sourceforge.net/viewvc/smolder/trunk/lib/Smolder/Platform.pm? view=markup

local::lib

mgrimes on 2007-12-22T16:32:54

I'm not sure I exactly understand the problem, but might local::lib solve this? It sounds too simple, but it just sets:

export MODULEBUILDRC=/home/username/perl/.modulebuildrc export PERL_MM_OPT='INSTALL_BASE=/home/username/perl' export PERL5LIB='/home/username/perl/lib/perl5:/home/username/perl/lib/perl5/i386-linux ' export PATH="/home/username/perl/bin:$PATH"