| File: | config/auto/env.pm |
| Coverage: | 92.4% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2001-2009, Parrot Foundation. | ||||
| 2 | # $Id: env.pm 37201 2009-03-08 12:07:48Z fperrad $ | ||||
| 3 | |||||
| 4 - 16 | =head1 NAME config/auto/env.pm - System Environment =head1 DESCRIPTION Determining if the C library has C<setenv()> and C<unsetenv()>. More information about these functions can be found at L<http://www.gnu.org/software/libc/manual/html_node/Environment-Access.html>, among other locations. =cut | ||||
| 17 | |||||
| 18 | package auto::env; | ||||
| 19 | |||||
| 20 | 81 81 81 | use strict; | |||
| 21 | 81 81 81 | use warnings; | |||
| 22 | |||||
| 23 | 81 81 81 | use base qw(Parrot::Configure::Step); | |||
| 24 | |||||
| 25 | 81 81 81 | use Parrot::Configure::Utils ':auto'; | |||
| 26 | |||||
| 27 | sub _init { | ||||
| 28 | 83 | my $self = shift; | |||
| 29 | 83 | my %data; | |||
| 30 | 83 | $data{description} = q{Does your C library have setenv / unsetenv}; | |||
| 31 | 83 | $data{result} = q{}; | |||
| 32 | 83 | return \%data; | |||
| 33 | } | ||||
| 34 | |||||
| 35 | sub runstep { | ||||
| 36 | 81 | my ( $self, $conf ) = ( shift, shift ); | |||
| 37 | |||||
| 38 | 81 | my ( $setenv, $unsetenv ) = ( 0, 0 ); | |||
| 39 | |||||
| 40 | 81 | $conf->cc_gen('config/auto/env/test_setenv_c.in'); | |||
| 41 | 81 81 | eval { $conf->cc_build(); }; | |||
| 42 | 81 | unless ( $@ || $conf->cc_run() !~ /ok/ ) { | |||
| 43 | 81 | $setenv = 1; | |||
| 44 | } | ||||
| 45 | 81 | $conf->cc_clean(); | |||
| 46 | 81 | $conf->cc_gen('config/auto/env/test_unsetenv_c.in'); | |||
| 47 | 81 81 | eval { $conf->cc_build(); }; | |||
| 48 | 81 | unless ( $@ || $conf->cc_run() !~ /ok/ ) { | |||
| 49 | 81 | $unsetenv = 1; | |||
| 50 | } | ||||
| 51 | 81 | $conf->cc_clean(); | |||
| 52 | |||||
| 53 | 81 | $self->_evaluate_env($conf, $setenv, $unsetenv); | |||
| 54 | |||||
| 55 | 81 | return 1; | |||
| 56 | } | ||||
| 57 | |||||
| 58 | sub _evaluate_env { | ||||
| 59 | 89 | my ($self, $conf, $setenv, $unsetenv) = @_; | |||
| 60 | 89 | my $verbose = $conf->options->get('verbose'); | |||
| 61 | 89 | $conf->data->set( | |||
| 62 | setenv => $setenv, | ||||
| 63 | unsetenv => $unsetenv | ||||
| 64 | ); | ||||
| 65 | |||||
| 66 | 89 | if ( $setenv && $unsetenv ) { | |||
| 67 | 83 | print " (both) " if $verbose; | |||
| 68 | 83 | $self->set_result('both'); | |||
| 69 | } | ||||
| 70 | elsif ($setenv) { | ||||
| 71 | 2 | print " (setenv) " if $verbose; | |||
| 72 | 2 | $self->set_result('setenv'); | |||
| 73 | } | ||||
| 74 | elsif ($unsetenv) { | ||||
| 75 | 2 | print " (unsetenv) " if $verbose; | |||
| 76 | 2 | $self->set_result('unsetenv'); | |||
| 77 | } | ||||
| 78 | else { | ||||
| 79 | 2 | print " (no) " if $verbose; | |||
| 80 | 2 | $self->set_result('no'); | |||
| 81 | } | ||||
| 82 | } | ||||
| 83 | |||||
| 84 | 1; | ||||
| 85 | |||||
| 86 | # Local Variables: | ||||
| 87 | # mode: cperl | ||||
| 88 | # cperl-indent-level: 4 | ||||
| 89 | # fill-column: 100 | ||||
| 90 | # End: | ||||
| 91 | # vim: expandtab shiftwidth=4: | ||||