Alien-Libarchive-Installer
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Alien/Libarchive/Installer.pm view on Meta::CPAN
system $make, 'all';
die "make all failed" if $?;
system $make, 'install';
die "make install failed" if $?;
});
require File::Spec;
foreach my $name ($^O =~ /^(MSWin32|cygwin)$/ ? ('bin','lib') : ('lib'))
{
do {
my $static_dir = File::Spec->catdir($prefix, $name);
my $dll_dir = File::Spec->catdir($prefix, 'dll');
require File::Path;
File::Path::mkpath($dll_dir, 0, 0755);
my $dh;
opendir $dh, $static_dir;
my @list = readdir $dh;
@list = grep { /\.so/ || /\.(dylib|la|dll|dll\.a)$/ } grep !/^\./, @list;
closedir $dh;
foreach my $basename (@list)
{
my $from = File::Spec->catfile($static_dir, $basename);
my $to = File::Spec->catfile($dll_dir, $basename);
if(-l $from)
{
symlink(readlink $from, $to);
unlink($from);
}
else
{
require File::Copy;
File::Copy::move($from, $to);
}
}
};
}
my $pkg_config_dir = File::Spec->catdir($prefix, 'lib', 'pkgconfig');
my $pcfile = File::Spec->catfile($pkg_config_dir, 'libarchive.pc');
do {
my @content;
if($Config::Config{cc} !~ /cl(\.exe)?$/i)
{
open my $fh, '<', $pcfile;
@content = map { s{$prefix}{'${pcfiledir}/../..'}eg; $_ } do { <$fh> };
close $fh;
}
else
{
# TODO: later when we know the version with more
# certainty, we can update this file with the
# Version
@content = join "\n", "prefix=\${pcfiledir}/../..",
"exec_prefix=\${prefix}",
"libdir=\${exec_prefix}/lib",
"includedir=\${prefix}/include",
"Name: libarchive",
"Description: library that can create and read several streaming archive formats",
"Cflags: -I\${includedir}",
"Libs: advapi32.lib \${libdir}/archive_static.lib",
"Libs.private: ",
"";
require File::Path;
File::Path::mkpath($pkg_config_dir, 0, 0755);
}
my($version) = map { /^Version:\s*(.*)$/; $1 } grep /^Version: /, @content;
# older versions apparently didn't include the necessary -I and -L flags
if(defined $version && $version =~ /^[12]\./)
{
for(@content)
{
s/^Libs: /Libs: -L\${libdir} /;
}
push @content, "Cflags: -I\${includedir}\n";
}
open my $fh, '>', $pcfile;
print $fh @content;
close $fh;
};
my $build = bless {
cflags => _try_pkg_config($pkg_config_dir, 'cflags', '-I' . File::Spec->catdir($prefix, 'include'), '--static'),
libs => _try_pkg_config($pkg_config_dir, 'libs', '-L' . File::Spec->catdir($prefix, 'lib'), '--static'),
prefix => $prefix,
dll_dir => [ 'dll' ],
dlls => do {
opendir(my $dh, File::Spec->catdir($prefix, 'dll'));
[grep { ! -l File::Spec->catfile($prefix, 'dll', $_) } grep { /\.so/ || /\.(dll|dylib)$/ } grep !/^\./, readdir $dh];
},
}, $class;
if($^O eq 'cygwin' || $^O eq 'MSWin32')
{
# TODO: should this go in the munged pc file?
unshift @{ $build->{cflags} }, '-DLIBARCHIVE_STATIC';
}
$build->test_compile_run || die $build->error if $options{test} =~ /^(compile|both)$/;
$build->test_ffi || die $build->error if $options{test} =~ /^(ffi|both)$/;
$build;
};
my $error = $@;
chdir $save;
die $error if $error;
$build;
}
sub cflags { shift->{cflags} }
sub libs { shift->{libs} }
sub version { shift->{version} }
sub dlls
{
my($self, $prefix) = @_;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.046 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b )