| File: | config/auto/gdbm.pm |
| Coverage: | 96.7% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2001-2005, Parrot Foundation. | ||||
| 2 | # $Id: gdbm.pm 42341 2009-11-07 23:48:27Z jkeenan $ | ||||
| 3 | |||||
| 4 - 17 | =head1 NAME config/auto/gdbm.pm - Test for GNU dbm (gdbm) library =head1 DESCRIPTION Determines whether the platform supports gdbm. This is needed for the dynamic GDBMHash PMC. From L<http://www.gnu.org/software/gdbm/>: "GNU dbm is a set of database routines that use extensible hashing. It works similar to the standard Unix dbm routines." =cut | ||||
| 18 | |||||
| 19 | package auto::gdbm; | ||||
| 20 | |||||
| 21 | 81 81 81 | use strict; | |||
| 22 | 81 81 81 | use warnings; | |||
| 23 | |||||
| 24 | 81 81 81 | use base qw(Parrot::Configure::Step); | |||
| 25 | |||||
| 26 | 81 81 81 | use Parrot::Configure::Utils ':auto'; | |||
| 27 | |||||
| 28 | |||||
| 29 | sub _init { | ||||
| 30 | 83 | my $self = shift; | |||
| 31 | 83 | my %data; | |||
| 32 | 83 | $data{description} = q{Does your platform support gdbm}; | |||
| 33 | 83 | $data{result} = q{}; | |||
| 34 | 83 | return \%data; | |||
| 35 | } | ||||
| 36 | |||||
| 37 | sub runstep { | ||||
| 38 | 81 | my ( $self, $conf ) = @_; | |||
| 39 | |||||
| 40 | 81 | my ( $verbose, $without ) = $conf->options->get( | |||
| 41 | qw| | ||||
| 42 | verbose | ||||
| 43 | without-gdbm | ||||
| 44 | | | ||||
| 45 | ); | ||||
| 46 | |||||
| 47 | 81 | if ($without) { | |||
| 48 | 1 | $conf->data->set( has_gdbm => 0 ); | |||
| 49 | 1 | $self->set_result('no'); | |||
| 50 | 1 | return 1; | |||
| 51 | } | ||||
| 52 | |||||
| 53 | 80 | my $osname = $conf->data->get('osname'); | |||
| 54 | |||||
| 55 | 80 | my $extra_libs = $self->_select_lib( { | |||
| 56 | conf => $conf, | ||||
| 57 | osname => $osname, | ||||
| 58 | cc => $conf->data->get('cc'), | ||||
| 59 | win32_gcc => '-llibgdbm', | ||||
| 60 | win32_nongcc => 'gdbm.lib', | ||||
| 61 | default => '-lgdbm', | ||||
| 62 | } ); | ||||
| 63 | |||||
| 64 | 80 | $conf->cc_gen('config/auto/gdbm/gdbm_c.in'); | |||
| 65 | 80 80 | eval { $conf->cc_build( q{}, $extra_libs ); }; | |||
| 66 | 80 | my $has_gdbm = 0; | |||
| 67 | 80 | if ( !$@ ) { | |||
| 68 | 80 | my $test = $conf->cc_run(); | |||
| 69 | 80 | unlink "gdbm_test_db"; | |||
| 70 | 80 | $has_gdbm = $self->_evaluate_cc_run($test, $has_gdbm, $verbose); | |||
| 71 | } | ||||
| 72 | 80 | $conf->data->set( has_gdbm => $has_gdbm ); # for gdbmhash.t and dynpmc.in | |||
| 73 | 80 | $self->set_result($has_gdbm ? 'yes' : 'no'); | |||
| 74 | |||||
| 75 | 80 | return 1; | |||
| 76 | } | ||||
| 77 | |||||
| 78 | sub _evaluate_cc_run { | ||||
| 79 | 83 | my $self = shift; | |||
| 80 | 83 | my ($test, $has_gdbm, $verbose) = @_; | |||
| 81 | 83 | if ( $test eq "gdbm is working.\n" ) { | |||
| 82 | 82 | $has_gdbm = 1; | |||
| 83 | 82 | print " (yes) " if $verbose; | |||
| 84 | 82 | $self->set_result('yes'); | |||
| 85 | } | ||||
| 86 | 83 | return $has_gdbm; | |||
| 87 | } | ||||
| 88 | |||||
| 89 | 1; | ||||
| 90 | |||||
| 91 | # Local Variables: | ||||
| 92 | # mode: cperl | ||||
| 93 | # cperl-indent-level: 4 | ||||
| 94 | # fill-column: 100 | ||||
| 95 | # End: | ||||
| 96 | # vim: expandtab shiftwidth=4: | ||||