tagged release 0.6.4
[parrot.git] / config / auto / snprintf.pm
blobf56edf076b52216456d570f32ec4feca6264e1bb
1 # Copyright (C) 2001-2003, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 config/auto/snprintf.pm - Test for snprintf
8 =head1 DESCRIPTION
10 Tests if snprintf is present and if it's C99 compliant.
12 =cut
14 package auto::snprintf;
16 use strict;
17 use warnings;
19 use base qw(Parrot::Configure::Step);
21 sub _init {
22 my $self = shift;
23 my %data;
24 $data{description} = q{Testing snprintf};
25 $data{result} = q{};
26 return \%data;
29 sub runstep {
30 my ( $self, $conf ) = @_;
32 my $res = _probe_for_snprintf($conf);
34 $self->_evaluate_snprintf($conf, $res);
36 return 1;
39 sub _probe_for_snprintf {
40 my $conf = shift;
41 $conf->cc_gen('config/auto/snprintf/test.in');
42 $conf->cc_build();
43 my $res = $conf->cc_run() or die "Can't run the snprintf testing program: $!";
44 $conf->cc_clean();
45 return $res;
48 sub _evaluate_snprintf {
49 my ($self, $conf, $res) = @_;
50 if ( $res =~ /snprintf/ ) {
51 $conf->data->set( HAS_SNPRINTF => 1 );
53 if ( $res =~ /^C99 snprintf/ ) {
54 $conf->data->set( HAS_C99_SNPRINTF => 1 );
56 elsif ( $res =~ /^old snprintf/ ) {
57 $conf->data->set( HAS_OLD_SNPRINTF => 1 );
59 print " ($res) " if $conf->options->get('verbose');
60 return 1;
65 # Local Variables:
66 # mode: cperl
67 # cperl-indent-level: 4
68 # fill-column: 100
69 # End:
70 # vim: expandtab shiftwidth=4: