Perl Inline::Module correct way of writing Makefile.PL

197 views Asked by At

I'm struggling with Inline::Module. The problem is that when I try to do make install of my perl module with inline C code, the make system generates automatic stubs with inline modules which supposed to compile the inline C code. Though if you run make dist, it replaces the stub with DynaLoader version (which is correct in my opinion). So the question is how to force Inline::Module to generate DynaLoader stubs when I'm running make install? Am I missing the point?

I took the Makefile from some open example:

use 5.008001; use strict; use warnings; use utf8;

use lib 'inc';
use ExtUtils::MakeMaker;
use Inline::Module;

WriteMakefile(
    NAME => 'Text::Levenshtein::Inline',
    ABSTRACT => 'Levenshtein distance implement by Inline::C',
    VERSION_FROM => 'lib/Text/Levenshtein/Inline.pm',
    AUTHOR => 'tadegenban <[email protected]>',
    LICENSE => 'perl',
    MIN_PERL_VERSION => '5.008001',
    test => { TESTS => 't/*.t' },
    postamble => {
        inline => {
            module => 'Text::Levenshtein::Inline',
            makestub => 1
        },
    },
);

Here is the resulting auto-generated stub when I run make install:

use strict; use warnings;
package Text::Levenshtein::Inline::Inline;
use Inline::Module stub => 'v2';
1;

though if I do make dist, it replaces the inline stub with this:

use strict; use warnings;
package Text::Levenshtein::Inline::Inline;
use base 'DynaLoader';
bootstrap Text::Levenshtein::Inline::Inline;
1;

The real problem here is that if somebody checks out the s/w from the Repo and simply runs make install, the s/w will try to build inline C code each time user runs it in the working directory. Otherwise you'll have to provide some explanation that after checking out someone has to run make dist or make distdir and run make install from there. A bit annoying...

1

There are 1 answers

2
cjm On

If you read the tutorial, you'll see it's intended to work the way it does. And the way the Perl toolchain is designed, it wouldn't make sense to do what you're asking for.

Consider the steps involved in installing a module:

perl Makefile.PL  # generates Makefile
make              # compiles code to blib
make test         # tests code in blib
make install      # copies files from blib to installation dir

If it worked as you requested, the make install step would need to discard the code that was built and tested, rebuild a different version of the code (which was not tested) and install that.

People building from the repository are expected to know what they are doing. You could add a note to a README file about this issue.