Load XML-Feed-0.01 into trunk.
[catagits/XML-Feed.git] / inc / Module / Install / Can.pm
1 #line 1 "inc/Module/Install/Can.pm - /Library/Perl/5.8.1/Module/Install/Can.pm"
2 # $File: //depot/cpan/Module-Install/lib/Module/Install/Can.pm $ $Author: autrijus $
3 # $Revision: #6 $ $Change: 1840 $ $DateTime: 2003/12/28 19:42:02 $ vim: expandtab shiftwidth=4
4
5 package Module::Install::Can;
6 use Module::Install::Base; @ISA = qw(Module::Install::Base);
7 $VERSION = '0.01';
8
9 use strict;
10 use Config ();
11 use File::Spec ();
12 use ExtUtils::MakeMaker ();
13
14 # check if we can run some command
15 sub can_run {
16     my ($self, $cmd) = @_;
17
18     my $_cmd = $cmd;
19     return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
20
21     for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
22         my $abs = File::Spec->catfile($dir, $_[1]);
23         return $abs if (-x $abs or $abs = MM->maybe_command($abs));
24     }
25
26     return;
27 }
28
29 sub can_cc {
30     my $self = shift;
31     my @chunks = split(/ /, $Config::Config{cc}) or return;
32
33     # $Config{cc} may contain args; try to find out the program part
34     while (@chunks) {
35         return $self->can_run("@chunks") || (pop(@chunks), next);
36     }
37
38     return;
39 }
40
41 1;