CXUX_BROKEN_CONSTANT_CONVERT isn't used anymore.
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_VMS.pm
index 02c4669..7cf0e2f 100644 (file)
@@ -20,8 +20,8 @@ BEGIN {
 
 use File::Basename;
 use vars qw($Revision @ISA $VERSION);
-($VERSION) = '5.68';
-($Revision) = q$Revision: 1.104 $ =~ /Revision:\s+(\S+)/;
+($VERSION) = '5.71_01';
+($Revision) = q$Revision: 1.113 $ =~ /Revision:\s+(\S+)/;
 
 require ExtUtils::MM_Any;
 require ExtUtils::MM_Unix;
@@ -164,25 +164,33 @@ sub find_perl {
     my($rslt);
     my($inabs) = 0;
     local *TCF;
-    # Check in relative directories first, so we pick up the current
-    # version of Perl if we're running MakeMaker as part of the main build.
-    @sdirs = sort { my($absa) = $self->file_name_is_absolute($a);
-                    my($absb) = $self->file_name_is_absolute($b);
-                    if ($absa && $absb) { return $a cmp $b }
-                    else { return $absa ? 1 : ($absb ? -1 : ($a cmp $b)); }
-                  } @$dirs;
-    # Check miniperl before perl, and check names likely to contain
-    # version numbers before "generic" names, so we pick up an
-    # executable that's less likely to be from an old installation.
-    @snames = sort { my($ba) = $a =~ m!([^:>\]/]+)$!;  # basename
-                     my($bb) = $b =~ m!([^:>\]/]+)$!;
-                     my($ahasdir) = (length($a) - length($ba) > 0);
-                     my($bhasdir) = (length($b) - length($bb) > 0);
-                     if    ($ahasdir and not $bhasdir) { return 1; }
-                     elsif ($bhasdir and not $ahasdir) { return -1; }
-                     else { $bb =~ /\d/ <=> $ba =~ /\d/
-                            or substr($ba,0,1) cmp substr($bb,0,1)
-                            or length($bb) <=> length($ba) } } @$names;
+
+    if( $self->{PERL_CORE} ) {
+        # Check in relative directories first, so we pick up the current
+        # version of Perl if we're running MakeMaker as part of the main build.
+        @sdirs = sort { my($absa) = $self->file_name_is_absolute($a);
+                        my($absb) = $self->file_name_is_absolute($b);
+                        if ($absa && $absb) { return $a cmp $b }
+                        else { return $absa ? 1 : ($absb ? -1 : ($a cmp $b)); }
+                      } @$dirs;
+        # Check miniperl before perl, and check names likely to contain
+        # version numbers before "generic" names, so we pick up an
+        # executable that's less likely to be from an old installation.
+        @snames = sort { my($ba) = $a =~ m!([^:>\]/]+)$!;  # basename
+                         my($bb) = $b =~ m!([^:>\]/]+)$!;
+                         my($ahasdir) = (length($a) - length($ba) > 0);
+                         my($bhasdir) = (length($b) - length($bb) > 0);
+                         if    ($ahasdir and not $bhasdir) { return 1; }
+                         elsif ($bhasdir and not $ahasdir) { return -1; }
+                         else { $bb =~ /\d/ <=> $ba =~ /\d/
+                                  or substr($ba,0,1) cmp substr($bb,0,1)
+                                  or length($bb) <=> length($ba) } } @$names;
+    }
+    else {
+        @sdirs  = @$dirs;
+        @snames = @$names;
+    }
+
     # Image names containing Perl version use '_' instead of '.' under VMS
     foreach $name (@snames) { $name =~ s/\.(\d+)$/_$1/; }
     if ($trace >= 2){
@@ -758,23 +766,11 @@ sub tool_xsubpp {
         (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)) {
         unshift(@tmargs,'-nolinenumbers');
     }
-    my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,'xsubpp'));
 
-    # What are the correct thresholds for version 1 && 2 Paul?
-    if ( $xsubpp_version > 1.923 ){
-       $self->{XSPROTOARG} = '' unless defined $self->{XSPROTOARG};
-    } else {
-       if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
-           print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
-       Your version of xsubpp is $xsubpp_version and cannot handle this.
-       Please upgrade to a more recent version of xsubpp.
-};
-       } else {
-           $self->{XSPROTOARG} = "";
-       }
-    }
 
