Fixes for the test suite on OS/2
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Win32.pm
index be9de22..efbd582 100644 (file)
@@ -19,24 +19,22 @@ the semantics.
 
 =cut 
 
-use Config;
+use ExtUtils::MakeMaker::Config;
 use File::Basename;
 use File::Spec;
 use ExtUtils::MakeMaker qw( neatvalue );
 
-use vars qw(@ISA $VERSION $BORLAND $GCC $DMAKE $NMAKE);
+use vars qw(@ISA $VERSION);
 
 require ExtUtils::MM_Any;
 require ExtUtils::MM_Unix;
 @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
-$VERSION = '1.08';
+$VERSION = '1.13';
 
 $ENV{EMXSHELL} = 'sh'; # to run `commands`
 
-$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;
+my $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
+my $GCC     = 1 if $Config{'cc'} =~ /^gcc/i;
 
 
 =head2 Overridden methods
@@ -121,20 +119,6 @@ sub maybe_command {
 }
 
 
-=item B<find_tests>
-
-The Win9x shell does not expand globs and I'll play it safe and assume
-other Windows variants don't either.
-
-So we do it for them.
-
-=cut
-
-sub find_tests {
-    return join(' ', <t\\*.t>);
-}
-
-
 =item B<init_DIRFILESEP>
 
 Using \ for Windows.
@@ -144,10 +128,12 @@ Using \ for Windows.
 sub init_DIRFILESEP {
     my($self) = shift;
 
+    my $make = $self->make;
+
     # The ^ makes sure its not interpreted as an escape in nmake
-    $self->{DIRFILESEP} = $NMAKE ? '^\\' :
-                          $DMAKE ? '\\\\'
-                                 : '\\';
+    $self->{DIRFILESEP} = $make eq 'nmake' ? '^\\' :
+                          $make eq 'dmake' ? '\\\\'
+                                           : '\\';
 }
 
 =item B<init_others>
@@ -171,17 +157,20 @@ sub init_others {
     $self->{ECHO}     ||= $self->oneliner('print qq{@ARGV}', ['-l']);
     $self->{ECHO_N}   ||= $self->oneliner('print qq{@ARGV}');
 
-    $self->{TOUCH}    ||= '$(PERLRUN) -MExtUtils::Command -e touch';
-    $self->{CHMOD}    ||= '$(PERLRUN) -MExtUtils::Command -e chmod'; 
-    $self->{CP}       ||= '$(PERLRUN) -MExtUtils::Command -e cp';
-    $self->{RM_F}     ||= '$(PERLRUN) -MExtUtils::Command -e rm_f';
-    $self->{RM_RF}    ||= '$(PERLRUN) -MExtUtils::Command -e rm_rf';
-    $self->{MV}       ||= '$(PERLRUN) -MExtUtils::Command -e mv';
+    $self->{TOUCH}    ||= '$(ABSPERLRUN) -MExtUtils::Command -e touch';
+    $self->{CHMOD}    ||= '$(ABSPERLRUN) -MExtUtils::Command -e chmod'; 
+    $self->{CP}       ||= '$(ABSPERLRUN) -MExtUtils::Command -e cp';
+    $self->{RM_F}     ||= '$(ABSPERLRUN) -MExtUtils::Command -e rm_f';
+    $self->{RM_RF}    ||= '$(ABSPERLRUN) -MExtUtils::Command -e rm_rf';
+    $self->{MV}       ||= '$(ABSPERLRUN) -MExtUtils::Command -e mv';
     $self->{NOOP}     ||= 'rem';
-    $self->{TEST_F}   ||= '$(PERLRUN) -MExtUtils::Command -e test_f';
+    $self->{TEST_F}   ||= '$(ABSPERLRUN) -MExtUtils::Command -e test_f';
     $self->{DEV_NULL} ||= '> NUL';
 
-    # technically speaking, these should be in init_main()
+    $self->{FIXIN}    ||= $self->{PERL_CORE} ? 
+      "\$(PERLRUN) $self->{PERL_SRC}/win32/bin/pl2bat.pl" : 
+      'pl2bat.bat';
+
     $self->{LD}     ||= $Config{ld} || 'link';
     $self->{AR}     ||= $Config{ar} || 'lib';
 
@@ -208,11 +197,11 @@ sub init_others {
 }
 
 
-=item init_platform (o)
+=item init_platform
 
 Add MM_Win32_VERSION.
 
-=item platform_constants (o)
+=item platform_constants
 
 =cut
 
@@ -236,7 +225,7 @@ sub platform_constants {
 }
 
 
-=item special_targets (o)
+=item special_targets
 
 Add .USESHELL target for dmake.
 
@@ -247,7 +236,7 @@ sub special_targets {
 
     my $make_frag = $self->SUPER::special_targets;
 
-    $make_frag .= <<'MAKE_FRAG' if $DMAKE;
+    $make_frag .= <<'MAKE_FRAG' if $self->make eq 'dmake';
 .USESHELL :
 MAKE_FRAG
 
@@ -255,7 +244,7 @@ MAKE_FRAG
 }
 
 
-=item static_lib (o)
+=item static_lib
 
 Changes how to run the linker.
 
@@ -270,7 +259,7 @@ sub static_lib {
 
     my(@m);
     push(@m, <<'END');
-$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
+$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
        $(RM_RF) $@
 END
 
@@ -293,12 +282,11 @@ q{        $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
        $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs
 MAKE_FRAG
 
-    push @m, "\n", $self->dir_target('$(INST_ARCHAUTODIR)');
     join('', @m);
 }
 
 
-=item dynamic_lib (o)
+=item dynamic_lib
 
 Complicated stuff for Win32 that I don't understand. :(
 
@@ -332,7 +320,7 @@ sub dynamic_lib {
 OTHERLDFLAGS = '.$otherldflags.'
 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
 
-$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
+$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
 ');
     if ($GCC) {
       push(@m,  
@@ -343,7 +331,8 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILE
     } elsif ($BORLAND) {
       push(@m,
        q{      $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,}
-       .($DMAKE ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) }
+       .($self->make eq 'dmake' 
+                ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) }
                 .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)}
                : q{$(subst /,\,$(PERL_ARCHIVE)) $(subst /,\,$(LDLOADLIBS)) }
                 .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))})
