Created
May 18, 2010 23:35
-
-
Save ashgti/405722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2010, Parrot Foundation. | |
# $Id$ | |
=head1 NAME | |
config/auto/libffi.pm - find libffi | |
=head1 DESCRIPTION | |
Discovers libffi, if it exists. | |
=cut | |
package auto::libffi; | |
use strict; | |
use warnings; | |
use base qw(Parrot::Configure::Step); | |
use Parrot::Configure::Utils ':auto'; | |
sub _init { | |
my $self = shift; | |
my %data; | |
$data{description} = q{Is libffi installed}; | |
$data{result} = q{}; | |
return \%data; | |
} | |
sub runstep { | |
my ( $self, $conf ) = @_; | |
my $test = $self->_probe_for_libffi($conf); | |
$self->_evaluate_libffi($conf, $test); | |
return 1; | |
} | |
sub _probe_for_libffi { | |
my ( $self, $conf ) = @_; | |
my %libffi; | |
my $extra_libs = $self->_select_lib( { | |
default => '-lffi', | |
} ); | |
$conf->cc_gen("config/auto/libffi/test_c.in"); | |
eval { $conf->cc_build( q{}, $extra_libs ) }; | |
if ( !$@ ) { | |
%libffi = eval $conf->cc_run() or die "Can't run the test program: $!"; | |
} | |
$conf->cc_clean(); | |
return \%libffi; | |
} | |
sub _evaluate_libffi { | |
my ( $self, $conf, $test ) = @_; | |
if ( defined $test->{libffi} ) { | |
$self->set_result("yes"); | |
$conf->data->set( libffi => $test->{libffi} ); | |
} | |
else { | |
$self->set_result("no"); | |
$conf->data->set( libffi => undef ); | |
} | |
return 1; | |
} | |
1; | |
# Local Variables: | |
# mode: cperl | |
# cperl-indent-level: 4 | |
# fill-column: 100 | |
# End: | |
# vim: expandtab shiftwidth=4: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment