[dummy merge]
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_VMS.pm
index f609cc8..aca41ea 100644 (file)
@@ -6,14 +6,18 @@
 #   Author:  Charles Bailey  bailey@genetics.upenn.edu
 
 package ExtUtils::MM_VMS;
-$ExtUtils::MM_VMS::Revision=$ExtUtils::MM_VMS::Revision = '5.39 (16-Jan-1997)';
-unshift @MM::ISA, 'ExtUtils::MM_VMS';
 
+use Carp qw( &carp );
 use Config;
 require Exporter;
 use VMS::Filespec;
 use File::Basename;
 
+use vars qw($Revision);
+$Revision = '5.3901 (6-Mar-1997)';
+
+unshift @MM::ISA, 'ExtUtils::MM_VMS';
+
 Exporter::import('ExtUtils::MakeMaker', '$Verbose', '&neatvalue');
 
 =head1 NAME
@@ -47,16 +51,23 @@ sub eliminate_macros {
        return '';
     }
     my($npath) = unixify($path);
+    my($complex) = 0;
     my($head,$macro,$tail);
 
     # perform m##g in scalar context so it acts as an iterator
     while ($npath =~ m#(.*?)\$\((\S+?)\)(.*)#g) { 
         if ($self->{$2}) {
             ($head,$macro,$tail) = ($1,$2,$3);
-            ($macro = unixify($self->{$macro})) =~ s#/$##;
+            if (ref $self->{$macro}) {
+              carp "Can't expand macro containing " . ref $self->{$macro};
+              $npath = "$head\cB$macro\cB$tail";
+              $complex = 1;
+            }
+            else { ($macro = unixify($self->{$macro})) =~ s#/$##; }
             $npath = "$head$macro$tail";
         }
     }
+    if ($complex) { $npath =~ s#\cB(.*?)\cB#\$($1)#g; }
     print "eliminate_macros($path) = |$npath|\n" if $Verbose >= 3;
     $npath;
 }
@@ -451,22 +462,32 @@ sub path {
 
 Follows VMS naming conventions for executable files.
 If the name passed in doesn't exactly match an executable file,
-appends F<.Exe> to check for executable image, and F<.Com> to check
-for DCL procedure.  If this fails, checks F<Sys$System:> for an
-executable file having the name specified.  Finally, appends F<.Exe>
-and checks again.
+appends F<.Exe> (or equivalent) to check for executable image, and F<.Com>
+to check for DCL procedure.  If this fails, checks directories in DCL$PATH
+and finally F<Sys$System:> for an executable file having the name specified,
+with or without the F<.Exe>-equivalent suffix.
 
 =cut
 
 sub maybe_command {
     my($self,$file) = @_;
     return $file if -x $file && ! -d _;
-    return "$file.exe" if -x "$file.exe";
-    return "$file.com" if -x "$file.com";
+    my(@dirs) = ('');
+    my(@exts) = ('',$Config{'exe_ext'},'.exe','.com');
+    my($dir,$ext);
     if ($file !~ m![/:>\]]!) {
-       my($shrfile) = 'Sys$System:' . $file;
-       return $file if -x $shrfile && ! -d _;
-       return "$file.exe" if -x "$shrfile.exe";
+       for (my $i = 0; defined $ENV{"DCL\$PATH;$i"}; $i++) {
+           $dir = $ENV{"DCL\$PATH;$i"};
+           $dir .= ':' unless $dir =~ m%[\]:]$%;
+           push(@dirs,$dir);
+       }
+       push(@dirs,'Sys$System:');
+       foreach $dir (@dirs) {
+           my $sysfile = "$dir$file";
+           foreach $ext (@exts) {
+               return $file if -x "$sysfile$ext" && ! -d _;
+           }
+       }
     }
     return 0;
 }
