"lose the it's", from Abhijit Menon-Sen.
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Win32.pm
index 5191bc8..7bcf1f1 100644 (file)
@@ -1,5 +1,7 @@
 package ExtUtils::MM_Win32;
 
+our $VERSION = '1.00';
+
 =head1 NAME
 
 ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
@@ -14,7 +16,7 @@ See ExtUtils::MM_Unix for a documentation of the methods provided
 there. This package overrides the implementation of these methods, not
 the semantics.
 
-=over
+=over 4
 
 =cut 
 
@@ -23,8 +25,8 @@ use Config;
 use File::Basename;
 require Exporter;
 
-Exporter::import('ExtUtils::MakeMaker',
-       qw( $Verbose &neatvalue));
+require ExtUtils::MakeMaker;
+ExtUtils::MakeMaker->import(qw( $Verbose &neatvalue));
 
 $ENV{EMXSHELL} = 'sh'; # to run `commands`
 unshift @MM::ISA, 'ExtUtils::MM_Win32';
@@ -36,6 +38,49 @@ $NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
 $PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
 $OBJ   = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
 
+# a few workarounds for command.com (very basic)
+{
+    package ExtUtils::MM_Win95;
+
+    # the $^O test may be overkill, but we want to be sure Win32::IsWin95()
+    # exists before we try it
+
+    unshift @MM::ISA, 'ExtUtils::MM_Win95'
+       if ($^O =~ /Win32/ && Win32::IsWin95());
+
+    sub xs_c {
+       my($self) = shift;
+       return '' unless $self->needs_linking();
+       '
+.xs.c:
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
+           $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c
+       '
+    }
+
+    sub xs_cpp {
+       my($self) = shift;
+       return '' unless $self->needs_linking();
+       '
+.xs.cpp:
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
+           $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.cpp
+       ';
+    }
+
+    # many makes are too dumb to use xs_c then c_o
+    sub xs_o {
+       my($self) = shift;
+       return '' unless $self->needs_linking();
+       '
+.xs$(OBJ_EXT):
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
+           $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c
+       $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
+       ';
+    }
+}      # end of command.com workarounds
+
 sub dlsyms {
     my($self,%attribs) = @_;
 
@@ -345,7 +390,6 @@ PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
 
 
 sub path {
-    local $^W = 1;
     my($self) = @_;
     my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'};
     my @path = split(';',$path);
@@ -371,7 +415,7 @@ sub static_lib {
 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
        $(RM_RF) $@
 END
-    # If this extension has it's own library (eg SDBM_File)
+    # If this extension has its own library (eg SDBM_File)
     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
     push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
 
@@ -441,6 +485,18 @@ sub dynamic_lib {
     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
     my($ldfrom) = '$(LDFROM)';
     my(@m);
+
+# one thing for GCC/Mingw32:
+# we try to overcome non-relocateable-DLL problems by generating
+#    a (hopefully unique) image-base from the dll's name
+# -- BKS, 10-19-1999
+    if ($GCC) { 
+       my $dllname = $self->{BASEEXT} . "." . $self->{DLEXT};
+       $dllname =~ /(....)(.{0,4})/;
+       my $baseaddr = unpack("n", $1 ^ $2);
+       $otherldflags .= sprintf("-Wl,--image-base,0x%x0000 ", $baseaddr);
+    }
+
     push(@m,'
 # This section creates the dynamically loadable $(INST_DYNAMIC)
 # from $(OBJECT) and possibly $(MYEXTLIB).
@@ -476,14 +532,25 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists
     join('',@m);
 }
 
+sub clean
+{
+ my ($self) = @_;
+ my $s = &ExtUtils::MM_Unix::clean;
+ if ($GCC) {
+       $s .= <<'END';
+clean ::
+       -$(RM_F) dll.base dll.exp
+
+END
+ }
+ return $s;
+}
+
+
+
 sub perl_archive
 {
     my ($self) = @_;
-    if($OBJ) {
-        if ($self->{CAPI}) {
-            return '$(PERL_INC)\perlCAPI$(LIB_EXT)';
-        }
-    }
     return '$(PERL_INC)\\'.$Config{'libperl'};
 }
 
@@ -547,7 +614,7 @@ pm_to_blib: $(TO_INST_PM)
        ($NMAKE ? 'qw[ <<pmfiles.dat ],'
                : $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],'
                         : '{ qw[$(PM_TO_BLIB)] },'
-        ).q{'}.$autodir.q{')"
+        ).q{'}.$autodir.q{','$(PM_FILTER)')"
        }. ($NMAKE ? q{
 $(PM_TO_BLIB)
 <<
@@ -635,7 +702,7 @@ MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
 -e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');"
 
 DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \
--e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', shift, '>';" \
+-e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', $$arg=shift, '|', $$arg, '>';" \
 -e "print '=over 4';" \
 -e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \
 -e "print '=back';"
@@ -699,12 +766,6 @@ config :: $(INST_AUTODIR)\.exists
        '.$self->{NOECHO}.'$(NOOP)
 ';
 
-    push @m, qq{
-config :: Version_check
-       $self->{NOECHO}\$(NOOP)
-
-} unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC};
-
     push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
 
     if (%{$self->{HTMLLIBPODS}}) {