Hey Gang,
I've figured out how to create and install a PPM binary distribution;
with or without distributing the C code! And I've decided to share it
with all of you :)
NOTE: Future versions of Inline will make this process a one line
command. But for now just use this simple recipe.
---
The Inline 0.40 distribution comes with a sample extension module called
Math::Simple. Theoretically you could distribute this module on CPAN. It
has all the necessary support for installation. You can find it in
Inline-0.40/modules/Math/Simple/. Here are the steps for converting this
into a binary distribution *without* C source code.
NOTE: The recipient of this binary distribution will need to have the
PPM.pm module installed. This module requires a lot of other CPAN
modules. ActivePerl (available for Win32, Linux, and Solaris) has all of
these bundled. So while ActivePerl isn't required, it makes things (a
lot) easier.
1) cd Inline-0.40/Math/Simple/
2) Divide Simple.pm into two files:
---8<--- (Simple.pm)
package Math::Simple;
use strict;
require Exporter;
@Math::Simple::ISA = qw(Exporter);
@Math::Simple::EXPORT = qw(add subtract);
$Math::Simple::VERSION = '1.23';
use Inline (C => 'src/Simple.c' =>
NAME => 'Math::Simple::Stuff',
VERSION => '1.23',
);
1;
---8<---
---8<--- (src/Simple.c)
int add (int x, int y) {
return x + y;
}
int subtract (int x, int y) {
return x - y;
}
---8<---
So now you have the Perl in one file and the C in the other. The C code
must be in a subdirectory.
3) Note that I also changed the term 'DATA' to the name of the C file.
This will work just as if the C were still inline.
4) Run 'perl Makefile.PL'
5) Run 'make test'
6) Get the MD5 key from 'blib/arch/auto/Math/Simple/Stuff/Stuff.inl'
7) Edit 'blib/lib/Math/Simple.pm'. Change 'src/Simple.c' to
'02c61710cab5b659efc343a9a830aa73' (the MD5 key)
8) Run 'make ppd'
9) Edit 'Math-Simple.ppd'. Fill in AUTHOR and ABSTRACT if you wish. Then
change:
<CODEBASE HREF="" />
to
<CODEBASE HREF="./Math-Simple.tar.gz" />
10) Run 'tar cvzf Math-Simple.tar.gz blib'
11) Run 'tar cvzf Math-Simple-1.23.tar.gz Math-Simple.ppd
Math-Simple.tar.gz'
12) Distribute Math-Simple-1.23.tar.gz with the following instructions:
A) Run 'tar xvzf Math-Simple-1.23.tar.gz'
B) Run 'ppm install Math-Simple.ppd'
C) Run 'rm rm Math-Simple*'
D) Test with:
perl -MMath::Simple -le 'print add(37, 42)'
---
That's it. The process should also work with zip instead of tar, but I
haven't tried it.
The recipient of the binary must have Perl built with a matching
architecture. Luckily, ppm will catch this.
This procedure requires 0.40-TRIAL8 (for no-source support).
For a binary dist *with* C source code, simply omit steps 2, 3, 6, and
7.
If this seems too hard, then wait for version 0.41 and type:
perl -MInline=makeppd Simple.pm
Cheers, Brian
--
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'