-    "
+    $self->{XSPROTOARG} = '' unless defined $self->{XSPROTOARG};
+
+    return "
 XSUBPPDIR = $xsdir
 XSUBPP = \$(PERLRUN) \$(XSUBPPDIR)xsubpp
 XSPROTOARG = $self->{XSPROTOARG}
@@ -783,71 +779,6 @@ XSUBPPARGS = @tmargs
 ";
 }
 
-=item xsubpp_version (override)
-
-Test xsubpp exit status according to VMS rules ($sts & 1 ==E<gt> good)
-rather than Unix rules ($sts == 0 ==E<gt> good).
-
-=cut
-
-sub xsubpp_version
-{
-    my($self,$xsubpp) = @_;
-    my ($version) ;
-    return '' unless $self->needs_linking;
-
-    # try to figure out the version number of the xsubpp on the system
-
-    # first try the -v flag, introduced in 1.921 & 2.000a2
-
-    my $command = qq{$self->{PERL} "-I$self->{PERL_LIB}" $xsubpp -v};
-    print "Running: $command\n" if $Verbose;
-    $version = `$command` ;
-    if ($?) {
-       use ExtUtils::MakeMaker::vmsish 'status';
-       warn "Running '$command' exits with status $?";
-    }
-    chop $version ;
-
-    return $1 if $version =~ /^xsubpp version (.*)/ ;
-
-    # nope, then try something else
-
-    my $counter = '000';
-    my ($file) = 'temp' ;
-    $counter++ while -e "$file$counter"; # don't overwrite anything
-    $file .= $counter;
-
-    local(*F);
-    open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
-    print F <<EOM ;
-MODULE = fred PACKAGE = fred
-
-int
-fred(a)
-       int     a;
-EOM
-
-    close F ;
-
-    $command = "$self->{PERLRUN} $xsubpp $file";
-    print "Running: $command\n" if $Verbose;
-    my $text = `$command` ;
-    if ($?) {
-       use ExtUtils::MakeMaker::vmsish 'status';
-       warn "Running '$command' exits with status $?";
-    }
-    unlink $file ;
-
-    # gets 1.2 -> 1.92 and 2.000a1
-    return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/  ;
-
-    # it is either 1.0 or 1.1
-    return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
-
-    # none of the above, so 1.0
-    return "1.0" ;
-}
 
 =item tools_other (override)
 
@@ -1075,13 +1006,12 @@ INST_DYNAMIC_DEP = $inst_dynamic_dep
 
 ";
     push @m, '
-$(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
+$(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt blibdirs.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
        $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
        If F$TrnLNm("',$shr,'").eqs."" Then Define/NoLog/User ',"$shr Sys\$Share:$shr.$Config{'dlext'}",'
        Link $(LDFLAGS) /Shareable=$(MMS$TARGET)$(OTHERLDFLAGS) $(BASEEXT).opt/Option,$(PERL_INC)perlshr_attr.opt/Option
 ';
 
-    push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
     join('',@m);
 }
 
@@ -1102,13 +1032,13 @@ BOOTSTRAP = '."$self->{BASEEXT}.bs".'
 # As MakeMaker mkbootstrap might not write a file (if none is required)
 # we use touch to prevent make continually trying to remake it.
 # The DynaLoader only reads a non-empty file.
-$(BOOTSTRAP) : $(FIRST_MAKEFILE) '."$self->{BOOTDEP}".' $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
+$(BOOTSTRAP) : $(FIRST_MAKEFILE) '."$self->{BOOTDEP}".' blibdirs.exists
        $(NOECHO) $(ECHO) "Running mkbootstrap for $(NAME) ($(BSLOADLIBS))"
        $(NOECHO) $(PERLRUN) -
        -e "use ExtUtils::Mkbootstrap; Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
        $(NOECHO) $(TOUCH) $(MMS$TARGET)
 
-$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
+$(INST_BOOT) : $(BOOTSTRAP) blibdirs.exists
        $(NOECHO) $(RM_RF) $(INST_BOOT)
        - $(CP) $(BOOTSTRAP) $(INST_BOOT)
 ';
@@ -1132,7 +1062,7 @@ $(INST_STATIC) :
     my(@m,$lib);
     push @m,'
 # Rely on suffix rule for update action
-$(OBJECT) : $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
+$(OBJECT) : blibdirs.exists
 
 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB)
 ';
