tagged release 0.6.4
[parrot.git] / config / auto / env.pm
blobd1ebf1754c42379ed8cf8d0dae4c5df1fc75927c
1 # Copyright (C) 2001-2003, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 config/auto/env.pm - System Environment
8 =head1 DESCRIPTION
10 Determining if the C library has C<setenv()> and C<unsetenv()>.
12 More information about these functions can be found at
13 L<http://www.gnu.org/software/libc/manual/html_node/Environment-Access.html>,
14 among other locations.
16 =cut
18 package auto::env;
20 use strict;
21 use warnings;
23 use base qw(Parrot::Configure::Step);
25 use Parrot::Configure::Utils ':auto';
27 sub _init {
28 my $self = shift;
29 my %data;
30 $data{description} = q{Determining if your C library has setenv / unsetenv};
31 $data{result} = q{};
32 return \%data;
35 sub runstep {
36 my ( $self, $conf ) = ( shift, shift );
38 my ( $setenv, $unsetenv ) = ( 0, 0 );
40 $conf->cc_gen('config/auto/env/test_setenv.in');
41 eval { $conf->cc_build(); };
42 unless ( $@ || $conf->cc_run() !~ /ok/ ) {
43 $setenv = 1;
45 $conf->cc_clean();
46 $conf->cc_gen('config/auto/env/test_unsetenv.in');
47 eval { $conf->cc_build(); };
48 unless ( $@ || $conf->cc_run() !~ /ok/ ) {
49 $unsetenv = 1;
51 $conf->cc_clean();
53 $self->_evaluate_env($conf, $setenv, $unsetenv);
55 return 1;
58 sub _evaluate_env {
59 my ($self, $conf, $setenv, $unsetenv) = @_;
60 my $verbose = $conf->options->get('verbose');
61 $conf->data->set(
62 setenv => $setenv,
63 unsetenv => $unsetenv
66 if ( $setenv && $unsetenv ) {
67 print " (both) " if $verbose;
68 $self->set_result('both');
70 elsif ($setenv) {
71 print " (setenv) " if $verbose;
72 $self->set_result('setenv');
74 elsif ($unsetenv) {
75 print " (unsetenv) " if $verbose;
76 $self->set_result('unsetenv');
78 else {
79 print " (no) " if $verbose;
80 $self->set_result('no');
86 # Local Variables:
87 # mode: cperl
88 # cperl-indent-level: 4
89 # fill-column: 100
90 # End:
91 # vim: expandtab shiftwidth=4: