tagged release 0.6.4
[parrot.git] / config / auto / inline.pm
blobc9060b681625c5d67029b3d95be5f42d8aaa5a86
1 # Copyright (C) 2001-2003, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 config/auto/inline.pm - Inline Compiler Support
8 =head1 DESCRIPTION
10 Determines whether the compiler supports C<inline>.
12 =cut
14 package auto::inline;
16 use strict;
17 use warnings;
19 use base qw(Parrot::Configure::Step);
21 use Parrot::Configure::Utils ':auto';
24 sub _init {
25 my $self = shift;
26 my %data;
27 $data{description} = q{Determining if your compiler supports inline};
28 $data{result} = q{};
29 return \%data;
32 sub runstep {
33 my ( $self, $conf ) = @_;
35 my $inline = $conf->options->get(qw(inline));
36 if ( defined $inline ) {
37 $conf->data->set( inline => $inline );
38 return 1;
41 my $test = $self->_first_probe_for_inline($conf);
42 unless ($test) {
43 $test = $self->_second_probe_for_inline($conf, $test);
46 $self->_evaluate_inline($conf, $test);
47 return 1;
50 sub _first_probe_for_inline {
51 my $self = shift;
52 my $conf = shift;
53 my $test;
54 $conf->cc_gen('config/auto/inline/test_1.in');
55 eval { $conf->cc_build(); };
56 if ( !$@ ) {
57 $test = $conf->cc_run();
58 chomp $test if $test;
60 $conf->cc_clean();
61 return $test;
64 sub _second_probe_for_inline {
65 my $self = shift;
66 my $conf = shift;
67 my $test = shift;
68 if ( !$test ) {
69 $conf->cc_gen('config/auto/inline/test_2.in');
70 eval { $conf->cc_build(); };
71 if ( !$@ ) {
72 $test = $conf->cc_run();
73 chomp $test if $test;
75 $conf->cc_clean();
77 return $test;
80 sub _evaluate_inline {
81 my ($self, $conf, $test) = @_;
82 my $verbose = $conf->options->get(qw(verbose));
83 if ($test) {
84 print " ($test) " if $verbose;
85 $self->set_result('yes');
87 else {
88 print " no " if $verbose;
89 $self->set_result('no');
90 $test = '';
92 $conf->data->set( inline => $test );
93 return 1;
98 # Local Variables:
99 # mode: cperl
100 # cperl-indent-level: 4
101 # fill-column: 100
102 # End:
103 # vim: expandtab shiftwidth=4: