2 package Module::Install::Can;
5 use Module::Install::Base;
7 ### This adds a 5.005 Perl version dependency.
8 ### This is a bug and will be fixed.
10 use ExtUtils::MakeMaker ();
12 use vars qw{$VERSION $ISCORE @ISA};
16 @ISA = qw{Module::Install::Base};
19 # check if we can load some module
20 ### Upgrade this to not have to load the module if possible
22 my ($self, $mod, $ver) = @_;
24 $mod .= '.pm' unless $mod =~ /\.pm$/i;
31 eval { require $mod; $pkg->VERSION($ver || 0); 1 };
34 # check if we can run some command
36 my ($self, $cmd) = @_;
39 return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
41 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
42 my $abs = File::Spec->catfile($dir, $_[1]);
43 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
49 # can we locate a (the) C compiler
52 my @chunks = split(/ /, $Config::Config{cc}) or return;
54 # $Config{cc} may contain args; try to find out the program part
56 return $self->can_run("@chunks") || (pop(@chunks), next);
62 # Fix Cygwin bug on maybe_command();
63 if ( $^O eq 'cygwin' ) {
64 require ExtUtils::MM_Cygwin;
65 require ExtUtils::MM_Win32;
66 if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
67 *ExtUtils::MM_Cygwin::maybe_command = sub {
68 my ($self, $file) = @_;
69 if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
70 ExtUtils::MM_Win32->maybe_command($file);
72 ExtUtils::MM_Unix->maybe_command($file);