view release on metacpan or search on metacpan
- dynamic libs handle upgrades more gracefully
- promote to production
0.18_06 2014-06-10 10:39:36 -0400
- Archive::Libarchive::XS dev compat
0.18_05 2014-06-10 10:19:42 -0400
- require Alien::Libarchive::Installer 0.03
0.18_04 2014-06-10 09:19:32 -0400
- cflags reference bug fix
0.18_03 2014-06-10 09:06:55 -0400
- fix prereqs
0.18_02 2014-06-10 08:36:20 -0400
- libs and cflags now return a list in list context and a scalar in scalar context
(used to always return a scalar)
0.18_01 2014-06-10 08:19:36 -0400
- completely new implementation based on Alien::Libarchive::Installer instead of Alien::Base
0.18 2014-02-03 16:40:43 -0500
- Fix ExtUtils::CChecker calling error
0.17 2014-02-03 16:37:39 -0500
- remove -fPIC / -fno-common detection and instead rely on $Config{cccdlflags}
- use $Config{optimize} for CFLAGS passed to libarchive configure
0.16 2014-02-02 04:30:52 -0500
- build with -fPIC if possible
0.15 2014-01-29 11:30:49 -0500
- fix prereqs
0.14 2014-01-29 09:37:52 -0500
- build with -fno-common if possible
- require Alien::Libarchive::MSWin32 0.04 on MSWin32
0.11 2013-12-24 09:26:53 -0500
- require Alien::Libarchive::MSWin32 0.02 on MSWin32
0.10 2013-12-19 03:04:41 -0500
- fix for beter detection of libarchive sans pkg-config as a system install
(runtime didn't work on non-FreeBSD systems)
0.09 2013-12-18 09:06:08 -0500
- verify Alien deps flags can at least compile a simple c program
- better detection of libarchive sans pkg-config as a system install
0.08 2013-12-12 17:07:56 -0500
- documentation
- try to use Alien::bz2 if available
- include bin directory in PATH for cygwin install_type = share
so dll can be found
- basic compile check to be sure it works
0.07 2013-12-05 18:44:24 -0500
SYNOPSIS
Build.PL
use Alien::Libarchive;
use Module::Build;
my $alien = Alien::Libarchive->new;
my $build = Module::Build->new(
...
extra_compiler_flags => [$alien->cflags],
extra_linker_flags => [$alien->libs],
...
);
$build->create_build_script;
Makefile.PL
use Alien::Libarchive;
use ExtUtils::MakeMaker;
my $alien = Alien::Libarchive;
WriteMakefile(
...
CCFLAGS => scalar $alien->cflags,
LIBS => [$alien->libs],
);
FFI::Platypus
use Alien::Libarchive;
use FFI::Platypus;
my $ffi = FFI::Platypus->new(lib => [Alien::Libarchive->new->dlls]);
$ffi->attach( archive_read_new => [] => 'opaque' );
% sudo apt-get install build-essential
Cygwin
On Cygwin, I couldn't get libarchive to build without making a minor
tweak to one of the include files. On Cygwin this module will patch
libarchive before it attempts to build if it is version 3.1.2.
METHODS
cflags
Returns the C compiler flags necessary to build against libarchive.
Returns flags as a list in list context and combined into a string in
scalar context.
libs
Returns the library flags necessary to build against libarchive.
Returns flags as a list in list context and combined into a string in
scalar context.
dlls
Returns a list of dynamic libraries (usually a list of just one
library) that make up libarchive. This can be used for FFI::Raw.
Returns just the first dynamic library found in scalar context.
version
---
pod_spelling_system:
skip: 0
# list of words that are spelled correctly
# (regardless of what spell check thinks)
stopwords:
- cflags
- libarchive
- libs
- dlls
- pc
pod_coverage:
skip: 0
# format is "Class#method" or "Class", regex allowed
# for either Class or method.
private:
installer = ModuleBuild
release_tests_skip = version.*
github_repo = Alien-Libarchive2
diag_preamble = | $post_diag = sub
diag_preamble = | {
diag_preamble = | eval {
diag_preamble = | require Alien::Libarchive;
diag_preamble = | my $alien = Alien::Libarchive->new;
diag_preamble = | diag 'libarchive';
diag_preamble = | diag ' cflags : ', join ' ', $alien->cflags;
diag_preamble = | diag ' libs : ', join ' ', $alien->libs;
diag_preamble = | diag ' install_type : ', $alien->install_type;
diag_preamble = | diag ' dlls : ', (eval { $alien->dlls } || 'not found');
diag_preamble = | diag ' version : ', (eval { $alien->version } || 'unknown');
diag_preamble = | };
diag_preamble = | };
[RemovePrereqs]
; comes with perl
remove = strict
inc/Alien/LZO/Installer.pm view on Meta::CPAN
# as an optional dep
use Alien::LZO::Installer;
use Module::Build;
my %build_args;
my $installer = eval { Alien::LZO::Installer->system_install };
if($installer)
{
$build_args{extra_compiler_flags} = $installer->cflags,
$build_args{extra_linker_flags} = $installer->libs,
}
my $build = Module::Build->new(%build_args);
$build->create_build_script;
Build.PL
# require 2.0
use Alien::LZO::Installer;
use Module::Build;
inc/Alien/LZO/Installer.pm view on Meta::CPAN
my $installer = eval {
my $system_installer = Alien::LZO::Installer->system_install;
die "we require 2.00 or better"
if $system->version !~ /^([0-9]+)\./ && $1 >= 2;
$system_installer;
# reasonably assumes that build_install will never download
# a version older that 3.0
} || Alien::LZO::Installer->build_install("dir");
my $build = Module::Build->new(
extra_compiler_flags => $installer->cflags,
extra_linker_flags => $installer->libs,
);
$build->create_build_script;
FFI::Raw
# as an optional dep
use Alien::LZO::Installer;
use FFI::Raw;
eval {
inc/Alien/LZO/Installer.pm view on Meta::CPAN
$options{alien} = 1 unless defined $options{alien};
$options{test} ||= 'compile';
die "test must be one of compile, ffi or both"
unless $options{test} =~ /^(compile|ffi|both)$/;
if($options{alien} && eval q{ use Alien::LZO 0.01; 1 })
{
my $alien = Alien::LZO->new;
my $build = bless {
cflags => $alien->cflags,
libs => $alien->libs,
}, $class;
return $build if $options{test} =~ /^(compile|both)$/ && $build->test_compile_run;
return $build if $options{test} =~ /^(ffi|both)$/ && $build->test_compile_run;
}
my $build = bless {
cflags => [],
libs => ['-llzo2'],
}, $class;
$build->test_compile_run || die $build->error if $options{test} =~ /^(compile|both)$/;
$build->test_ffi || die $build->error if $options{test} =~ /^(ffi|both)$/;
$build;
}
=head2 build_install
inc/Alien/LZO/Installer.pm view on Meta::CPAN
else
{
require File::Copy;
File::Copy::move($from, $to);
}
}
};
}
my $build = bless {
cflags => ['-I' . _catdir($prefix, 'include')],
libs => ['-L' . _catdir($prefix, 'lib'), '-llzo2'],
prefix => $prefix,
dll_dir => [ 'dll' ],
dlls => do {
opendir(my $dh, _catdir($prefix, 'dll'));
[grep { ! -l _catfile($prefix, 'dll', $_) } grep { /\.so/ || /\.(dll|dylib)$/ } grep !/^\./, readdir $dh];
},
}, $class;
$build->test_compile_run || die $build->error if $options{test} =~ /^(compile|both)$/;
inc/Alien/LZO/Installer.pm view on Meta::CPAN
$build;
}
=head1 ATTRIBUTES
Attributes of an L<Alien::LZO::Installer> provide the
information needed to use an existing lzo (which may
either be provided by the system, or have just been built
using L<build_install|Alien::LZO::Installer#build_install>.
=head2 cflags
The compiler flags required to use lzo.
=head2 libs
The linker flags and libraries required to use lzo.
=head2 dlls
List of DLL or .so (or other dynamic library) files that can
be used by L<FFI::Raw> or similar.
=head2 version
The version of lzo
=cut
sub cflags { shift->{cflags} }
sub libs { shift->{libs} }
sub version { shift->{version} }
sub dlls
{
my($self, $prefix) = @_;
$prefix = $self->{prefix} unless defined $prefix;
unless(defined $self->{dlls} && defined $self->{dll_dir})
inc/Alien/LZO/Installer.pm view on Meta::CPAN
" printf(\"lzo_version = %d\\n\", lzo_version());\n",
" printf(\"version = '%s'\\n\", LZO_VERSION_STRING);\n",
" return 0;\n",
"}\n";
close $fh;
};
my $test_object = eval {
$cbuilder->compile(
source => $fn,
extra_compiler_flags => $self->{cflags} || [],
);
};
if(my $error = $@)
{
$self->{error} = $error;
return;
}
my $test_exe = eval {
$cbuilder->link_executable(
objects => $test_object,
extra_linker_flags => $self->{libs} || [],
);
};
if(my $error = $@)
{
$self->{error} = $error;
return;
}
if($test_exe =~ /\s/)
inc/My/ModuleBuild.pm view on Meta::CPAN
$self->config_data( already_built => 0 );
$self->config_data( msvc => $^O eq 'MSWin32' && $Config{cc} =~ /cl(\.exe)?$/i ? 1 : 0 );
$self->add_to_cleanup( '_alien', '_alien_libarchive', '_alien_bz2', '_alien_lzo', 'share/libarchive019' );
if(defined $system)
{
print "Found libarchive " . $system->version . " from system\n";
print "You can set ALIEN_LIBARCHIVE=share to force building from source\n";
$self->config_data( install_type => 'system' );
$self->config_data( cflags => _list $system->cflags );
$self->config_data( libs => _list $system->libs );
$self->config_data( version => $system->version );
}
else
{
print "Did not find working libarchive, will download and install from the Internet\n";
$self->config_data( install_type => 'share' );
}
$self;
inc/My/ModuleBuild.pm view on Meta::CPAN
}
}
}
}
my $build_dir = _catdir($FindBin::Bin, '_alien_libarchive');
mkdir $build_dir unless -d $build_dir;
mkdir $prefix unless -d $prefix;
my $build = Alien::Libarchive::Installer->build_install( $prefix, dir => $build_dir );
$self->config_data( cflags => [grep !/^-I/, @{ _list $build->cflags }] );
$self->config_data( libs => [grep !/^-L/, @{ _list $build->libs }] );
if($self->config_data('msvc'))
{
$self->config_data( libs => [grep !/^(\/|-)libpath/i, @{ _list $build->libs }] );
}
$self->config_data( version => $build->version );
printf "cflags: %s\n", join ' ', @{ $self->config_data('cflags') };
printf "libs: %s\n", join ' ', @{ $self->config_data('libs') };
printf "msvc: %d\n", $self->config_data('msvc');
do {
opendir my $dh, _catdir($prefix, 'dll');
my @list = grep { ! -l _catfile($prefix, 'dll', $_) }
grep { /\.so/ || /\.(dll|dylib)$/ }
grep !/^(libbz2|bzip2.dll|liblzo2)/,
grep !/^\./,
sort
inc/My/ModuleBuild.pm view on Meta::CPAN
# The name that we can dlopen(3).
dlname='../bin/bzip2.dll'
# Names of this library.
library_names='../dll/libbz2.dll.a'
# The name of the static archive.
old_library='libbz2.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=''
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libbz2.
current=14
age=1
lib/Alien/Libarchive.pm view on Meta::CPAN
}
sub new
{
my($class) = @_;
bless {}, $class;
}
sub cflags
{
my($class) = @_;
my @cflags = @{ $cf->config("cflags") };
unshift @cflags, '-I' . _catdir(_share_dir, 'libarchive019', 'include' )
if $class->install_type eq 'share';
wantarray ? @cflags : "@cflags";
}
sub libs
{
my($class) = @_;
my @libs = @{ $cf->config("libs") };
if($class->install_type eq 'share')
{
if($cf->config('msvc'))
lib/Alien/Libarchive.pm view on Meta::CPAN
# build process (and maybe Archive::Libarchive::FFI) to automatically
# generate constants
# UPDATE: this maybe should use C::Scan or C::Scan::Constants
sub _macro_list
{
require Config;
require File::Temp;
require File::Spec;
my $alien = Alien::Libarchive->new;
my $cc = "$Config::Config{ccname} $Config::Config{ccflags} " . $alien->cflags;
my $fn = File::Spec->catfile(File::Temp::tempdir( CLEANUP => 1 ), "test.c");
do {
open my $fh, '>', $fn;
print $fh "#include <archive.h>\n";
print $fh "#include <archive_entry.h>\n";
close $fh;
};
lib/Alien/Libarchive.pm view on Meta::CPAN
=head1 SYNOPSIS
Build.PL
use Alien::Libarchive;
use Module::Build;
my $alien = Alien::Libarchive->new;
my $build = Module::Build->new(
...
extra_compiler_flags => [$alien->cflags],
extra_linker_flags => [$alien->libs],
...
);
$build->create_build_script;
Makefile.PL
use Alien::Libarchive;
use ExtUtils::MakeMaker;
my $alien = Alien::Libarchive;
WriteMakefile(
...
CCFLAGS => scalar $alien->cflags,
LIBS => [$alien->libs],
);
FFI::Platypus
use Alien::Libarchive;
use FFI::Platypus;
my $ffi = FFI::Platypus->new(lib => [Alien::Libarchive->new->dlls]);
$ffi->attach( archive_read_new => [] => 'opaque' );
lib/Alien/Libarchive.pm view on Meta::CPAN
On Cygwin, I couldn't get libarchive to build without making a
minor tweak to one of the include files. On Cygwin this module
will patch libarchive before it attempts to build if it is
version 3.1.2.
=back
=head1 METHODS
=head2 cflags
Returns the C compiler flags necessary to build against libarchive.
Returns flags as a list in list context and combined into a string in
scalar context.
=head2 libs
Returns the library flags necessary to build against libarchive.
Returns flags as a list in list context and combined into a string in
scalar context.
=head2 dlls
Returns a list of dynamic libraries (usually a list of just one library)
that make up libarchive. This can be used for L<FFI::Raw>.
Returns just the first dynamic library found in scalar context.
=head2 version
t/00_diag.t view on Meta::CPAN
Module::Build
Test::More
);
$post_diag = sub
{
eval {
require Alien::Libarchive;
my $alien = Alien::Libarchive->new;
diag 'libarchive';
diag ' cflags : ', join ' ', $alien->cflags;
diag ' libs : ', join ' ', $alien->libs;
diag ' install_type : ', $alien->install_type;
diag ' dlls : ', (eval { $alien->dlls } || 'not found');
diag ' version : ', (eval { $alien->version } || 'unknown');
};
};
my @modules = sort keys %modules;
sub spacer ()