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