@@ -509,8 +530,8 @@ sub maybe_command_in_dirs { # $ver is optional argument if looking for perl
 
 =item perl_script (override)
 
-If name passed in doesn't specify a readable file, appends F<.pl> and
-tries again, since it's customary to have file types on all files
+If name passed in doesn't specify a readable file, appends F<.com> or
+F<.pl> and tries again, since it's customary to have file types on all files
 under VMS.
 
 =cut
@@ -518,7 +539,8 @@ under VMS.
 sub perl_script {
     my($self,$file) = @_;
     return $file if -r $file && ! -d _;
-    return "$file.pl" if -r "$file.pl" && ! -d _;
+    return "$file.com" if -r "$file.com";
+    return "$file.pl" if -r "$file.pl";
     return '';
 }
 
@@ -590,8 +612,8 @@ sub constants {
        foreach $def (@defs) {
            next unless $def;
            if ($def =~ s/^-D//) {       # If it was a Unix-style definition
-               $def =~ /='(.*)'$/=$1/;  # then remove shell-protection ''
-               $def =~ /^'(.*)'$/$1/;   # from entire term or argument
+               $def =~ s/='(.*)'$/=$1/;  # then remove shell-protection ''
+               $def =~ s/^'(.*)'$/$1/;   # from entire term or argument
            }
            if ($def =~ /=/) {
                $def =~ s/"/""/g;  # Protect existing " from DCL
@@ -740,7 +762,7 @@ INST_STATIC =
 INST_DYNAMIC =
 INST_BOOT =
 EXPORT_LIST = $(BASEEXT).opt
-PERL_ARCHIVE = ',($ENV{'PERLSHR'} ? $ENV{'PERLSHR'} : 'Sys$Share:PerlShr.Exe'),'
+PERL_ARCHIVE = ',($ENV{'PERLSHR'} ? $ENV{'PERLSHR'} : "Sys\$Share:PerlShr.$Config{'dlext'}"),'
 ';
     }
 
@@ -994,7 +1016,10 @@ sub xsubpp_version
     my $command = "$self->{PERL} \"-I$self->{PERL_LIB}\" $xsubpp -v";
     print "Running: $command\n" if $Verbose;
     $version = `$command` ;
-    warn "Running '$command' exits with status " . $? unless ($? & 1);
+    if ($?) {
+       use vmsish 'status';
+       warn "Running '$command' exits with status $?";
+    }
     chop $version ;
 
     return $1 if $version =~ /^xsubpp version (.*)/ ;
@@ -1281,12 +1306,12 @@ $(BASEEXT).opt : Makefile.PL
        foreach $lib (split ' ', $self->{LDLOADLIBS}) {
            $lib =~ s%\$%\\\$%g;  # Escape '$' in VMS filespecs
            if (length($line) + length($lib) > 160) {
-               push @m, "\t\$(PERL) -e \"print qq[$line]\" >>\$(MMS\$TARGET)\n";
+               push @m, "\t\$(PERL) -e \"print qq{$line}\" >>\$(MMS\$TARGET)\n";
                $line = $lib . '\n';
            }
            else { $line .= $lib . '\n'; }
        }
-       push @m, "\t\$(PERL) -e \"print qq[$line]\" >>\$(MMS\$TARGET)\n" if $line;
+       push @m, "\t\$(PERL) -e \"print qq{$line}\" >>\$(MMS\$TARGET)\n" if $line;
     }
 
     join('',@m);
@@ -1317,7 +1342,7 @@ INST_DYNAMIC_DEP = $inst_dynamic_dep
     push @m, '
 $(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt rtls.opt $(INST_ARCHAUTODIR).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
        $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
-       $(NOECHO) If F$TrnLNm("PerlShr").eqs."" Then Define/NoLog/User PerlShr Sys$Share:PerlShr.Exe
+       $(NOECHO) If F$TrnLNm("PerlShr").eqs."" Then Define/NoLog/User PerlShr Sys$Share:PerlShr.',$Config{'dlext'},'
        Link $(LDFLAGS) /Shareable=$(MMS$TARGET)$(OTHERLDFLAGS) $(BASEEXT).opt/Option,rtls.opt/Option,$(PERL_INC)perlshr_attr.opt/Option
 ';
 
@@ -1383,7 +1408,7 @@ $(INST_STATIC) : $(OBJECT) $(MYEXTLIB)
     push(@m,'
        If F$Search("$(MMS$TARGET)").eqs."" Then Library/Object/Create $(MMS$TARGET)
        Library/Object/Replace $(MMS$TARGET) $(MMS$SOURCE_LIST)
-       $(NOECHO) $(PERL) -e "open F,\'>>$(INST_ARCHAUTODIR)extralibs.ld\';print F qq[$(EXTRALIBS)\n];close F;"
+       $(NOECHO) $(PERL) -e "open F,\'>>$(INST_ARCHAUTODIR)extralibs.ld\';print F qq{$(EXTRALIBS)\n};close F;"
 ');
     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
     join('',@m);
@@ -1559,7 +1584,7 @@ sub subdir_x {
 subdirs ::
        olddef = F$Environment("Default")
        Set Default ',$subdir,'
-       - $(MMS) all $(USEMACROS)$(PASTHRU)$(MACROEND)
+       - $(MMS)$(MMSQUALIFIERS) all $(USEMACROS)$(PASTHRU)$(MACROEND)
        Set Default \'olddef\'
 ';
     join('',@m);
@@ -1584,13 +1609,25 @@ clean ::
     foreach $dir (@{$self->{DIR}}) { # clean subdirectories first
        my($vmsdir) = $self->fixpath($dir,1);
        push( @m, '     If F$Search("'.$vmsdir.'$(MAKEFILE)").nes."" Then \\',"\n\t",
-             '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS) clean`;"',"\n");
+             '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS)$(MMSQUALIFIERS) clean`;"',"\n");
     }
     push @m, ' $(RM_F) *.Map *.Dmp *.Lis *.cpp *.$(DLEXT) *$(OBJ_EXT) *$(LIB_EXT) *.Opt $(BOOTSTRAP) $(BASEEXT).bso .MM_Tmp
 ';
 
     my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
-    push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
+    # Unlink realclean, $attribs{FILES} is a string here; it may contain
+    # a list or a macro that expands to a list.
+    if ($attribs{FILES}) {
+       my($word,$key,@filist);
+       if (ref $attribs{FILES} eq 'ARRAY') { @filist = @{$attribs{FILES}}; }
+       else { @filist = split /\s+/, $attribs{FILES}; }
+       foreach $word (@filist) {
+           if (($key) = $word =~ m#^\$\((.*)\)$# and ref $self->{$key} eq 'ARRAY') {
+               push(@otherfiles, @{$self->{$key}});
+           }
+           else { push(@otherfiles, $attribs{FILES}); }
+       }
+    }
     push(@otherfiles, qw[ blib $(MAKE_APERL_FILE) extralibs.ld perlmain.c pm_to_blib.ts ]);
     push(@otherfiles,$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
     my($file,$line);
@@ -1624,7 +1661,7 @@ realclean :: clean
     foreach(@{$self->{DIR}}){
        my($vmsdir) = $self->fixpath($_,1);
        push(@m, '      If F$Search("'."$vmsdir".'$(MAKEFILE)").nes."" Then \\',"\n\t",
-             '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS) realclean`;"',"\n");
+             '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS)$(MMSQUALIFIERS) realclean`;"',"\n");
     }
     push @m,'  $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
 ';
@@ -1649,9 +1686,18 @@ realclean :: clean
        else { $line .= " $file"; }
     }
     push @m, "\t\$(RM_F) $line\n" if $line;
-    if ($attribs{FILES} && ref $attribs{FILES} eq 'ARRAY') {
+    if ($attribs{FILES}) {
+       my($word,$key,@filist,@allfiles);
+       if (ref $attribs{FILES} eq 'ARRAY') { @filist = @{$attribs{FILES}}; }
+       else { @filist = split /\s+/, $attribs{FILES}; }
+       foreach $word (@filist) {
+           if (($key) = $word =~ m#^\$\((.*)\)$# and ref $self->{$key} eq 'ARRAY') {
+               push(@allfiles, @{$self->{$key}});
+           }
+           else { push(@allfiles, $attribs{FILES}); }
+       }
        $line = '';
-       foreach $file (@{$attribs{'FILES'}}) {
+       foreach $file (@allfiles) {
            $file = $self->fixpath($file);
            if (length($line) + length($file) > 80) {
                push @m, "\t\$(RM_RF) $line\n";
@@ -1681,7 +1727,7 @@ distcheck :
        $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&fullcheck\'; fullcheck()"
 
 skipcheck :
-       $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&fullcheck\'; skipcheck()"
+       $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&skipcheck\'; skipcheck()"
 
 manifest :
        $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&mkmanifest\'; mkmanifest()"
@@ -1756,8 +1802,8 @@ disttest : distdir
        startdir = F$Environment("Default")
        Set Default [.$(DISTVNAME)]
        $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL
-       $(MMS)
-       $(MMS) test
+       $(MMS)$(MMSQUALIFIERS)
+       $(MMS)$(MMSQUALIFIERS) test
        Set Default 'startdir'
 };
 }
@@ -1810,7 +1856,7 @@ pure__install : pure_site_install
        $(NOECHO) $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
 
 doc__install : doc_site_install
-       $(NOECHO} $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
+       $(NOECHO) $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
 
 # This hack brought to you by DCL's 255-character command line limit
 pure_perl_install ::
@@ -1935,7 +1981,14 @@ $(PERL_ARCHLIB)Config.pm : $(PERL_VMS)config.vms $(PERL_VMS)genconfig.pl
        $(NOECHO) Write Sys$Error "$(PERL_ARCHLIB)Config.pm may be out of date with config.vms or genconfig.pl"
        olddef = F$Environment("Default")
        Set Default $(PERL_SRC)
-       $(MMS)],$mmsquals,q[ $(MMS$TARGET)
+       $(MMS)],$mmsquals,);
+       if ($self->{PERL_ARCHLIB} =~ m|\[-| && $self->{PERL_SRC} =~ m|(\[-+)|) {
+           my($prefix,$target) = ($1,$self->fixpath('$(PERL_ARCHLIB)Config.pm'));
+           $target =~ s/\Q$prefix/[/;
+           push(@m," $target");
+       }
+       else { push(@m,' $(MMS$TARGET)'); }
+       push(@m,q[
        Set Default 'olddef'
 ]);
     }
@@ -1969,7 +2022,7 @@ $(MAKEFILE) : Makefile.PL $(CONFIGDEP)
        $(NOECHO) $(SAY) "$(MAKEFILE) out-of-date with respect to $(MMS$SOURCE_LIST)"
        $(NOECHO) $(SAY) "Cleaning current config before rebuilding $(MAKEFILE) ..."
        - $(MV) $(MAKEFILE) $(MAKEFILE)_old
-       - $(MMS) $(USEMAKEFILE)$(MAKEFILE)_old clean
+       - $(MMS)$(MMSQUALIFIERS) $(USEMAKEFILE)$(MAKEFILE)_old clean
        $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL ],join(' ',map(qq["$_"],@ARGV)),q[
        $(NOECHO) $(SAY) "$(MAKEFILE) has been rebuilt."
        $(NOECHO) $(SAY) "Please run $(MMS) to build the extension."
@@ -2004,7 +2057,7 @@ testdb :: testdb_\$(LINKTYPE)
     foreach(@{$self->{DIR}}){
       my($vmsdir) = $self->fixpath($_,1);
       push(@m, '       If F$Search("',$vmsdir,'$(MAKEFILE)").nes."" Then $(PERL) -e "chdir ',"'$vmsdir'",
-           '; print `$(MMS) $(PASTHRU2) test`'."\n");
+           '; print `$(MMS)$(MMSQUALIFIERS) $(PASTHRU2) test`'."\n");
     }
     push(@m, "\t\$(NOECHO) \$(SAY) \"No tests defined for \$(NAME) extension.\"\n")
         unless $tests or -f "test.pl" or @{$self->{DIR}};
@@ -2096,7 +2149,7 @@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
                MAKEAPERL=1 NORECURS=1
 
 $(MAP_TARGET) :: $(MAKE_APERL_FILE)
-       $(MMS)$(USEMAKEFILE)$(MAKE_APERL_FILE) static $(MMS$TARGET)
+       $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKE_APERL_FILE) static $(MMS$TARGET)
 };
        push @m, map( " \\\n\t\t$_", @ARGV );
        push @m, "\n";
@@ -2191,7 +2244,7 @@ $(MAP_TARGET) :: $(MAKE_APERL_FILE)
        }
     }
 
-    $target = "Perl.Exe" unless $target;
+    $target = "Perl$Config{'exe_ext'}" unless $target;
     ($shrtarget,$targdir) = fileparse($target);
     $shrtarget =~ s/^([^.]*)/$1Shr/;
     $shrtarget = $targdir . $shrtarget;
@@ -2242,9 +2295,9 @@ $(MAP_SHRTARGET) : $(MAP_LIBPERL) $(MAP_STATIC) ',"${libperldir}Perlshr_Attr.Opt
 $(MAP_TARGET) : $(MAP_SHRTARGET) ',"${tmp}perlmain\$(OBJ_EXT) ${tmp}PerlShr.Opt",'
        $(MAP_LINKCMD) ',"${tmp}perlmain\$(OBJ_EXT)",', PerlShr.Opt/Option
        $(NOECHO) $(SAY) "To install the new ""$(MAP_TARGET)"" binary, say"
-       $(NOECHO) $(SAY) "    $(MMS)$(USEMAKEFILE)$(MAKEFILE) inst_perl $(USEMACROS)MAP_TARGET=$(MAP_TARGET)$(ENDMACRO)"
+       $(NOECHO) $(SAY) "    $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKEFILE) inst_perl $(USEMACROS)MAP_TARGET=$(MAP_TARGET)$(ENDMACRO)"
        $(NOECHO) $(SAY) "To remove the intermediate files, say
-       $(NOECHO) $(SAY) "    $(MMS)$(USEMAKEFILE)$(MAKEFILE) map_clean"
+       $(NOECHO) $(SAY) "    $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKEFILE) map_clean"
 ';
     push @m,'
 ',"${tmp}perlmain.c",' : $(MAKEFILE)