tagged release 0.6.4
[parrot.git] / config / auto / backtrace.pm
blob515ac7680e45998fb1f97e6323921142a3121744
1 # Copyright (C) 2001-2007, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 config/auto/backtrace.pm - GNU C Compiler
8 =head1 DESCRIPTION
10 Determines whether libc has the backtrace* functions. The backtrace() and
11 backtrace_symbols() functions exist in GNU libc, and also in OS X versions
12 10.5+.
14 =cut
16 package auto::backtrace;
18 use strict;
19 use warnings;
21 use base qw(Parrot::Configure::Step);
23 use Parrot::Configure::Utils ':auto';
26 sub _init {
27 my $self = shift;
28 my %data;
29 $data{description} = q{Determining whether libc has the backtrace* functions};
30 $data{result} = q{};
31 return \%data;
34 sub runstep {
35 my ( $self, $conf ) = @_;
37 my $anyerror = _probe_for_backtrace($conf);
39 $self->_evaluate_backtrace($conf, $anyerror);
41 return 1;
44 sub _probe_for_backtrace {
45 my $conf = shift;
46 $conf->cc_gen("config/auto/backtrace/test_c.in");
48 # If the program builds (e.g. the linker found backtrace* in libc)
49 # then we have the "backtrace" and "backtrace_symbols" functions. If the
50 # program fails to build for whatever reason we're just going to assume
51 # that the build failure is because these symbols are missing.
53 eval { $conf->cc_build(); };
54 my $anyerror = $@;
55 $conf->cc_clean();
56 return $anyerror;
59 sub _evaluate_backtrace {
60 my ($self, $conf, $anyerror) = @_;
61 if ( $anyerror ) {
62 $self->set_result("no");
64 else {
65 $conf->data->set( backtrace => 1 );
66 $self->set_result("yes");
72 # Local Variables:
73 # mode: cperl
74 # cperl-indent-level: 4
75 # fill-column: 100
76 # End:
77 # vim: expandtab shiftwidth=4: