-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalienfile
More file actions
112 lines (91 loc) · 2.79 KB
/
alienfile
File metadata and controls
112 lines (91 loc) · 2.79 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
use alienfile;
use Path::Tiny qw( path );
use File::Glob qw( bsd_glob );
use Config;
my $compiler_type = meta_prop->{platform}->{compiler_type};
meta_prop->{my_makefile} = $compiler_type eq 'microsoft' ? 'makefile.msc' : 'Makefile';
if($compiler_type eq 'microsoft')
{
plugin 'Probe::Vcpkg' => (
name => 'bzip2',
ffi_name => 'bz2',
);
meta->after_hook(
gather_system => sub {
my($build) = @_;
require Win32::Vcpkg;
my $root = Win32::Vcpkg->root;
my $triplet = Win32::Vcpkg->perl_triplet;
$build->runtime_prop->{my_bin_dir} = path($root)->child('installed', $triplet, 'tools', 'bzip2')->stringify;
},
);
}
else
{
plugin 'Probe::CBuilder' => (
libs => '-lbz2',
version => qr/version = '(.*?)[,']/,
program => q{
#include <bzlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("version = '%s'\n", BZ2_bzlibVersion());
return 0;
}
},
);
plugin 'Probe::CommandLine' => (
command => 'bzip2',
secondary => 1,
);
}
share {
plugin 'Build::MSYS' => () unless $compiler_type eq 'microsoft';
plugin 'Download' => (
url => 'https://sourceforge.net/projects/bzip2/files/latest/download',
);
plugin Extract => 'tar.gz';
patch [ '%{patch} -p1 < %{.install.patch}/bzip2-1.0.6.diff' ];
my @build;
push @build,
[ '%{make}', -f => '%{.meta.my_makefile}', 'all', "CC=%{perl.config.cc}", "CFLAGS=%{perl.config.cccdlflags} %{perl.config.optimize}", ],
[ '%{make}', -f => '%{.meta.my_makefile}', 'install', 'PREFIX=%{.install.prefix}', 'EXE=%{perl.config.exe_ext}' ];
push @build, sub {
my($build) = @_;
my($version) = path(".")->absolute->basename =~ /([0-9\.]+)$/;
$build->runtime_prop->{version} = $version;
};
if($^O !~ /^(MSWin32|cygwin|msys)$/)
{
push @build, [ '%{make}', -f => 'Makefile-libbz2_so', sub {
my($build, $det) = @_;
if($det->{exit} == 0)
{
my @dlls = grep { ! -l $_ } bsd_glob 'libbz2*.so*';
my $dest = path($build->install_prop->{prefix})->child('dynamic');
$dest->mkpath;
path($_)->copy($dest->child($_))
for @dlls;
}
}];
}
build \@build;
gather sub {
my($build) = @_;
my $prefix = $build->runtime_prop->{prefix};
$build->runtime_prop->{cflags} = "-I$prefix/include ";
$build->runtime_prop->{cflags_static} = "-I$prefix/include ";
if($compiler_type eq 'microsoft')
{
$build->runtime_prop->{libs} = "-LIBPATH:$prefix/lib libbz2.lib ";
$build->runtime_prop->{libs_static} = "-LIBPATH:$prefix/lib libbz2.lib ";
}
else
{
$build->runtime_prop->{cflags_static} .= ' -DBZ_STATIC=1';
$build->runtime_prop->{libs} = "-L$prefix/lib -lbz2 ";
$build->runtime_prop->{libs_static} = "-L$prefix/lib -lbz2 ";
}
};
};