tokuhirom (owner)

Revisions

gist: 204872 Download_button fork
public
Public Clone URL: git://gist.github.com/204872.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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.