forked from hoelzro/inline-lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.PL
More file actions
129 lines (102 loc) · 3.52 KB
/
Makefile.PL
File metadata and controls
129 lines (102 loc) · 3.52 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
use 5.006;
use strict;
use warnings;
use ExtUtils::MakeMaker;
use Config;
{
my $CC = $Config{cc};
my @config;
sub get_lua_config {
my %args = map { split /\s*=\s*/, $_, 2 } @ARGV;
my $libs = $args{'LIBS'};
my $inc = $args{'INC'};
return ( $inc, $libs ) if defined($inc) && defined($libs);
if ($^O eq 'MSWin32' && exists $ENV{'LUA_DEV'}) {
$inc = '"' . '-I' . $ENV{LUA_DEV} . '\\include' . '"';
$libs = '"' . '-l' . $ENV{LUA_DEV} . '\\lib\\lua5.1.lib' . '"';
return ( $inc, $libs );
}
my @candidates = (
'lua-config',
'pkg-config lua',
'pkg-config lua5.4',
'pkg-config lua-5.4',
'pkg-config lua5.3',
'pkg-config lua-5.3',
'pkg-config lua5.2',
'pkg-config lua-5.2',
'pkg-config lua5.1',
'pkg-config lua-5.1',
);
foreach my $command (@candidates) {
my $status = system "$command >/dev/null 2>/dev/null"; # XXX *nix-specific
if($status == 0) {
my $extra_args = `$command --libs --cflags`;
chomp $extra_args;
$status = system("$CC check.c $extra_args 2>/dev/null");
if($status == 0) {
$libs ||= `$command --libs`;
$inc ||= `$command --cflags`;
chomp for $libs, $inc;
return ( $inc, $libs );
}
}
}
return;
}
}
##{ $share_dir_code{preamble} || '' ##}
my %makefile_params;
unless($ENV{'PERL_MM_OPT'} && $ENV{'PERL_MM_OPT'} =~ /(INC|LIBS)(?![a-z])/i) {
my ( $inc, $libs ) = get_lua_config();
if (!$inc && !$libs ) {
die <<EOD;
*******************************************
Couldn't find a working Lua installation
on this machine. This is required for
this module.
To obtain it, go to
http://www.lua.org/download.html
*******************************************
If Makefile.PL failed to find your Lua installation,
you can specify INC and LIBS flags directly:
perl Makefile.PL INC=-I/usr/include/lua5.1 LIBS=-llua5.1
(You can also specify INC/LIBS using PERL_MM_OPT)
EOD
}
%makefile_params = (
LIBS => [ $libs ],
INC => "-I. $inc",
);
}
WriteMakefile(
NAME => 'Inline::Lua',
##{ $plugin->get_default(qw(ABSTRACT AUTHOR LICENSE VERSION)) ##}
##{ $plugin->get_prereqs(1) ##}
DEFINE => '',
clean => { FILES => "_Inline a.out" },
%makefile_params
);
if (eval {require ExtUtils::Constant; 1}) {
# If you edit these definitions to change the constants used by this module,
# you will need to use the generated const-c.inc and const-xs.inc
# files to replace their "fallback" counterparts before distributing your
# changes.
my @names = (qw());
ExtUtils::Constant::WriteConstants(
NAME => 'Inline::Lua',
NAMES => \@names,
DEFAULT_TYPE => 'IV',
C_FILE => 'const-c.inc',
XS_FILE => 'const-xs.inc',
);
}
else {
use File::Copy;
use File::Spec;
foreach my $file ('const-c.inc', 'const-xs.inc') {
my $fallback = File::Spec->catfile('fallback', $file);
copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
}
}
##{ $share_dir_code{postamble} || '' ##}