RFC: upload C/C++ modules to CPAN project.
==========================================
why?
----
We want to upload C/C++ modules to CPAN.
Merit:
* use C/C++ libraries from XS!
* upload C/C++ program to CPAN and resolve dependencies automatically =)
how?
----
We will write Module::Install::Lang::C.
writing libraries
-----------------
If you wrote C library named Clib::picohttpclient, using autotools.
You can write Makefile.PL in following style.
{{{
use inc::Module::Install;
exec './configure', configure_options();
die "WTF";
}}}
configure_options() is defined at Module::Install::Lang::C.This method returns
the CPAN friendly compile options for configure.For example,
"--prefix=$CPANDIR/auto/Clib/" is passed.The program will be install to
$CPANDIR/auto/Clib/bin/, library will be install to $CPANDIR/auto/Clib/lib,
and header files copy to $CPANDIR/auto/Clib/include".
If owner user of installing has super user privilidges, the libraries will soft
link to "/usr/local/lib/libpicojson.so".This is needed for dynamic library loaders.
writing consumers(XS)
---------------------
And, You want to write XS module depend to Clib::picohttpparser.
Makfile.PL is...
{{{
use inc::Module::Install;
cc_libs 'picohttpparser';
set_clib_options;
WriteMakefile;
}}}
The 'set_clib_options' method is provided by Module::Install::Lang::C.
This method sets "-L $CPANLIB/auto/Clib/lib/" for linker option.And add "-I
$CPANLIB/auto/Clib/include" for compiler option.
and in your perl module loader
>||
package HTML::Parser::XS;
use strict;
use XSLoader;
our $VERSION = 0.01;
use Clib;
XSLoader::load(__PACKAGE__, $VERSION);
1;
||<
Clib.pm will set the path to $CPANLIB/auto/Clib/lib/ for loading dynamic libraries.
Link to system directory
------------------------
If you want to use CPAN modules to
>||
ln -s $CPANLIB/auto/Clib/lib/ /usr/local/clib
||<
FAQ
---
Q. CPAN is Comprehensive Perl Archive Network, not for C/C++!
A. ingy already uploads a lot of JS::* modules :P
Q. Why don't install it to system /usr/local/lib/ directory?
Or, why don't use Alien::* style appraoch?
A. I want to use library who don't have super user priviledges.