File Coverage

File:config/auto/crypto.pm
Coverage:96.7%

linestmtbrancondsubcode
1# Copyright (C) 2008, Parrot Foundation.
2# $Id: crypto.pm 42341 2009-11-07 23:48:27Z jkeenan $
3
4 - 14
=head1 NAME

config/auto/crypto.pm - Test for crypto library (libssl)

=head1 DESCRIPTION

This library is linked to a dynamic PMC.

See L<http://www.openssl.org>

=cut
15
16package auto::crypto;
17
18
81
81
81
use strict;
19
81
81
81
use warnings;
20
21
81
81
81
use base qw(Parrot::Configure::Step);
22
23
81
81
81
use Parrot::Configure::Utils ':auto';
24
25
26sub _init {
27
83
    my $self = shift;
28
83
    my %data;
29
83
    $data{description} = q{Does your platform support crypto};
30
83
    $data{result} = q{};
31
83
    return \%data;
32}
33
34sub runstep {
35
81
    my ( $self, $conf ) = @_;
36
37
81
    my ( $verbose, $without ) = $conf->options->get(
38        qw|
39            verbose
40            without-crypto
41        |
42    );
43
44
81
    if ($without) {
45
1
        $conf->data->set( has_crypto => 0 );
46
1
        $self->set_result('no');
47
1
        return 1;
48    }
49
50
80
    my $osname = $conf->data->get('osname');
51
52
80
    my $extra_libs = $self->_select_lib( {
53        conf => $conf,
54        osname => $osname,
55        cc => $conf->data->get('cc'),
56        win32_nongcc => 'libcrypto.lib',
57        default => '-lcrypto',
58    } );
59
60
80
    $conf->cc_gen('config/auto/crypto/crypto_c.in');
61
80
80
    eval { $conf->cc_build( q{}, $extra_libs); };
62
80
    my $has_crypto = 0;
63
80
    if ( !$@ ) {
64
80
        my $test = $conf->cc_run();
65
80
        $has_crypto = $self->_evaluate_cc_run($conf, $test, $has_crypto, $verbose);
66    }
67
80
    $conf->data->set( has_crypto => $has_crypto ); # for dynpmc.in & digest.t
68
80
    $self->set_result($has_crypto ? 'yes' : 'no');
69
70
80
    return 1;
71}
72
73sub _evaluate_cc_run {
74
83
    my $self = shift;
75
83
    my ($conf, $test, $has_crypto, $verbose) = @_;
76
83
    if ( $test =~ m/^OpenSSL (\d\.\d\.\d\w?)/ ) {
77
82
        my $version = $1;
78
82
        $has_crypto = 1;
79
82
        $conf->data->set( openssl_version => $version );
80
82
        print " (yes) " if $verbose;
81
82
        $self->set_result("yes, $version");
82    }
83
83
    return $has_crypto;
84}
85
861;
87
88# Local Variables:
89# mode: cperl
90# cperl-indent-level: 4
91# fill-column: 100
92# End:
93# vim: expandtab shiftwidth=4: