| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::bz2::Installer; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
227310
|
use strict; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
279
|
|
|
4
|
8
|
|
|
8
|
|
37
|
use warnings; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
19192
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Installer for bz2 |
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _catfile { |
|
10
|
0
|
|
|
0
|
|
0
|
my $path = File::Spec->catfile(@_); |
|
11
|
0
|
0
|
|
|
|
0
|
$path =~ s{\\}{/}g if $^O eq 'MSWin32'; |
|
12
|
0
|
|
|
|
|
0
|
$path; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _catdir { |
|
16
|
0
|
|
|
0
|
|
0
|
my $path = File::Spec->catdir(@_); |
|
17
|
0
|
0
|
|
|
|
0
|
$path =~ s{\\}{/}g if $^O eq 'MSWin32'; |
|
18
|
0
|
|
|
|
|
0
|
$path; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub versions_available |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
1
|
50
|
|
1
|
1
|
14
|
($^O eq 'MSWin32' ? '1.0.5' : '1.0.6'); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub fetch |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
0
|
|
|
0
|
1
|
0
|
my($class, %options) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
0
|
my $dir = $options{dir} || eval { require File::Temp; File::Temp::tempdir( CLEANUP => 1 ) }; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# actually we ignore the version argument. |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
require File::Spec; |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
my $url = 'http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz'; |
|
39
|
0
|
|
|
|
|
0
|
my $fn = _catfile($dir, 'bzip2-1.0.6.tar.gz'); |
|
40
|
0
|
|
|
|
|
0
|
my($version) = $class->versions_available; |
|
41
|
0
|
0
|
|
|
|
0
|
if($^O eq 'MSWin32') |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
0
|
$url = 'http://gnuwin32.sourceforge.net/downlinks/bzip2-src-zip.php'; |
|
44
|
0
|
|
|
|
|
0
|
$fn = _catfile($dir, 'bzip2-1.0.5-src.zip'); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
require HTTP::Tiny; |
|
48
|
0
|
|
|
|
|
0
|
my $response = HTTP::Tiny->new->get($url); |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
0
|
die sprintf("%s %s %s", $response->{status}, $response->{reason}, $url) |
|
51
|
|
|
|
|
|
|
unless $response->{success}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
open my $fh, '>', $fn; |
|
54
|
0
|
|
|
|
|
0
|
binmode $fh; |
|
55
|
0
|
|
|
|
|
0
|
print $fh $response->{content}; |
|
56
|
0
|
|
|
|
|
0
|
close $fh; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
0
|
wantarray ? ($fn, $version) : $fn; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub build_requires |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
1
|
|
|
1
|
1
|
11
|
my %prereqs = ( |
|
65
|
|
|
|
|
|
|
'HTTP::Tiny' => 0, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
1
|
50
|
|
|
|
5
|
if($^O eq 'MSWin32') |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
0
|
|
|
|
|
0
|
$prereqs{'Archive::Zip'} = 0; |
|
71
|
0
|
|
|
|
|
0
|
$prereqs{'Alien::o2dll'} = 0; |
|
72
|
0
|
|
|
|
|
0
|
$prereqs{'Alien::MSYS'} = 0; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
else |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
1
|
|
|
|
|
2
|
$prereqs{'Archive::Tar'} = 0; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
2
|
\%prereqs; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub system_requires |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
1
|
|
|
1
|
1
|
8
|
my %prereqs; |
|
86
|
1
|
|
|
|
|
2
|
\%prereqs; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub system_install |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
0
|
|
|
0
|
1
|
|
my($class, %options) = @_; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
$options{alien} = 1 unless defined $options{alien}; |
|
95
|
0
|
|
0
|
|
|
|
$options{test} ||= 'compile'; |
|
96
|
0
|
0
|
|
|
|
|
die "test must be one of compile, ffi or both" |
|
97
|
|
|
|
|
|
|
unless $options{test} =~ /^(compile|ffi|both)$/; |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $build = bless { |
|
100
|
|
|
|
|
|
|
cflags => [], |
|
101
|
|
|
|
|
|
|
libs => ['-lbz2'], |
|
102
|
|
|
|
|
|
|
}, $class; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
0
|
0
|
|
|
|
$build->test_compile_run || die $build->error if $options{test} =~ /^(compile|both)$/; |
|
105
|
0
|
0
|
0
|
|
|
|
$build->test_ffi || die $build->error if $options{test} =~ /^(ffi|both)$/; |
|
106
|
0
|
|
|
|
|
|
$build; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _msys |
|
111
|
|
|
|
|
|
|
{ |
|
112
|
0
|
|
|
0
|
|
|
my($sub) = @_; |
|
113
|
0
|
|
|
|
|
|
require Config; |
|
114
|
0
|
0
|
|
|
|
|
if($^O eq 'MSWin32') |
|
115
|
|
|
|
|
|
|
{ |
|
116
|
0
|
0
|
|
|
|
|
if($Config::Config{cc} !~ /cl(\.exe)?$/i) |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
0
|
|
|
|
|
|
require Alien::MSYS; |
|
119
|
0
|
|
|
0
|
|
|
return Alien::MSYS::msys(sub{ $sub->('make') }); |
|
|
0
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
0
|
|
|
|
|
|
$sub->($Config::Config{make}); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub build_install |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
0
|
|
|
0
|
1
|
|
my($class, $prefix, %options) = @_; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
0
|
|
|
|
$options{test} ||= 'compile'; |
|
130
|
0
|
0
|
|
|
|
|
die "test must be one of compile, ffi or both" |
|
131
|
|
|
|
|
|
|
unless $options{test} =~ /^(compile|ffi|both)$/; |
|
132
|
0
|
0
|
|
|
|
|
die "need an install prefix" unless $prefix; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$prefix =~ s{\\}{/}g; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
0
|
|
|
|
my $dir = $options{dir} || do { require File::Temp; File::Temp::tempdir( CLEANUP => 1 ) }; |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
require Cwd; |
|
139
|
0
|
|
|
|
|
|
require File::Spec; |
|
140
|
0
|
|
|
|
|
|
my $save = Cwd::getcwd(); |
|
141
|
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
my $build = eval { |
|
143
|
0
|
0
|
|
|
|
|
if($^O eq 'MSWin32') |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
0
|
|
|
|
|
|
require Archive::Zip; |
|
146
|
0
|
|
|
|
|
|
my $zip = Archive::Zip->new; |
|
147
|
0
|
|
0
|
|
|
|
$zip->read(scalar $options{tar} || $class->fetch); |
|
148
|
0
|
|
|
|
|
|
chdir $dir; |
|
149
|
0
|
|
|
|
|
|
mkdir 'bzip2-1.0.5'; |
|
150
|
0
|
|
|
|
|
|
chdir 'bzip2-1.0.5'; |
|
151
|
0
|
|
|
|
|
|
$zip->extractTree; |
|
152
|
0
|
|
|
|
|
|
chdir(_catdir(qw( src bzip2 1.0.5 bzip2-1.0.5 ))); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
else |
|
155
|
|
|
|
|
|
|
{ |
|
156
|
0
|
|
|
|
|
|
require Archive::Tar; |
|
157
|
0
|
|
|
|
|
|
my $tar = Archive::Tar->new; |
|
158
|
0
|
|
0
|
|
|
|
$tar->read($options{tar} || $class->fetch); |
|
159
|
0
|
|
|
|
|
|
chdir $dir; |
|
160
|
0
|
|
|
|
|
|
$tar->extract; |
|
161
|
0
|
|
|
|
|
|
chdir do { |
|
162
|
0
|
|
|
|
|
|
opendir my $dh, '.'; |
|
163
|
0
|
|
|
|
|
|
my(@list) = grep !/^\./,readdir $dh; |
|
164
|
0
|
|
|
|
|
|
close $dh; |
|
165
|
0
|
0
|
|
|
|
|
die "unable to find source in build root" if @list == 0; |
|
166
|
0
|
0
|
|
|
|
|
die "confused by multiple entries in the build root" if @list > 1; |
|
167
|
0
|
|
|
|
|
|
$list[0]; |
|
168
|
|
|
|
|
|
|
}; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
if($^O eq 'MSWin32') |
|
172
|
|
|
|
|
|
|
{ |
|
173
|
0
|
|
|
|
|
|
open my $fh, '<', 'Makefile'; |
|
174
|
0
|
|
|
|
|
|
my $makefile = do { local $/; <$fh> }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
close $fh; |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
$makefile =~ s/\to2dll/\t$^X -MAlien::o2dll=o2dll o2dll.pl/g; |
|
178
|
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
open $fh, '>', 'Makefile'; |
|
180
|
0
|
|
|
|
|
|
print $fh $makefile; |
|
181
|
0
|
|
|
|
|
|
close $fh; |
|
182
|
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
open $fh, '>', 'o2dll.pl'; |
|
184
|
0
|
|
|
|
|
|
print $fh "use Alien::o2dll qw( o2dll );\n"; |
|
185
|
0
|
|
|
|
|
|
print $fh "o2dll(\@ARGV)\n"; |
|
186
|
0
|
|
|
|
|
|
close $fh; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
_msys(sub { |
|
189
|
0
|
|
|
0
|
|
|
system 'make', 'all'; |
|
190
|
0
|
0
|
|
|
|
|
die "make all failed" if $?; |
|
191
|
0
|
|
|
|
|
|
system 'make', 'install', "PREFIX=$prefix"; |
|
192
|
0
|
0
|
|
|
|
|
die "make install failed" if $?; |
|
193
|
0
|
|
|
|
|
|
}); |
|
194
|
0
|
|
|
|
|
|
mkdir(_catdir($prefix, 'dll')); |
|
195
|
0
|
|
|
|
|
|
File::Copy::copy('bzip2.dll', _catfile($prefix, 'dll', 'bzip2.dll')); |
|
196
|
0
|
|
|
|
|
|
File::Copy::copy('libbz2.dll.a', _catfile($prefix, 'dll', 'libbz2.dll.a')); |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
else |
|
199
|
|
|
|
|
|
|
{ |
|
200
|
0
|
|
|
|
|
|
require Config; |
|
201
|
0
|
|
|
|
|
|
require File::Copy; |
|
202
|
0
|
|
|
|
|
|
my $make = $Config::Config{make}; |
|
203
|
0
|
|
|
|
|
|
system $make, -f => 'Makefile-libbz2_so'; |
|
204
|
0
|
0
|
|
|
|
|
die "make -f Makefile-libbz2_so failed" if $?; |
|
205
|
0
|
|
|
|
|
|
system $make, 'all'; |
|
206
|
0
|
0
|
|
|
|
|
die "make all failed" if $?; |
|
207
|
0
|
|
|
|
|
|
system $make, 'install', "PREFIX=$prefix"; |
|
208
|
0
|
0
|
|
|
|
|
die "make install failed" if $?; |
|
209
|
0
|
|
|
|
|
|
mkdir(_catdir($prefix, 'dll')); |
|
210
|
0
|
|
|
|
|
|
File::Copy::copy('libbz2.so.1.0.6', _catfile($prefix, 'dll', 'libbz2.so.1.0.6')); |
|
211
|
0
|
|
|
|
|
|
eval { chmod 0755, _catfile($prefix, 'dll', 'libbz2.so.1.0.6') }; |
|
|
0
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
my $build = bless { |
|
215
|
|
|
|
|
|
|
cflags => [ "-I" . _catdir($prefix, 'include') ], |
|
216
|
|
|
|
|
|
|
libs => [ "-L" . _catdir($prefix, 'lib'), '-lbz2' ], |
|
217
|
|
|
|
|
|
|
prefix => $prefix, |
|
218
|
|
|
|
|
|
|
dll_dir => [ 'dll' ], |
|
219
|
0
|
|
|
|
|
|
dlls => do { |
|
220
|
0
|
|
|
|
|
|
opendir(my $dh, File::Spec->catdir($prefix, 'dll')); |
|
221
|
0
|
0
|
|
|
|
|
[grep { ! -l File::Spec->catfile($prefix, 'dll', $_) } grep { /\.so/ || /\.(dll|dylib)$/ } grep !/^\./, readdir $dh]; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
}, |
|
223
|
|
|
|
|
|
|
}, $class; |
|
224
|
|
|
|
|
|
|
|
|
225
|
0
|
0
|
0
|
|
|
|
$build->test_compile_run || die $build->error if $options{test} =~ /^(compile|both)$/; |
|
226
|
0
|
0
|
0
|
|
|
|
$build->test_ffi || die $build->error if $options{test} =~ /^(ffi|both)$/; |
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
$build; |
|
229
|
|
|
|
|
|
|
}; |
|
230
|
|
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
my $error = $@; |
|
232
|
0
|
|
|
|
|
|
chdir $save; |
|
233
|
0
|
0
|
|
|
|
|
die $error if $error; |
|
234
|
0
|
|
|
|
|
|
$build; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
0
|
1
|
|
sub cflags { shift->{cflags} } |
|
240
|
0
|
|
|
0
|
1
|
|
sub libs { shift->{libs} } |
|
241
|
0
|
|
|
0
|
1
|
|
sub version { shift->{version} } |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub dlls |
|
244
|
|
|
|
|
|
|
{ |
|
245
|
0
|
|
|
0
|
1
|
|
my($self, $prefix) = @_; |
|
246
|
|
|
|
|
|
|
|
|
247
|
0
|
0
|
|
|
|
|
$prefix = $self->{prefix} unless defined $prefix; |
|
248
|
|
|
|
|
|
|
|
|
249
|
0
|
|
|
|
|
|
require File::Spec; |
|
250
|
|
|
|
|
|
|
|
|
251
|
0
|
0
|
0
|
|
|
|
unless(defined $self->{dlls} && defined $self->{dll_dir}) |
|
252
|
|
|
|
|
|
|
{ |
|
253
|
0
|
0
|
|
|
|
|
if($^O eq 'cygwin') |
|
254
|
|
|
|
|
|
|
{ |
|
255
|
0
|
|
|
|
|
|
opendir my $dh, '/usr/bin'; |
|
256
|
0
|
|
|
|
|
|
$self->{dlls} = [grep /^cygbz2-[0-9]+\.dll$/i, readdir $dh]; |
|
257
|
0
|
|
|
|
|
|
$self->{dll_dir} = []; |
|
258
|
0
|
|
|
|
|
|
$prefix = '/usr/bin'; |
|
259
|
0
|
|
|
|
|
|
closedir $dh; |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
else |
|
262
|
|
|
|
|
|
|
{ |
|
263
|
0
|
|
|
|
|
|
require DynaLoader; |
|
264
|
0
|
|
|
|
|
|
my $path = DynaLoader::dl_findfile(grep /^-l/, @{ $self->libs}); |
|
|
0
|
|
|
|
|
|
|
|
265
|
0
|
0
|
|
|
|
|
die "unable to find dynamic library" unless defined $path; |
|
266
|
0
|
|
|
|
|
|
my($vol, $dirs, $file) = File::Spec->splitpath($path); |
|
267
|
0
|
0
|
|
|
|
|
if($^O eq 'openbsd') |
|
268
|
|
|
|
|
|
|
{ |
|
269
|
|
|
|
|
|
|
# on openbsd we get the .a file back, so have to scan |
|
270
|
|
|
|
|
|
|
# for .so.#.# as there is no .so symlink |
|
271
|
0
|
|
|
|
|
|
opendir(my $dh, $dirs); |
|
272
|
0
|
|
|
|
|
|
$self->{dlls} = [grep /^libbz2.so/, readdir $dh]; |
|
273
|
0
|
|
|
|
|
|
closedir $dh; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
else |
|
276
|
|
|
|
|
|
|
{ |
|
277
|
0
|
|
|
|
|
|
$self->{dlls} = [ $file ]; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
0
|
|
|
|
|
|
$self->{dll_dir} = []; |
|
280
|
0
|
|
|
|
|
|
$prefix = File::Spec->catpath($vol, $dirs); |
|
281
|
0
|
|
|
|
|
|
$prefix =~ s{\\}{/}g; |
|
282
|
|
|
|
|
|
|
} |
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
map { _catfile($prefix, @{ $self->{dll_dir} }, $_) } @{ $self->{dlls} }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub test_compile_run |
|
290
|
|
|
|
|
|
|
{ |
|
291
|
0
|
|
|
0
|
1
|
|
my($self, %opt) = @_; |
|
292
|
|
|
|
|
|
|
|
|
293
|
0
|
|
|
|
|
|
delete $self->{error}; |
|
294
|
0
|
0
|
|
|
|
|
$opt{quiet} = 1 unless defined $opt{quiet}; |
|
295
|
0
|
|
0
|
|
|
|
my $cbuilder = $opt{cbuilder} || do { require ExtUtils::CBuilder; ExtUtils::CBuilder->new(quiet => $opt{quiet}) }; |
|
296
|
|
|
|
|
|
|
|
|
297
|
0
|
0
|
|
|
|
|
unless($cbuilder->have_compiler) |
|
298
|
|
|
|
|
|
|
{ |
|
299
|
0
|
|
|
|
|
|
$self->{error} = 'no compiler'; |
|
300
|
0
|
|
|
|
|
|
return; |
|
301
|
|
|
|
|
|
|
} |
|
302
|
|
|
|
|
|
|
|
|
303
|
0
|
|
0
|
|
|
|
my $dir = $opt{dir} || do { require File::Temp; File::Temp::tempdir(CLEANUP => 1) }; |
|
304
|
0
|
|
|
|
|
|
require File::Spec; |
|
305
|
0
|
|
|
|
|
|
my $fn = _catfile($dir, 'test.c'); |
|
306
|
0
|
|
|
|
|
|
do { |
|
307
|
0
|
|
|
|
|
|
open my $fh, '>', $fn; |
|
308
|
0
|
|
|
|
|
|
print $fh "#include \n", |
|
309
|
|
|
|
|
|
|
"#include \n", |
|
310
|
|
|
|
|
|
|
"int\n", |
|
311
|
|
|
|
|
|
|
"main(int argc, char *argv[])\n", |
|
312
|
|
|
|
|
|
|
"{\n", |
|
313
|
|
|
|
|
|
|
" printf(\"version = '%s'\\n\", BZ2_bzlibVersion());\n", |
|
314
|
|
|
|
|
|
|
" return 0;\n", |
|
315
|
|
|
|
|
|
|
"}\n"; |
|
316
|
0
|
|
|
|
|
|
close $fh; |
|
317
|
|
|
|
|
|
|
}; |
|
318
|
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
my $test_exe = eval { |
|
320
|
0
|
|
|
|
|
|
my $test_object = $cbuilder->compile( |
|
321
|
|
|
|
|
|
|
source => $fn, |
|
322
|
|
|
|
|
|
|
extra_compiler_flags => $self->cflags, |
|
323
|
|
|
|
|
|
|
); |
|
324
|
0
|
|
|
|
|
|
$cbuilder->link_executable( |
|
325
|
|
|
|
|
|
|
objects => $test_object, |
|
326
|
|
|
|
|
|
|
extra_linker_flags => $self->libs, |
|
327
|
|
|
|
|
|
|
); |
|
328
|
|
|
|
|
|
|
}; |
|
329
|
|
|
|
|
|
|
|
|
330
|
0
|
0
|
|
|
|
|
if(my $error = $@) |
|
331
|
|
|
|
|
|
|
{ |
|
332
|
0
|
|
|
|
|
|
$self->{error} = $error; |
|
333
|
0
|
|
|
|
|
|
return; |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
|
|
336
|
0
|
0
|
|
|
|
|
if($test_exe =~ /\s/) |
|
337
|
|
|
|
|
|
|
{ |
|
338
|
0
|
0
|
|
|
|
|
$test_exe = Win32::GetShortPathName($test_exe) if $^O eq 'MSWin32'; |
|
339
|
0
|
0
|
|
|
|
|
$test_exe = Cygwin::win_to_posix_path(Win32::GetShortPathName(Cygwin::posix_to_win_path($test_exe))) if $^O eq 'cygwin'; |
|
340
|
|
|
|
|
|
|
} |
|
341
|
|
|
|
|
|
|
|
|
342
|
0
|
|
|
|
|
|
my $output = `$test_exe`; |
|
343
|
|
|
|
|
|
|
|
|
344
|
0
|
0
|
|
|
|
|
if($?) |
|
345
|
|
|
|
|
|
|
{ |
|
346
|
0
|
0
|
|
|
|
|
if($? == -1) |
|
|
|
0
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
{ |
|
348
|
0
|
|
|
|
|
|
$self->{error} = "failed to execute $!"; |
|
349
|
|
|
|
|
|
|
} |
|
350
|
|
|
|
|
|
|
elsif($? & 127) |
|
351
|
|
|
|
|
|
|
{ |
|
352
|
0
|
|
|
|
|
|
$self->{error} = "child died with signal" . ($? & 127); |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
else |
|
355
|
|
|
|
|
|
|
{ |
|
356
|
0
|
|
|
|
|
|
$self->{error} = "child exited with value " . ($? >> 8); |
|
357
|
|
|
|
|
|
|
} |
|
358
|
0
|
|
|
|
|
|
return; |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
0
|
0
|
|
|
|
|
if($output =~ /version = '(.*?),/) |
|
362
|
|
|
|
|
|
|
{ |
|
363
|
0
|
|
|
|
|
|
return $self->{version} = $1; |
|
364
|
|
|
|
|
|
|
} |
|
365
|
|
|
|
|
|
|
else |
|
366
|
|
|
|
|
|
|
{ |
|
367
|
0
|
|
|
|
|
|
$self->{error} = "unable to retrieve version from output"; |
|
368
|
0
|
|
|
|
|
|
return; |
|
369
|
|
|
|
|
|
|
} |
|
370
|
|
|
|
|
|
|
} |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
sub test_ffi |
|
374
|
|
|
|
|
|
|
{ |
|
375
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
|
376
|
0
|
|
|
|
|
|
require FFI::Raw; |
|
377
|
|
|
|
|
|
|
|
|
378
|
0
|
|
|
|
|
|
foreach my $dll ($self->dlls) |
|
379
|
|
|
|
|
|
|
{ |
|
380
|
0
|
|
|
|
|
|
my $get_version = eval { |
|
381
|
0
|
|
|
|
|
|
FFI::Raw->new( |
|
382
|
|
|
|
|
|
|
$dll, 'BZ2_bzlibVersion', FFI::Raw::str(), |
|
383
|
|
|
|
|
|
|
); |
|
384
|
|
|
|
|
|
|
}; |
|
385
|
0
|
0
|
|
|
|
|
next if $@; |
|
386
|
0
|
0
|
|
|
|
|
if($get_version->() =~ /^(.*?),/) |
|
387
|
|
|
|
|
|
|
{ |
|
388
|
0
|
|
|
|
|
|
return $self->{version} = $1; |
|
389
|
|
|
|
|
|
|
} |
|
390
|
|
|
|
|
|
|
} |
|
391
|
0
|
|
|
|
|
|
$self->{error} = 'BZ2_bzlibVersion not found (ffi)'; |
|
392
|
0
|
|
|
|
|
|
return; |
|
393
|
|
|
|
|
|
|
} |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
|
|
396
|
0
|
|
|
0
|
1
|
|
sub error { $_[0]->{error} } |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
1; |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
__END__ |