2 package Module::Install::Can;
7 use ExtUtils::MakeMaker ();
8 use Module::Install::Base ();
10 use vars qw{$VERSION @ISA $ISCORE};
13 @ISA = 'Module::Install::Base';
17 # check if we can load some module
18 ### Upgrade this to not have to load the module if possible
20 my ($self, $mod, $ver) = @_;
22 $mod .= '.pm' unless $mod =~ /\.pm$/i;
29 eval { require $mod; $pkg->VERSION($ver || 0); 1 };
32 # check if we can run some command
34 my ($self, $cmd) = @_;
37 return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
39 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
41 my $abs = File::Spec->catfile($dir, $_[1]);
42 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
48 # can we locate a (the) C compiler
51 my @chunks = split(/ /, $Config::Config{cc}) or return;
53 # $Config{cc} may contain args; try to find out the program part
55 return $self->can_run("@chunks") || (pop(@chunks), next);
61 # Fix Cygwin bug on maybe_command();
62 if ( $^O eq 'cygwin' ) {
63 require ExtUtils::MM_Cygwin;
64 require ExtUtils::MM_Win32;
65 if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
66 *ExtUtils::MM_Cygwin::maybe_command = sub {
67 my ($self, $file) = @_;
68 if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
69 ExtUtils::MM_Win32->maybe_command($file);
71 ExtUtils::MM_Unix->maybe_command($file);