change#4236 fallout
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Unix.pm
index b4bf41c..8824076 100644 (file)
@@ -377,7 +377,7 @@ sub cflags {
 
     if ($Is_PERL_OBJECT) {
         $self->{CCFLAGS} =~ s/-DPERL_OBJECT(\b|$)/-DPERL_CAPI/g;
-        if ($Is_Win32 && $Config{'cc'} =~ /^cl.exe/i) {
+        if ($Is_Win32 && $Config{'cc'} =~ /^cl/i) {
             # Turn off C++ mode of the MSC compiler
             $self->{CCFLAGS} =~ s/-TP(\s|$)//;
             $self->{OPTIMIZE} =~ s/-TP(\s|$)//;
@@ -388,12 +388,20 @@ sub cflags {
        $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
     }
 
+    my $pollute = '';
+    if ($Config{usemymalloc} and not $Config{bincompat5005}
+       and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
+       and $self->{PERL_MALLOC_OK}) {
+       $pollute = '$(PERL_MALLOC_DEF)';
+    }
+
     return $self->{CFLAGS} = qq{
 CCFLAGS = $self->{CCFLAGS}
 OPTIMIZE = $self->{OPTIMIZE}
 PERLTYPE = $self->{PERLTYPE}
 LARGE = $self->{LARGE}
 SPLIT = $self->{SPLIT}
+MPOLLUTE = $pollute
 };
 
 }
@@ -450,7 +458,7 @@ sub const_cccmd {
     return '' unless $self->needs_linking();
     return $self->{CONST_CCCMD} =
        q{CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \\
-       $(PERLTYPE) $(LARGE) $(SPLIT) $(DEFINE_VERSION) \\
+       $(PERLTYPE) $(LARGE) $(SPLIT) $(MPOLLUTE) $(DEFINE_VERSION) \\
        $(XS_DEFINE_VERSION)};
 }
 
@@ -535,6 +543,7 @@ VERSION_MACRO = VERSION
 DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
 XS_VERSION_MACRO = XS_VERSION
 XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
+PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
 };
 
     push @m, qq{
@@ -1382,9 +1391,9 @@ sub init_dirscan {        # --- File and Directory Lists (.xs .pm .pod etc)
            $h{$name} = 1;
        } elsif ($name =~ /\.PL$/) {
            ($pl_files{$name} = $name) =~ s/\.PL$// ;
-       } elsif ($Is_VMS && $name =~ /[._]pl$/i) {
+       } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
            # case-insensitive filesystem, one dot per name, so foo.h.PL
-           # under Unix appears as foo.h_pl under VMS
+           # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
            local($/); open(PL,$name); my $txt = <PL>; close PL;
            if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
                ($pl_files{$name} = $name) =~ s/[._]pl$//i ;
@@ -1665,10 +1674,34 @@ from the perl source tree.
        }
     } else {
        # we should also consider $ENV{PERL5LIB} here
+        my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
        $self->{PERL_LIB}     ||= $Config::Config{privlibexp};
        $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};
        $self->{PERL_INC}     = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
        my $perl_h;
+
+       if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
+           and not $old){
+           # Maybe somebody tries to build an extension with an
+           # uninstalled Perl outside of Perl build tree
+           my $found;
+           for my $dir (@INC) {
+             $found = $dir, last if -e $self->catdir($dir, "Config.pm");
+           }
+           if ($found) {
+             my $inc = dirname $found;
+             if (-e $self->catdir($inc, "perl.h")) {
+               $self->{PERL_LIB}          = $found;
+               $self->{PERL_ARCHLIB}      = $found;
+               $self->{PERL_INC}          = $inc;
+               $self->{UNINSTALLED_PERL}  = 1;
+               print STDOUT <<EOP;
+... Detected uninstalled Perl.  Trying to continue.
+EOP
+             }
+           }
+       }
+       
        unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))){
            die qq{
 Error: Unable to locate installed Perl libraries or Perl source code.
@@ -2547,6 +2580,10 @@ sub manifypods {
        $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
     }
     unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
+      # Maybe a build by uninstalled Perl?
+      $pod2man_exe = $self->catfile($self->{PERL_INC}, "pod", "pod2man");
+    }
+    unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
        # No pod2man but some MAN3PODS to be installed
        print <<END;