MM_Win32::maybe_command() case-insesitivity tweak
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Win32.pm
index 101f76a..7894ddd 100644 (file)
@@ -33,6 +33,7 @@ $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
 $GCC     = 1 if $Config{'cc'} =~ /^gcc/i;
 $DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
 $NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
+$OBJ   = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
 
 sub dlsyms {
     my($self,%attribs) = @_;
@@ -66,7 +67,21 @@ sub replace_manpage_separator {
 
 sub maybe_command {
     my($self,$file) = @_;
-    return "$file.exe" if -e "$file.exe";
+    my @e = exists($ENV{'PATHEXT'})
+          ? split(/;/, $ENV{PATHEXT})
+         : qw(.com .exe .bat .cmd);
+    my $e = '';
+    for (@e) { $e .= "\Q$_\E|" }
+    chop $e;
+    # see if file ends in one of the known extensions
+    if ($file =~ /($e)$/i) {
+       return $file if -e $file;
+    }
+    else {
+       for (@e) {
+           return "$file$_" if -e "$file$_";
+       }
+    }
     return;
 }
 
@@ -162,11 +177,12 @@ sub init_others
   {
    $self->{'LDLOADLIBS'}
       ||= ( $BORLAND
-            ? 'import32.lib cw32mti.lib '
-            : 'msvcrt.lib oldnames.lib kernel32.lib comdlg32.lib winspool.lib gdi32.lib '
+            ? 'import32.lib'
+            : # compiler adds msvcrtd?.lib according to debug switches
+               'oldnames.lib kernel32.lib comdlg32.lib winspool.lib gdi32.lib '
              .'advapi32.lib user32.lib shell32.lib netapi32.lib ole32.lib '
-             .'oleaut32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib '
-       ) . ' odbc32.lib odbccp32.lib';
+             .'oleaut32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib'
+       ) . ' $(LIBC) odbc32.lib odbccp32.lib';
   }
  $self->{'DEV_NULL'} = '> NUL';
  # $self->{'NOECHO'} = ''; # till we have it working
@@ -447,7 +463,13 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists
 
 sub perl_archive
 {
- return '$(PERL_INC)\perl$(LIB_EXT)';
+    my ($self) = @_;
+    if($OBJ) {
+        if ($self->{CAPI} eq 'TRUE') {
+            return '$(PERL_INC)\perlCAPI$(LIB_EXT)';
+        }
+    }
+    return '$(PERL_INC)\\'.$Config{'libperl'};
 }
 
 sub export_list
@@ -710,6 +732,7 @@ We don't want manpage process.  XXX add pod2html support later.
 =cut
 
 sub manifypods {
+    my($self) = shift;
     return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
 }