Suppress leaked warnings in ExtUtils tests
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Win32.pm
index fef8767..4998c74 100644 (file)
@@ -19,7 +19,7 @@ the semantics.
 
 =cut 
 
-use Config;
+use ExtUtils::MakeMaker::Config;
 use File::Basename;
 use File::Spec;
 use ExtUtils::MakeMaker qw( neatvalue );
@@ -29,7 +29,7 @@ use vars qw(@ISA $VERSION $BORLAND $GCC $DMAKE $NMAKE);
 require ExtUtils::MM_Any;
 require ExtUtils::MM_Unix;
 @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
-$VERSION = '1.07';
+$VERSION = '1.12';
 
 $ENV{EMXSHELL} = 'sh'; # to run `commands`
 
@@ -121,20 +121,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.
@@ -169,18 +155,22 @@ sub init_others {
 
     # Used in favor of echo because echo won't strip quotes. :(
     $self->{ECHO}     ||= $self->oneliner('print qq{@ARGV}', ['-l']);
-
-    $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->{ECHO_N}   ||= $self->oneliner('print qq{@ARGV}');
+
+    $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';
 
@@ -207,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
 
@@ -235,7 +225,7 @@ sub platform_constants {
 }
 
 
-=item special_targets (o)
+=item special_targets
 
 Add .USESHELL target for dmake.
 
@@ -254,7 +244,7 @@ MAKE_FRAG
 }
 
 
-=item static_lib (o)
+=item static_lib
 
 Changes how to run the linker.
 
@@ -269,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
 
@@ -292,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. :(
 
@@ -331,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,  
@@ -356,28 +345,20 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILE
        $(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
@@ -409,7 +390,7 @@ sub perl_script {
 }
 
 
-=item xs_o (o)
+=item xs_o
 
 This target is stubbed out.  Not sure why.
 
@@ -420,7 +401,7 @@ sub xs_o {
 }
 
 
-=item pasthru (o)
+=item pasthru
 
 All we send is -nologo to nmake to prevent it from printing its damned
 banner.
@@ -433,7 +414,7 @@ sub pasthru {
 }
 
 
-=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.
@@ -453,7 +434,7 @@ sub oneliner {
 
     $switches = join ' ', @$switches;
 
-    return qq{\$(PERLRUN) $switches -e $cmd};
+    return qq{\$(ABSPERLRUN) $switches -e $cmd};
 }
 
 
@@ -487,16 +468,51 @@ 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 $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
 
-Using 31K, a safe number gotten from Windows 2000.
+nmake 1.50 limits command length to 2048 characters.
 
 =cut
 
 sub max_exec_len {
     my $self = shift;
 
-    return $self->{_MAX_EXEC_LEN} ||= 31 * 1024;
+    return $self->{_MAX_EXEC_LEN} ||= 2 * 1024;
 }