ExtUtils-CChecker
view release on metacpan or search on metacpan
lib/ExtUtils/CChecker.pm view on Meta::CPAN
ref( my $dirs = $args{dirs} ) eq "ARRAY" or croak "Expected 'dirs' as ARRAY ref";
foreach my $d ( @$dirs ) {
ref $d eq "ARRAY" or croak "Expected 'dirs' element as ARRAY ref";
$self->try_compile_run( %args, include_dirs => $d ) or next;
$self->push_include_dirs( @$d );
return 1;
}
return 0;
}
=head2 try_find_libs_for
$success = $cc->try_find_libs_for( %args );
Try to compile, link and execute the given source, when linked against a
given set of extra libraries.
When a usable combination is found, the libraries required are stored in the
object for use in further link operations, or returned by
C<extra_linker_flags>. The method then returns true.
If no usable combination is found, it returns false.
Takes the following arguments:
=over 4
=item source => STRING
Source code to compile
=item libs => ARRAY of STRINGs
Gives a list of sets of libraries. Each set of libraries should be
space-separated.
=item define => STRING
Optional. If specified, then the named symbol will be defined if the program
ran successfully. This will either on the C compiler commandline (by passing
an option C<-DI<SYMBOL>>), or in the C<defines_to> file.
=back
=cut
sub try_find_libs_for
{
my $self = shift;
my %args = @_;
ref( my $libs = $args{libs} ) eq "ARRAY" or croak "Expected 'libs' as ARRAY ref";
foreach my $l ( @$libs ) {
my @extra_linker_flags = map { "-l$_" } split m/\s+/, $l;
$self->try_compile_run( %args, extra_linker_flags => \@extra_linker_flags ) or next;
$self->push_extra_linker_flags( @extra_linker_flags );
return 1;
}
return 0;
}
=head2 find_cflags_for
$cc->find_cflags_for( %args );
=head2 find_include_dirs_for
$cc->find_include_dirs_for( %args );
=head2 find_libs_for
$cc->find_libs_for( %args );
Calls C<try_find_cflags_for>, C<try_find_include_dirs_for> or
C<try_find_libs_for> respectively. If it fails, die with an
C<OS unsupported> message.
Each method takes one extra optional argument:
=over 4
=item diag => STRING
If present, this string will be appended to the failure message if one is
generated. It may provide more useful information to the user on why the OS is
unsupported.
=back
=cut
foreach ( qw( find_cflags_for find_libs_for find_include_dirs_for ) ) {
my $trymethod = "try_$_";
my $code = sub {
my $self = shift;
my %args = @_;
my $diag = delete $args{diag};
$self->$trymethod( %args ) or $self->fail( $diag );
};
no strict 'refs';
*$_ = $code;
}
=head2 extend_module_build
$cc->extend_module_build( $build );
( run in 1.119 second using v1.01-cache-2.11-cpan-71847e10f99 )