tagged release 0.7.1
[parrot.git] / config / auto / pcre.pm
blob207f528664a98bbb6eef355f203fb0dd360e1c0e
1 # Copyright (C) 2008, The Perl Foundation.
2 # $Id $
4 =head1 NAME
6 config/auto/pcre.pm - Probe for pcre library
8 =head1 DESCRIPTION
10 Determines whether the platform supports pcre library.
12 =cut
14 package auto::pcre;
16 use strict;
17 use warnings;
18 use File::Spec;
20 use base qw(Parrot::Configure::Step);
22 use Parrot::Configure::Utils ':auto';
24 sub _init {
25 my $self = shift;
26 my %data;
27 $data{description} = q{Does your platform support pcre};
28 $data{result} = q{};
29 return \%data;
32 sub runstep {
33 my ( $self, $conf ) = @_;
35 my ( $verbose, $without ) = $conf->options->get(
36 qw|
37 verbose
38 without-pcre
42 if ($without) {
43 $conf->data->set( has_pcre => 0 );
44 $self->set_result('no');
45 return 1;
48 my $cc = $conf->data->get('cc');
49 my $libs = $conf->data->get('libs');
50 my $linkflags = $conf->data->get('linkflags');
51 my $ccflags = $conf->data->get('ccflags');
53 my $osname = $conf->data->get_p5('OSNAME');
55 $self->_add_to_libs( {
56 conf => $conf,
57 osname => $osname,
58 cc => $cc,
59 win32_nongcc => 'pcre.lib',
60 default => '-lpcre',
61 } );
63 # On OS X check the presence of the pcre headers in the standard
64 # Fink/macports locations.
65 $self->_handle_darwin_for_fink ($conf, $osname, 'pcre.h');
66 $self->_handle_darwin_for_macports($conf, $osname, 'pcre.h');
68 $conf->cc_gen('config/auto/pcre/pcre.in');
69 eval { $conf->cc_build() };
70 my $has_pcre = 0;
71 if ( !$@ ) {
72 my $test = $conf->cc_run();
73 $has_pcre = $self->_evaluate_cc_run($test, $verbose);
75 if (! $has_pcre) {
76 # The Parrot::Configure settings might have changed while class ran
77 $self->_recheck_settings($conf, $libs, $ccflags, $linkflags, $verbose);
79 $conf->data->set( HAS_PCRE => $has_pcre);
81 return 1;
84 sub _evaluate_cc_run {
85 my $self = shift;
86 my ($test, $verbose) = @_;
87 my $has_pcre = 0;
88 if ( $test =~ /pcre (\d+\.\d+)/ ) {
89 my $pcre_version = $1;
90 $has_pcre = 1;
91 print " (yes, $pcre_version) " if $verbose;
92 $self->set_result("yes, $pcre_version");
94 return $has_pcre;
99 # Local Variables:
100 # mode: cperl
101 # cperl-indent-level: 4
102 # fill-column: 100
103 # End:
104 # vim: expandtab shiftwidth=4: