File Coverage

File:config/auto/pcre.pm
Coverage:98.2%

linestmtbrancondsubcode
1# Copyright (C) 2008, Parrot Foundation.
2# $Id: pcre.pm 47318 2010-06-03 01:36:45Z jkeenan $
3
4 - 14
=head1 NAME

config/auto/pcre.pm - Probe for pcre library

=head1 DESCRIPTION

Determines whether the platform supports pcre library.

This library is used via NCI mechanism.

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