Alien-Build
view release on metacpan or search on metacpan
lib/Alien/Base.pm view on Meta::CPAN
L<Alien::Build::Manual::AlienAuthor>).
Then a C<MyLibrary::XS> can use C<Alien::MyLibrary> in its C<Makefile.PL>:
use Alien::MyLibrary
use ExtUtils::MakeMaker;
use Alien::Base::Wrapper qw( Alien::MyLibrary !export );
use Config;
WriteMakefile(
...
Alien::Base::Wrapper->mm_args,
...
);
Or if you prefer L<Module::Build>, in its C<Build.PL>:
use Alien::MyLibrary;
use Module::Build 0.28; # need at least 0.28
use Alien::Base::Wrapper qw( Alien::MyLibrary !export );
my $builder = Module::Build->new(
...
Alien::Base::Wrapper->mb_args,
...
);
$builder->create_build_script;
Or if you are using L<ExtUtils::Depends>:
use ExtUtils::MakeMaker;
use ExtUtils::Depends;
my $eud = ExtUtils::Depends->new(qw( MyLibrary::XS Alien::MyLibrary ));
WriteMakefile(
...
$eud->get_makefile_vars
);
If you are using L<Alien::Base::ModuleBuild> instead of the recommended L<Alien::Build>
and L<alienfile>, then in your C<MyLibrary::XS> module, you may need something like
this in your main C<.pm> file IF your library uses dynamic libraries:
package MyLibrary::XS;
use Alien::MyLibrary; # may only be needed if you are using Alien::Base::ModuleBuild
...
Or you can use it from an FFI module:
package MyLibrary::FFI;
use Alien::MyLibrary;
use FFI::Platypus;
use FFI::CheckLib 0.28 qw( find_lib_or_die );
my $ffi = FFI::Platypus->new;
$ffi->lib(find_lib_or_die lib => 'mylib', alien => ['Alien::MyLibrary']);
$ffi->attach( 'my_library_function' => [] => 'void' );
You can even use it with L<Inline> (C and C++ languages are supported):
package MyLibrary::Inline;
use Alien::MyLibrary;
# Inline 0.56 or better is required
use Inline 0.56 with => 'Alien::MyLibrary';
...
=head1 DESCRIPTION
B<NOTE>: L<Alien::Base::ModuleBuild> is no longer bundled with L<Alien::Base> and has been spun off into a separate distribution.
L<Alien::Base::ModuleBuild> will be a prerequisite for L<Alien::Base> until October 1, 2017. If you are using L<Alien::Base::ModuleBuild>
you need to make sure it is declared as a C<configure_requires> in your C<Build.PL>. You may want to also consider using L<Alien::Base> and
L<alienfile> as a more modern alternative.
L<Alien::Base> comprises base classes to help in the construction of C<Alien::> modules. Modules in the L<Alien> namespace are used to locate and install (if necessary) external libraries needed by other Perl modules.
This is the documentation for the L<Alien::Base> module itself. If you
are starting out you probably want to do so from one of these documents:
=over 4
=item L<Alien::Build::Manual::AlienUser>
For users of an C<Alien::libfoo> that is implemented using L<Alien::Base>.
(The developer of C<Alien::libfoo> I<should> provide the documentation
necessary, but if not, this is the place to start).
=item L<Alien::Build::Manual::AlienAuthor>
If you are writing your own L<Alien> based on L<Alien::Build> and L<Alien::Base>.
=item L<Alien::Build::Manual::FAQ>
If you have a common question that has already been answered, like
"How do I use L<alienfile> with some build system".
=item L<Alien::Build::Manual::PluginAuthor>
This is for the brave souls who want to write plugins that will work with
L<Alien::Build> + L<alienfile>.
=back
Before using an L<Alien::Base> based L<Alien> directly, please consider the following advice:
If you are wanting to use an L<Alien::Base> based L<Alien> with an XS module using L<ExtUtils::MakeMaker> or L<Module::Build>, it is highly
recommended that you use L<Alien::Base::Wrapper>, rather than using the L<Alien> directly, because it handles a number of sharp edges and avoids
pitfalls common when trying to use an L<Alien> directly with L<ExtUtils::MakeMaker>.
In the same vein, if you are wanting to use an L<Alien::Base> based L<Alien> with an XS module using L<Dist::Zilla> it is highly recommended
that you use L<Dist::Zilla::Plugin::AlienBase::Wrapper> for the same reasons.
As of version 0.28, L<FFI::CheckLib> has a good interface for working with L<Alien::Base> based L<Alien>s in fallback mode, which is
recommended.
You should typically only be using an L<Alien::Base> based L<Alien> directly, if you need to integrate it with some other system, or if it
is a tool based L<Alien> that you don't need to link.
( run in 0.840 second using v1.01-cache-2.11-cpan-e1769b4cff6 )