-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathMakefile.PL
56 lines (48 loc) · 1.59 KB
/
Makefile.PL
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
use 5.008;
use ExtUtils::MakeMaker;
use lib qw(inc);
use Devel::CheckLib;
my $V8_DIR = $ENV{V8_DIR};
check_lib_or_exit(
lib => ['v8'],
$V8_DIR
? ( libpath => $V8_DIR, incpath => "$V8_DIR/include" )
: (),
);
my $CC = 'g++';
my %mm = (
NAME => 'JavaScript::V8',
VERSION_FROM => 'lib/JavaScript/V8.pm', # finds $VERSION
PREREQ_PM => {
'ExtUtils::XSpp' => '0.11',
'Test::Number::Delta' => 0,
}, # e.g., Module::Name => 1.1
ABSTRACT_FROM => 'lib/JavaScript/V8.pm', # retrieve abstract from module
AUTHOR => 'Pawel Murias <pawelmurias@gmail.org>',
LIBS => [($V8_DIR ? "-L$V8_DIR " : '') . '-lv8'], # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
INC => '-I.' . ($V8_DIR ? " -I$V8_DIR/include" : ''), # e.g., '-I. -I/usr/include/other'
OBJECT => '$(O_FILES)', # link all the C files too
XSOPT => '-C++ -hiertype',
TYPEMAPS => ['perlobject.map'],
CC => $CC,
LD => '$(CC)',
depend => { 'WithV8Context.c' => 'JavaScript-V8-Context.xsp' },
);
if(ExtUtils::MakeMaker->can("VERSION") && ExtUtils::MakeMaker->VERSION(6.46)) {
$mm{META_MERGE} = {
resources => {
repository => 'http://github.com/pmurias/javascript-v8',
}
};
}
if(gcc_version($CC) >= 4.5) {
$mm{CCFLAGS} = '-fpermissive';
}
WriteMakefile(%mm);
sub gcc_version {
my($cc) = @_;
my $gcc_out = qx{$cc -v 2>&1};
# Just the first two digits
$gcc_out =~ /gcc version (\d+\.\d+)/ ? $1 : 0;
}