Initial Commit
This commit is contained in:
96
database/perl/vendor/lib/Alien/Base/Authoring.pod
vendored
Normal file
96
database/perl/vendor/lib/Alien/Base/Authoring.pod
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# ABSTRACT: Authoring an Alien distribution using Alien::Base
|
||||
# PODNAME: Alien::Base::Authoring
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Alien::Base::Authoring - Authoring an Alien distribution using Alien::Base
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.38
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
% perldoc Alien::Build::Manual::AlienAuthor
|
||||
% perldoc Alien::Base::ModuleBuild::Authoring
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This used to document the only way to author an L<Alien> distribution, which
|
||||
was with L<Alien::Base::ModuleBuild>. You should now seriously consider using
|
||||
the newer more reliable method which is via L<Alien::Build> and L<alienfile>. Read all about it in L<Alien::Build::Manual::AlienAuthor> and L<Alien::Base::ModuleBuild::Authoring>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
|
||||
|
||||
Contributors:
|
||||
|
||||
Diab Jerius (DJERIUS)
|
||||
|
||||
Roy Storey (KIWIROY)
|
||||
|
||||
Ilya Pavlov
|
||||
|
||||
David Mertens (run4flat)
|
||||
|
||||
Mark Nunberg (mordy, mnunberg)
|
||||
|
||||
Christian Walde (Mithaldu)
|
||||
|
||||
Brian Wightman (MidLifeXis)
|
||||
|
||||
Zaki Mughal (zmughal)
|
||||
|
||||
mohawk (mohawk2, ETJ)
|
||||
|
||||
Vikas N Kumar (vikasnkumar)
|
||||
|
||||
Flavio Poletti (polettix)
|
||||
|
||||
Salvador Fandiño (salva)
|
||||
|
||||
Gianni Ceccarelli (dakkar)
|
||||
|
||||
Pavel Shaydo (zwon, trinitum)
|
||||
|
||||
Kang-min Liu (劉康民, gugod)
|
||||
|
||||
Nicholas Shipp (nshp)
|
||||
|
||||
Juan Julián Merelo Guervós (JJ)
|
||||
|
||||
Joel Berger (JBERGER)
|
||||
|
||||
Petr Pisar (ppisar)
|
||||
|
||||
Lance Wicks (LANCEW)
|
||||
|
||||
Ahmad Fatoum (a3f, ATHREEF)
|
||||
|
||||
José Joaquín Atria (JJATRIA)
|
||||
|
||||
Duke Leto (LETO)
|
||||
|
||||
Shoichi Kaji (SKAJI)
|
||||
|
||||
Shawn Laffan (SLAFFAN)
|
||||
|
||||
Paul Evans (leonerd, PEVANS)
|
||||
|
||||
Håkon Hægland (hakonhagland, HAKONH)
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2011-2020 by Graham Ollis.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
106
database/perl/vendor/lib/Alien/Base/FAQ.pod
vendored
Normal file
106
database/perl/vendor/lib/Alien/Base/FAQ.pod
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
# ABSTRACT: Frequently asked questions
|
||||
# VERSION
|
||||
# PODNAME: Alien::Base::FAQ
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Alien::Base::FAQ - Frequently asked questions
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.38
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
% perldoc Alien::Build::Manual::FAQ
|
||||
% perldoc Alien::Base::ModuleBuild::FAQ
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This used to answer FAQs regarding the only way to author an L<Alien::Build>
|
||||
distribution, which was with L<Aien::Base::ModuleBuild>. You should now
|
||||
seriously consider using the newer more reliable method which is via
|
||||
L<Alien::Build> and L<alienfile>.
|
||||
|
||||
=over 4
|
||||
|
||||
=item L<Alien::Build::Manual::FAQ>
|
||||
|
||||
=item L<Alien::Base::ModuleBuild::FAQ>
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
|
||||
|
||||
Contributors:
|
||||
|
||||
Diab Jerius (DJERIUS)
|
||||
|
||||
Roy Storey (KIWIROY)
|
||||
|
||||
Ilya Pavlov
|
||||
|
||||
David Mertens (run4flat)
|
||||
|
||||
Mark Nunberg (mordy, mnunberg)
|
||||
|
||||
Christian Walde (Mithaldu)
|
||||
|
||||
Brian Wightman (MidLifeXis)
|
||||
|
||||
Zaki Mughal (zmughal)
|
||||
|
||||
mohawk (mohawk2, ETJ)
|
||||
|
||||
Vikas N Kumar (vikasnkumar)
|
||||
|
||||
Flavio Poletti (polettix)
|
||||
|
||||
Salvador Fandiño (salva)
|
||||
|
||||
Gianni Ceccarelli (dakkar)
|
||||
|
||||
Pavel Shaydo (zwon, trinitum)
|
||||
|
||||
Kang-min Liu (劉康民, gugod)
|
||||
|
||||
Nicholas Shipp (nshp)
|
||||
|
||||
Juan Julián Merelo Guervós (JJ)
|
||||
|
||||
Joel Berger (JBERGER)
|
||||
|
||||
Petr Pisar (ppisar)
|
||||
|
||||
Lance Wicks (LANCEW)
|
||||
|
||||
Ahmad Fatoum (a3f, ATHREEF)
|
||||
|
||||
José Joaquín Atria (JJATRIA)
|
||||
|
||||
Duke Leto (LETO)
|
||||
|
||||
Shoichi Kaji (SKAJI)
|
||||
|
||||
Shawn Laffan (SLAFFAN)
|
||||
|
||||
Paul Evans (leonerd, PEVANS)
|
||||
|
||||
Håkon Hægland (hakonhagland, HAKONH)
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2011-2020 by Graham Ollis.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
254
database/perl/vendor/lib/Alien/Base/PkgConfig.pm
vendored
Normal file
254
database/perl/vendor/lib/Alien/Base/PkgConfig.pm
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
package Alien::Base::PkgConfig;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use 5.008004;
|
||||
use Carp;
|
||||
use Config;
|
||||
use Path::Tiny qw( path );
|
||||
use Capture::Tiny qw( capture_stderr );
|
||||
|
||||
# ABSTRACT: Private legacy pkg-config class for Alien::Base
|
||||
our $VERSION = '2.38'; # VERSION
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
||||
# allow creation of an object from a full spec.
|
||||
if (ref $_[0] eq 'HASH') {
|
||||
return bless $_[0], $class;
|
||||
}
|
||||
|
||||
my ($path) = @_;
|
||||
croak "Must specify a file" unless defined $path;
|
||||
|
||||
$path = path( $path )->absolute;
|
||||
|
||||
my($name) = $path->basename =~ /^(.*)\.pc$/;
|
||||
|
||||
my $self = {
|
||||
package => $name,
|
||||
vars => { pcfiledir => $path->parent->stringify },
|
||||
keywords => {},
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
$self->read($path);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub read {
|
||||
my $self = shift;
|
||||
my ($path) = @_;
|
||||
|
||||
open my $fh, '<', $path
|
||||
or croak "Cannot open .pc file $path: $!";
|
||||
|
||||
while (my $line = <$fh>) {
|
||||
if ($line =~ /^([^=:]+?)=([^\n\r]*)/) {
|
||||
$self->{vars}{$1} = $2;
|
||||
} elsif ($line =~ /^([^=:]+?):\s*([^\n\r]*)/) {
|
||||
$self->{keywords}{$1} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# getter/setter for vars
|
||||
sub var {
|
||||
my $self = shift;
|
||||
my ($var, $newval) = @_;
|
||||
if (defined $newval) {
|
||||
$self->{vars}{$var} = $newval;
|
||||
}
|
||||
return $self->{vars}{$var};
|
||||
}
|
||||
|
||||
# abstract keywords and other vars in terms of "pure" vars
|
||||
sub make_abstract {
|
||||
my $self = shift;
|
||||
die "make_abstract needs a key (and possibly a value)" unless @_;
|
||||
my ($var, $value) = @_;
|
||||
|
||||
$value = defined $value ? $value : $self->{vars}{$var};
|
||||
|
||||
# convert other vars
|
||||
foreach my $key (keys %{ $self->{vars} }) {
|
||||
next if $key eq $var; # don't overwrite the current var
|
||||
$self->{vars}{$key} =~ s/\Q$value\E/\$\{$var\}/g;
|
||||
}
|
||||
|
||||
# convert keywords
|
||||
foreach my $key (keys %{ $self->{keywords} }) {
|
||||
$self->{keywords}{$key} =~ s/\Q$value\E/\$\{$var\}/g;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub _interpolate_vars {
|
||||
my $self = shift;
|
||||
my ($string, $override) = @_;
|
||||
|
||||
$override ||= {};
|
||||
|
||||
foreach my $key (keys %$override) {
|
||||
carp "Overriden pkg-config variable $key, contains no data"
|
||||
unless $override->{$key};
|
||||
}
|
||||
|
||||
if (defined $string) {
|
||||
1 while $string =~ s/\$\{(.*?)\}/$override->{$1} || $self->{vars}{$1}/e;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
sub keyword {
|
||||
my $self = shift;
|
||||
my ($keyword, $override) = @_;
|
||||
|
||||
{
|
||||
no warnings 'uninitialized';
|
||||
croak "overrides passed to 'keyword' must be a hashref"
|
||||
if defined $override and ref $override ne 'HASH';
|
||||
}
|
||||
|
||||
return $self->_interpolate_vars( $self->{keywords}{$keyword}, $override );
|
||||
}
|
||||
|
||||
my $pkg_config_command;
|
||||
|
||||
sub pkg_config_command {
|
||||
unless (defined $pkg_config_command) {
|
||||
capture_stderr {
|
||||
|
||||
# For now we prefer PkgConfig.pm over pkg-config on
|
||||
# Solaris 64 bit Perls. We may need to do this on
|
||||
# other platforms, in which case this logic should
|
||||
# be abstracted so that it can be shared here and
|
||||
# in Build.PL
|
||||
|
||||
if (`pkg-config --version` && $? == 0 && !($^O eq 'solaris' && $Config{ptrsize} == 8)) {
|
||||
$pkg_config_command = 'pkg-config';
|
||||
} else {
|
||||
require PkgConfig;
|
||||
$pkg_config_command = "$^X $INC{'PkgConfig.pm'}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pkg_config_command;
|
||||
}
|
||||
|
||||
sub TO_JSON
|
||||
{
|
||||
my($self) = @_;
|
||||
my %hash = %$self;
|
||||
$hash{'__CLASS__'} = ref($self);
|
||||
\%hash;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Alien::Base::PkgConfig - Private legacy pkg-config class for Alien::Base
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.38
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is used internally by L<Alien::Base> and L<Alien::Base::ModuleBuild>
|
||||
to store information from pkg-config about installed Aliens. It is not used
|
||||
internally by the newer L<alienfile> and L<Alien::Build>. It should never
|
||||
be used externally, should not be used for code new inside of C<Alien-Build>.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
=over
|
||||
|
||||
=item L<Alien::Base>
|
||||
|
||||
=item L<alienfile>
|
||||
|
||||
=item L<Alien::Build>
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
|
||||
|
||||
Contributors:
|
||||
|
||||
Diab Jerius (DJERIUS)
|
||||
|
||||
Roy Storey (KIWIROY)
|
||||
|
||||
Ilya Pavlov
|
||||
|
||||
David Mertens (run4flat)
|
||||
|
||||
Mark Nunberg (mordy, mnunberg)
|
||||
|
||||
Christian Walde (Mithaldu)
|
||||
|
||||
Brian Wightman (MidLifeXis)
|
||||
|
||||
Zaki Mughal (zmughal)
|
||||
|
||||
mohawk (mohawk2, ETJ)
|
||||
|
||||
Vikas N Kumar (vikasnkumar)
|
||||
|
||||
Flavio Poletti (polettix)
|
||||
|
||||
Salvador Fandiño (salva)
|
||||
|
||||
Gianni Ceccarelli (dakkar)
|
||||
|
||||
Pavel Shaydo (zwon, trinitum)
|
||||
|
||||
Kang-min Liu (劉康民, gugod)
|
||||
|
||||
Nicholas Shipp (nshp)
|
||||
|
||||
Juan Julián Merelo Guervós (JJ)
|
||||
|
||||
Joel Berger (JBERGER)
|
||||
|
||||
Petr Pisar (ppisar)
|
||||
|
||||
Lance Wicks (LANCEW)
|
||||
|
||||
Ahmad Fatoum (a3f, ATHREEF)
|
||||
|
||||
José Joaquín Atria (JJATRIA)
|
||||
|
||||
Duke Leto (LETO)
|
||||
|
||||
Shoichi Kaji (SKAJI)
|
||||
|
||||
Shawn Laffan (SLAFFAN)
|
||||
|
||||
Paul Evans (leonerd, PEVANS)
|
||||
|
||||
Håkon Hægland (hakonhagland, HAKONH)
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2011-2020 by Graham Ollis.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
571
database/perl/vendor/lib/Alien/Base/Wrapper.pm
vendored
Normal file
571
database/perl/vendor/lib/Alien/Base/Wrapper.pm
vendored
Normal file
@@ -0,0 +1,571 @@
|
||||
package Alien::Base::Wrapper;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use 5.006;
|
||||
use Config;
|
||||
use Text::ParseWords qw( shellwords );
|
||||
|
||||
# NOTE: Although this module is now distributed with Alien-Build,
|
||||
# it should have NO non-perl-core dependencies for all Perls
|
||||
# 5.6.0-5.30.1 (as of this writing, and any Perl more recent).
|
||||
# You should be able to extract this module from the rest of
|
||||
# Alien-Build and use it by itself. (There is a dzil plugin
|
||||
# for this [AlienBase::Wrapper::Bundle]
|
||||
|
||||
# ABSTRACT: Compiler and linker wrapper for Alien
|
||||
our $VERSION = '2.38'; # VERSION
|
||||
|
||||
|
||||
sub _join
|
||||
{
|
||||
join ' ', map { s/(\s)/\\$1/g; $_ } map { "$_" } @_; ## no critic (ControlStructures::ProhibitMutatingListFunctions)
|
||||
}
|
||||
|
||||
sub new
|
||||
{
|
||||
my($class, @aliens) = @_;
|
||||
|
||||
my $export = 1;
|
||||
my $writemakefile = 0;
|
||||
|
||||
my @cflags_I;
|
||||
my @cflags_other;
|
||||
my @ldflags_L;
|
||||
my @ldflags_l;
|
||||
my @ldflags_other;
|
||||
my %requires = (
|
||||
'ExtUtils::MakeMaker' => '6.52',
|
||||
'Alien::Base::Wrapper' => '1.97',
|
||||
);
|
||||
|
||||
foreach my $alien (@aliens)
|
||||
{
|
||||
if($alien eq '!export')
|
||||
{
|
||||
$export = 0;
|
||||
next;
|
||||
}
|
||||
if($alien eq 'WriteMakefile')
|
||||
{
|
||||
$writemakefile = 1;
|
||||
next;
|
||||
}
|
||||
my $version = 0;
|
||||
if($alien =~ s/=(.*)$//)
|
||||
{
|
||||
$version = $1;
|
||||
}
|
||||
$alien = "Alien::$alien" unless $alien =~ /::/;
|
||||
$requires{$alien} = $version;
|
||||
my $alien_pm = $alien . '.pm';
|
||||
$alien_pm =~ s/::/\//g;
|
||||
require $alien_pm unless eval { $alien->can('cflags') } && eval { $alien->can('libs') };
|
||||
my $cflags;
|
||||
my $libs;
|
||||
if($alien->install_type eq 'share' && $alien->can('cflags_static'))
|
||||
{
|
||||
$cflags = $alien->cflags_static;
|
||||
$libs = $alien->libs_static;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cflags = $alien->cflags;
|
||||
$libs = $alien->libs;
|
||||
}
|
||||
|
||||
push @cflags_I, grep /^-I/, shellwords $cflags;
|
||||
push @cflags_other, grep !/^-I/, shellwords $cflags;
|
||||
|
||||
push @ldflags_L, grep /^-L/, shellwords $libs;
|
||||
push @ldflags_l, grep /^-l/, shellwords $libs;
|
||||
push @ldflags_other, grep !/^-[Ll]/, shellwords $libs;
|
||||
}
|
||||
|
||||
my @cflags_define = grep /^-D/, @cflags_other;
|
||||
my @cflags_other2 = grep !/^-D/, @cflags_other;
|
||||
|
||||
my @mm;
|
||||
|
||||
push @mm, INC => _join @cflags_I if @cflags_I;
|
||||
push @mm, CCFLAGS => _join(@cflags_other2) . " $Config{ccflags}" if @cflags_other2;
|
||||
push @mm, DEFINE => _join(@cflags_define) if @cflags_define;
|
||||
|
||||
# TODO: handle spaces in -L paths
|
||||
push @mm, LIBS => ["@ldflags_L @ldflags_l"];
|
||||
my @ldflags = (@ldflags_L, @ldflags_other);
|
||||
push @mm, LDDLFLAGS => _join(@ldflags) . " $Config{lddlflags}" if @ldflags;
|
||||
push @mm, LDFLAGS => _join(@ldflags) . " $Config{ldflags}" if @ldflags;
|
||||
|
||||
my @mb;
|
||||
|
||||
push @mb, extra_compiler_flags => _join(@cflags_I, @cflags_other);
|
||||
push @mb, extra_linker_flags => _join(@ldflags_l);
|
||||
|
||||
if(@ldflags)
|
||||
{
|
||||
push @mb, config => {
|
||||
lddlflags => _join(@ldflags) . " $Config{lddlflags}",
|
||||
ldflags => _join(@ldflags) . " $Config{ldflags}",
|
||||
},
|
||||
}
|
||||
|
||||
bless {
|
||||
cflags_I => \@cflags_I,
|
||||
cflags_other => \@cflags_other,
|
||||
ldflags_L => \@ldflags_L,
|
||||
ldflags_l => \@ldflags_l,
|
||||
ldflags_other => \@ldflags_other,
|
||||
mm => \@mm,
|
||||
mb => \@mb,
|
||||
_export => $export,
|
||||
_writemakefile => $writemakefile,
|
||||
requires => \%requires,
|
||||
}, $class;
|
||||
}
|
||||
|
||||
my $default_abw = __PACKAGE__->new;
|
||||
|
||||
# for testing only
|
||||
sub _reset { __PACKAGE__->new }
|
||||
|
||||
|
||||
sub _myexec
|
||||
{
|
||||
my @command = @_;
|
||||
if($^O eq 'MSWin32')
|
||||
{
|
||||
# To handle weird quoting on MSWin32
|
||||
# this logic needs to be improved.
|
||||
my $command = "@command";
|
||||
$command =~ s{"}{\\"}g;
|
||||
system $command;
|
||||
|
||||
if($? == -1 )
|
||||
{
|
||||
die "failed to execute: $!\n";
|
||||
}
|
||||
elsif($? & 127)
|
||||
{
|
||||
die "child died with signal @{[ $? & 128 ]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
exit($? >> 8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exec @command;
|
||||
}
|
||||
}
|
||||
|
||||
sub cc
|
||||
{
|
||||
my @command = (
|
||||
shellwords($Config{cc}),
|
||||
@{ $default_abw->{cflags_I} },
|
||||
@{ $default_abw->{cflags_other} },
|
||||
@ARGV,
|
||||
);
|
||||
print "@command\n" unless $ENV{ALIEN_BASE_WRAPPER_QUIET};
|
||||
_myexec @command;
|
||||
}
|
||||
|
||||
|
||||
sub ld
|
||||
{
|
||||
my @command = (
|
||||
shellwords($Config{ld}),
|
||||
@{ $default_abw->{ldflags_L} },
|
||||
@{ $default_abw->{ldflags_other} },
|
||||
@ARGV,
|
||||
@{ $default_abw->{ldflags_l} },
|
||||
);
|
||||
print "@command\n" unless $ENV{ALIEN_BASE_WRAPPER_QUIET};
|
||||
_myexec @command;
|
||||
}
|
||||
|
||||
|
||||
sub mm_args
|
||||
{
|
||||
my $self = ref $_[0] ? shift : $default_abw;
|
||||
@{ $self->{mm} };
|
||||
}
|
||||
|
||||
|
||||
sub mm_args2
|
||||
{
|
||||
my $self = shift;
|
||||
$self = $default_abw unless ref $self;
|
||||
my %args = @_;
|
||||
|
||||
my @mm = @{ $self->{mm} };
|
||||
|
||||
while(@mm)
|
||||
{
|
||||
my $key = shift @mm;
|
||||
my $value = shift @mm;
|
||||
if(defined $args{$key})
|
||||
{
|
||||
if($args{$key} eq 'LIBS')
|
||||
{
|
||||
require Carp;
|
||||
# Todo: support this maybe?
|
||||
Carp::croak("please do not specify your own LIBS key with mm_args2");
|
||||
}
|
||||
else
|
||||
{
|
||||
$args{$key} = join ' ', $value, $args{$key};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$args{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $module (keys %{ $self->{requires} })
|
||||
{
|
||||
$args{CONFIGURE_REQUIRES}->{$module} = $self->{requires}->{$module};
|
||||
}
|
||||
|
||||
%args;
|
||||
}
|
||||
|
||||
|
||||
sub mb_args
|
||||
{
|
||||
my $self = ref $_[0] ? shift : $default_abw;
|
||||
@{ $self->{mb} };
|
||||
}
|
||||
|
||||
sub import
|
||||
{
|
||||
shift;
|
||||
my $abw = $default_abw = __PACKAGE__->new(@_);
|
||||
if($abw->_export)
|
||||
{
|
||||
my $caller = caller;
|
||||
no strict 'refs';
|
||||
*{"${caller}::cc"} = \&cc;
|
||||
*{"${caller}::ld"} = \&ld;
|
||||
}
|
||||
if($abw->_writemakefile)
|
||||
{
|
||||
my $caller = caller;
|
||||
no strict 'refs';
|
||||
*{"${caller}::WriteMakefile"} = \&WriteMakefile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub WriteMakefile
|
||||
{
|
||||
my %args = @_;
|
||||
|
||||
require ExtUtils::MakeMaker;
|
||||
ExtUtils::MakeMaker->VERSION('6.52');
|
||||
|
||||
my @aliens;
|
||||
|
||||
if(my $reqs = delete $args{alien_requires})
|
||||
{
|
||||
if(ref $reqs eq 'HASH')
|
||||
{
|
||||
@aliens = map {
|
||||
my $module = $_;
|
||||
my $version = $reqs->{$module};
|
||||
$version ? "$module=$version" : "$module";
|
||||
} sort keys %$reqs;
|
||||
}
|
||||
elsif(ref $reqs eq 'ARRAY')
|
||||
{
|
||||
@aliens = @$reqs;
|
||||
}
|
||||
else
|
||||
{
|
||||
require Carp;
|
||||
Carp::croak("aliens_require must be either a hash or array reference");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
require Carp;
|
||||
Carp::croak("You are using Alien::Base::Wrapper::WriteMakefile, but didn't specify any alien requirements");
|
||||
}
|
||||
|
||||
ExtUtils::MakeMaker::WriteMakefile(
|
||||
Alien::Base::Wrapper->new(@aliens)->mm_args2(%args),
|
||||
);
|
||||
}
|
||||
|
||||
sub _export { shift->{_export} }
|
||||
sub _writemakefile { shift->{_writemakefile} }
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Alien::Base::Wrapper - Compiler and linker wrapper for Alien
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.38
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
From the command line:
|
||||
|
||||
% perl -MAlien::Base::Wrapper=Alien::Foo,Alien::Bar -e cc -- -o foo.o -c foo.c
|
||||
% perl -MAlien::Base::Wrapper=Alien::Foo,Alien::Bar -e ld -- -o foo foo.o
|
||||
|
||||
From Makefile.PL (static):
|
||||
|
||||
use ExtUtils::MakeMaker;
|
||||
use Alien::Base::Wrapper ();
|
||||
|
||||
WriteMakefile(
|
||||
Alien::Base::Wrapper->new( 'Alien::Foo', 'Alien::Bar')->mm_args2(
|
||||
'NAME' => 'Foo::XS',
|
||||
'VERSION_FROM' => 'lib/Foo/XS.pm',
|
||||
),
|
||||
);
|
||||
|
||||
From Makefile.PL (static with wrapper)
|
||||
|
||||
use Alien::Base::Wrapper qw( WriteMakefile);
|
||||
|
||||
WriteMakefile(
|
||||
'NAME' => 'Foo::XS',
|
||||
'VERSION_FROM' => 'lib/Foo/XS.pm',
|
||||
'alien_requires' => {
|
||||
'Alien::Foo' => 0,
|
||||
'Alien::Bar' => 0,
|
||||
},
|
||||
);
|
||||
|
||||
From Makefile.PL (dynamic):
|
||||
|
||||
use Devel::CheckLib qw( check_lib );
|
||||
use ExtUtils::MakeMaker 6.52;
|
||||
|
||||
my @mm_args;
|
||||
my @libs;
|
||||
|
||||
if(check_lib( lib => [ 'foo' ] )
|
||||
{
|
||||
push @mm_args, LIBS => [ '-lfoo' ];
|
||||
}
|
||||
else
|
||||
{
|
||||
push @mm_args,
|
||||
CC => '$(FULLPERL) -MAlien::Base::Wrapper=Alien::Foo -e cc --',
|
||||
LD => '$(FULLPERL) -MAlien::Base::Wrapper=Alien::Foo -e ld --',
|
||||
BUILD_REQUIRES => {
|
||||
'Alien::Foo' => 0,
|
||||
'Alien::Base::Wrapper' => 0,
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
WriteMakefile(
|
||||
'NAME' => 'Foo::XS',
|
||||
'VERSION_FROM' => 'lib/Foo/XS.pm',
|
||||
'CONFIGURE_REQUIRES => {
|
||||
'ExtUtils::MakeMaker' => 6.52,
|
||||
},
|
||||
@mm_args,
|
||||
);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module acts as a wrapper around one or more L<Alien> modules. It is designed to work
|
||||
with L<Alien::Base> based aliens, but it should work with any L<Alien> which uses the same
|
||||
essential API.
|
||||
|
||||
In the first example (from the command line), this class acts as a wrapper around the
|
||||
compiler and linker that Perl is configured to use. It takes the normal compiler and
|
||||
linker flags and adds the flags provided by the Aliens specified, and then executes the
|
||||
command. It will print the command to the console so that you can see exactly what is
|
||||
happening.
|
||||
|
||||
In the second example (from Makefile.PL non-dynamic), this class is used to generate the
|
||||
appropriate L<ExtUtils::MakeMaker> (EUMM) arguments needed to C<WriteMakefile>.
|
||||
|
||||
In the third example (from Makefile.PL dynamic), we do a quick check to see if the simple
|
||||
linker flag C<-lfoo> will work, if so we use that. If not, we use a wrapper around the
|
||||
compiler and linker that will use the alien flags that are known at build time. The
|
||||
problem that this form attempts to solve is that compiler and linker flags typically
|
||||
need to be determined at I<configure> time, when a distribution is installed, meaning
|
||||
if you are going to use an L<Alien> module then it needs to be a configure prerequisite,
|
||||
even if the library is already installed and easily detected on the operating system.
|
||||
|
||||
The author of this module believes that the third (from Makefile.PL dynamic) form is
|
||||
somewhat unnecessary. L<Alien> modules based on L<Alien::Base> have a few prerequisites,
|
||||
but they are well maintained and reliable, so while there is a small cost in terms of extra
|
||||
dependencies, the overall reliability thanks to reduced overall complexity.
|
||||
|
||||
=head1 CONSTRUCTOR
|
||||
|
||||
=head2 new
|
||||
|
||||
my $abw = Alien::Base::Wrapper->new(@aliens);
|
||||
|
||||
Instead of passing the aliens you want to use into this modules import you can create
|
||||
a non-global instance of C<Alien::Base::Wrapper> using the OO interface.
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 cc
|
||||
|
||||
% perl -MAlien::Base::Wrapper=Alien::Foo -e cc -- cflags
|
||||
|
||||
Invoke the C compiler with the appropriate flags from C<Alien::Foo> and what
|
||||
is provided on the command line.
|
||||
|
||||
=head2 ld
|
||||
|
||||
% perl -MAlien::Base::Wrapper=Alien::Foo -e ld -- ldflags
|
||||
|
||||
Invoke the linker with the appropriate flags from C<Alien::Foo> and what
|
||||
is provided on the command line.
|
||||
|
||||
=head2 mm_args
|
||||
|
||||
my %args = $abw->mm_args;
|
||||
my %args = Alien::Base::Wrapper->mm_args;
|
||||
|
||||
Returns arguments that you can pass into C<WriteMakefile> to compile/link against
|
||||
the specified Aliens. Note that this does not set C<CONFIGURE_REQUIRES>. You
|
||||
probably want to use C<mm_args2> below instead for that reason.
|
||||
|
||||
=head2 mm_args2
|
||||
|
||||
my %args = $abw->mm_args2(%args);
|
||||
my %args = Alien::Base::Wrapper->mm_args2(%args);
|
||||
|
||||
Returns arguments that you can pass into C<WriteMakefile> to compile/link against. It works
|
||||
a little differently from C<mm_args> above in that you can pass in arguments. It also adds
|
||||
the appropriate C<CONFIGURE_REQUIRES> for you so you do not have to do that explicitly.
|
||||
|
||||
=head2 mb_args
|
||||
|
||||
my %args = $abw->mb_args;
|
||||
my %args = Alien::Base::Wrapper->mb_args;
|
||||
|
||||
Returns arguments that you can pass into the constructor to L<Module::Build>.
|
||||
|
||||
=head2 WriteMakefile
|
||||
|
||||
use Alien::Base::Wrapper qw( WriteMakefile );
|
||||
WriteMakefile(%args, alien_requires => %aliens);
|
||||
WriteMakefile(%args, alien_requires => @aliens);
|
||||
|
||||
This is a thin wrapper around C<WriteMakefile> from L<ExtUtils::MakeMaker>, which adds the
|
||||
given aliens to the configure requirements and sets the appropriate compiler and linker
|
||||
flags.
|
||||
|
||||
If the aliens are specified as a hash reference, then the keys are the module names and the
|
||||
values are the versions. For a list it is just the name of the aliens.
|
||||
|
||||
For the list form you can specify a version by appending C<=version> to the name of the
|
||||
Aliens, that is:
|
||||
|
||||
WriteMakefile(
|
||||
alien_requires => [ 'Alien::libfoo=1.23', 'Alien::libbar=4.56' ],
|
||||
);
|
||||
|
||||
The list form is recommended if the ordering of the aliens matter. The aliens are sorted in
|
||||
the hash form to make it consistent, but it may not be the order that you want.
|
||||
|
||||
=head1 ENVIRONMENT
|
||||
|
||||
Alien::Base::Wrapper responds to these environment variables:
|
||||
|
||||
=over 4
|
||||
|
||||
=item ALIEN_BASE_WRAPPER_QUIET
|
||||
|
||||
If set to true, do not print the command before executing
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<Alien::Base>, L<Alien::Base>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
|
||||
|
||||
Contributors:
|
||||
|
||||
Diab Jerius (DJERIUS)
|
||||
|
||||
Roy Storey (KIWIROY)
|
||||
|
||||
Ilya Pavlov
|
||||
|
||||
David Mertens (run4flat)
|
||||
|
||||
Mark Nunberg (mordy, mnunberg)
|
||||
|
||||
Christian Walde (Mithaldu)
|
||||
|
||||
Brian Wightman (MidLifeXis)
|
||||
|
||||
Zaki Mughal (zmughal)
|
||||
|
||||
mohawk (mohawk2, ETJ)
|
||||
|
||||
Vikas N Kumar (vikasnkumar)
|
||||
|
||||
Flavio Poletti (polettix)
|
||||
|
||||
Salvador Fandiño (salva)
|
||||
|
||||
Gianni Ceccarelli (dakkar)
|
||||
|
||||
Pavel Shaydo (zwon, trinitum)
|
||||
|
||||
Kang-min Liu (劉康民, gugod)
|
||||
|
||||
Nicholas Shipp (nshp)
|
||||
|
||||
Juan Julián Merelo Guervós (JJ)
|
||||
|
||||
Joel Berger (JBERGER)
|
||||
|
||||
Petr Pisar (ppisar)
|
||||
|
||||
Lance Wicks (LANCEW)
|
||||
|
||||
Ahmad Fatoum (a3f, ATHREEF)
|
||||
|
||||
José Joaquín Atria (JJATRIA)
|
||||
|
||||
Duke Leto (LETO)
|
||||
|
||||
Shoichi Kaji (SKAJI)
|
||||
|
||||
Shawn Laffan (SLAFFAN)
|
||||
|
||||
Paul Evans (leonerd, PEVANS)
|
||||
|
||||
Håkon Hægland (hakonhagland, HAKONH)
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2011-2020 by Graham Ollis.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user