@@ -352,33 +341,30 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILE
       push(@m,
        q{      $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
       .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
+      if ($Config{cc} eq 'cl' and $Config{ccversion} =~ /^(\d+)/ and $1 >= 14) {       # VC 2005 (aka VC 8) or higher
+        push(@m,
+          q{   
+       mt -nologo -manifest $@.manifest -outputresource:$@;2 && del $@.manifest});
+      }
     }
     push @m, '
        $(CHMOD) $(PERM_RWX) $@
 ';
 
-    push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
     join('',@m);
 }
 
-=item clean
+=item extra_clean_files
 
 Clean out some extra dll.{base,exp} files which might be generated by
 gcc.  Otherwise, take out all *.pdb files.
 
 =cut
 
-sub clean
-{
-    my ($self) = shift;
-    my $s = $self->SUPER::clean(@_);
-    my $clean = $GCC ? 'dll.base dll.exp' : '*.pdb';
-    $s .= <<END;
-clean ::
-       -\$(RM_F) $clean
+sub extra_clean_files {
+    my $self = shift;
 
-END
-    return $s;
+    return $GCC ? (qw(dll.base dll.exp)) : ('*.pdb');
 }
 
 =item init_linker
@@ -410,7 +396,7 @@ sub perl_script {
 }
 
 
-=item xs_o (o)
+=item xs_o
 
 This target is stubbed out.  Not sure why.
 
@@ -421,7 +407,7 @@ sub xs_o {
 }
 
 
-=item pasthru (o)
+=item pasthru
 
 All we send is -nologo to nmake to prevent it from printing its damned
 banner.
@@ -430,11 +416,11 @@ banner.
 
 sub pasthru {
     my($self) = shift;
-    return "PASTHRU = " . ($NMAKE ? "-nologo" : "");
+    return "PASTHRU = " . ($self->make eq 'nmake' ? "-nologo" : "");
 }
 
 
-=item oneliner (o)
+=item oneliner
 
 These are based on what command.com does on Win98.  They may be wrong
 for other Windows shells, I don't know.
@@ -454,7 +440,7 @@ sub oneliner {
 
     $switches = join ' ', @$switches;
 
-    return qq{\$(PERLRUN) $switches -e $cmd};
+    return qq{\$(ABSPERLRUN) $switches -e $cmd --};
 }
 
 
@@ -469,7 +455,7 @@ sub quote_literal {
     # quotes; however it transforms {{ into { either inside and outside double
     # quotes.  It also translates }} into }.  The escaping below is not
     # 100% correct.
-    if( $DMAKE ) {
+    if( $self->make eq 'dmake' ) {
         $text =~ s/{/{{/g;
         $text =~ s/}}/}}}/g;
     }
@@ -488,6 +474,41 @@ sub escape_newlines {
 }
 
 
+=item cd
+
+dmake can handle Unix style cd'ing but nmake (at least 1.5) cannot.  It
+wants:
+
+    cd dir
+    command
+    another_command
+    cd ..
+
+B<NOTE> This cd can only go one level down.  So far this sufficient for
+what MakeMaker needs.
+
+=cut
+
+sub cd {
+    my($self, $dir, @cmds) = @_;
+
+    return $self->SUPER::cd($dir, @cmds) unless $self->make eq 'nmake';
+
+    my $cmd = join "\n\t", map "$_", @cmds;
+
+    # No leading tab and no trailing newline makes for easier embedding.
+    my $make_frag = sprintf <<'MAKE_FRAG', $dir, $cmd;
+cd %s
+       %s
+       cd ..
+MAKE_FRAG
+
+    chomp $make_frag;
+
+    return $make_frag;
+}
+
+
 =item max_exec_len
 
 nmake 1.50 limits command length to 2048 characters.