@@ -1155,7 +1085,6 @@ $(INST_STATIC) : $(OBJECT) $(MYEXTLIB)
     foreach $lib (split ' ', $self->{EXTRALIBS}) {
       push(@m,"\t",'$(NOECHO) $(PERL) -e "print qq{',$lib,'\n}" >>$(INST_ARCHAUTODIR)extralibs.ld',"\n");
     }
-    push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
     join('',@m);
 }
 
@@ -1241,10 +1170,10 @@ realclean ::
         }
        $todir = $self->fixpath($todir,1);
        push @m, "
-$to : $from \$(FIRST_MAKEFILE) ${todir}\$(DIRFILESEP).exists
+$to : $from \$(FIRST_MAKEFILE) blibdirs.exists
        \$(CP) $from $to
 
-", $self->dir_target($todir);
+";
     }
     join "", @m;
 }
@@ -1306,13 +1235,14 @@ clean :: clean_subdirs
            else { push(@otherfiles, $word); }
        }
     }
-    push(@otherfiles, qw[ blib $(MAKE_APERL_FILE) extralibs.ld 
-                          perlmain.c pm_to_blib pm_to_blib.ts ]);
+    push(@otherfiles, qw[ blib $(MAKE_APERL_FILE) 
+                          perlmain.c blibdirs.exists pm_to_blib pm_to_blib.ts ]);
     push(@otherfiles, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
+    push(@otherfiles, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
 
     # Occasionally files are repeated several times from different sources
     { my(%of) = map { ($_ => 1) } @otherfiles; @otherfiles = keys %of; }
-    
+
     my $line = '';
     foreach my $file (@otherfiles) {
        $file = $self->fixpath($file);
@@ -1385,7 +1315,8 @@ realclean :: clean
     # combination of macros).  In order to stay below DCL's 255 char limit,
     # we put only 2 on a line.
     my($file,$fcnt);
-    my(@files) = qw{ $(FIRST_MAKEFILE) $(MAKEFILE_OLD) };
+    my(@files) = values %{$self->{PM}};
+    push @files, qw{ $(FIRST_MAKEFILE) $(MAKEFILE_OLD) };
     if ($self->has_link_code) {
        push(@files,qw{ $(INST_DYNAMIC) $(INST_STATIC) $(INST_BOOT) $(OBJECT) });
     }
@@ -2112,6 +2043,9 @@ sub prefixify {
         print STDERR "  no Config found for $var.\n" if $Verbose >= 2;
         $path = $self->_prefixify_default($rprefix, $default);
     }
+    elsif( !$self->{ARGS}{PREFIX} || !$self->file_name_is_absolute($path) ) {
+        # do nothing if there's no prefix or if its relative
+    }
     elsif( $sprefix eq $rprefix ) {
         print STDERR "  no new prefix.\n" if $Verbose >= 2;
     }
@@ -2398,6 +2332,34 @@ sub os_flavor {
     return('VMS');
 }
 
+=item blibdirs_target (override)
+
+    my $make_frag = $mm->blibdirs_target;
+
+Creates the blibdirs.exists target which creates all the directories we use in
+blib/.  Override because older CRTLs have trouble with C<mkpath '[.foo]'> (as 
+opposed to C<mkpath 'foo.dir'>).
+
+=cut
+
+sub blibdirs_target {
+    my $self = shift;
+
+    my @dirs = map { uc "\$(INST_$_)" } qw(libdir
+                                       autodir archautodir
+                                       bin script
+                                       man1dir man3dir
+                                      );
+    
+    my $make = "\nblibdirs.exists :: \n";
+    for my $dir (@dirs) {
+        $make .= "\t" . '$(NOECHO) CREATE/DIRECTORY/PROTECTION=(O:RWE,G:RE,W:RE) ' . $dir . "\n";
+    }
+    $make .= "\t\$(NOECHO) \$(TOUCH) blibdirs.exists\n\n";
+
+    return $make;
+}
+
 =back
 
 =cut