[PATCH 5.004_60] Fix to MM_VMS.PM
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_VMS.pm
index aca41ea..954f612 100644 (file)
@@ -36,6 +36,8 @@ the semantics.
 
 =head2 Methods always loaded
 
+=over
+
 =item eliminate_macros
 
 Expands MM[KS]/Make macros in a text string, using the contents of
@@ -94,7 +96,7 @@ sub fixpath {
     }
     my($fixedpath,$prefix,$name);
 
-    if ($path =~ m#^\$\(.+\)$# || $path =~ m#[/:>\]]#) { 
+    if ($path =~ m#^\$\([^\)]+\)$# || $path =~ m#[/:>\]]#) { 
         if ($force_path or $path =~ /(?:DIR\)|\])$/) {
             $fixedpath = vmspath($self->eliminate_macros($path));
         }
@@ -103,7 +105,9 @@ sub fixpath {
         }
     }
     elsif ((($prefix,$name) = ($path =~ m#^\$\(([^\)]+)\)(.+)#)) && $self->{$prefix}) {
-        my($vmspre) = vmspath($self->eliminate_macros("\$($prefix)")) || ''; # is it a dir or just a name?
+        my($vmspre) = $self->eliminate_macros("\$($prefix)");
+        # is it a dir or just a name?
+        $vmspre = ($vmspre =~ m|/| or $prefix =~ /DIR$/) ? vmspath($vmspre) : '';
         $fixedpath = ($vmspre ? $vmspre : $self->{$prefix}) . $name;
         $fixedpath = vmspath($fixedpath) if $force_path;
     }
@@ -312,6 +316,7 @@ sub ext {
   ExtUtils::Liblist::ext(@_);
 }
 
+=back
 
 =head2 SelfLoaded methods
 
@@ -321,6 +326,8 @@ For overridden methods, documentation is limited to an explanation
 of why this method overrides the MM_Unix method; see the ExtUtils::MM_Unix
 documentation for more details.
 
+=over
+
 =item guess_name (override)
 
 Try to determine name of extension being built.  We begin with the name
@@ -1046,7 +1053,10 @@ EOM
     $command = "$self->{PERL} $xsubpp $file";
     print "Running: $command\n" if $Verbose;
     my $text = `$command` ;
-    warn "Running '$command' exits with status " . $? unless ($? & 1);
+    if ($?) {
+       use vmsish 'status';
+       warn "Running '$command' exits with status $?";
+    }
     unlink $file ;
 
     # gets 1.2 -> 1.92 and 2.000a1
@@ -1111,12 +1121,17 @@ default MM_Unix method.
 sub dist {
     my($self, %attribs) = @_;
     $attribs{VERSION}      ||= $self->{VERSION_SYM};
+    $attribs{NAME}         ||= $self->{DISTNAME};
     $attribs{ZIPFLAGS}     ||= '-Vu';
     $attribs{COMPRESS}     ||= 'gzip';
     $attribs{SUFFIX}       ||= '-gz';
     $attribs{SHAR}         ||= 'vms_share';
     $attribs{DIST_DEFAULT} ||= 'zipdist';
 
+    # Sanitize these for use in $(DISTVNAME) filespec
+    $attribs{VERSION} =~ s/[^\w\$]/_/g;
+    $attribs{NAME} =~ s/[^\w\$]/_/g;
+
     return ExtUtils::MM_Unix::dist($self,%attribs);
 }
 
@@ -1407,7 +1422,21 @@ $(INST_STATIC) : $(OBJECT) $(MYEXTLIB)
 
     push(@m,'
        If F$Search("$(MMS$TARGET)").eqs."" Then Library/Object/Create $(MMS$TARGET)
+');
+    # if there was a library to copy, then we can't use MMS$SOURCE_LIST,
+    # 'cause it's a library and you can't stick them in other libraries.
+    # In that case, we use $OBJECT instead and hope for the best
+    if ($self->{MYEXTLIB}) {
+      push(@m,'
+       Library/Object/Replace $(MMS$TARGET) $(OBJECT)
+'); 
+    } else {
+      push(@m,'
        Library/Object/Replace $(MMS$TARGET) $(MMS$SOURCE_LIST)
+'); 
+    }
+    
+    push(@m, '
        $(NOECHO) $(PERL) -e "open F,\'>>$(INST_ARCHAUTODIR)extralibs.ld\';print F qq{$(EXTRALIBS)\n};close F;"
 ');
     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
@@ -1745,28 +1774,28 @@ sub dist_core {
     my($self) = @_;
 q[
 dist : $(DIST_DEFAULT)
-       $(NOECHO) $(PERL) -le "print 'Warning: $m older than $vf' if -e ($vf = '$(VERSION_FROM)') && -M $vf < -M ($m = '$(MAKEFILE)'"
+       $(NOECHO) $(PERL) -le "print 'Warning: $m older than $vf' if -e ($vf = '$(VERSION_FROM)') && -M $vf < -M ($m = '$(MAKEFILE)')"
 
 zipdist : $(DISTVNAME).zip
        $(NOECHO) $(NOOP)
 
 $(DISTVNAME).zip : distdir
        $(PREOP)
-       $(ZIP) "$(ZIPFLAGS)" $(MMS$TARGET) $(SRC)
+       $(ZIP) "$(ZIPFLAGS)" $(MMS$TARGET) [.$(DISTVNAME)...]*.*;
        $(RM_RF) $(DISTVNAME)
        $(POSTOP)
 
 $(DISTVNAME).tar$(SUFFIX) : distdir
        $(PREOP)
        $(TO_UNIX)
-       $(TAR) "$(TARFLAGS)" $(DISTVNAME).tar $(SRC)
+       $(TAR) "$(TARFLAGS)" $(DISTVNAME).tar [.$(DISTVNAME)]
        $(RM_RF) $(DISTVNAME)
        $(COMPRESS) $(DISTVNAME).tar
        $(POSTOP)
 
 shdist : distdir
        $(PREOP)
-       $(SHARE) $(SRC) $(DISTVNAME).share
+       $(SHAR) [.$(DISTVNAME...]*.*; $(DISTVNAME).share
        $(RM_RF) $(DISTVNAME)
        $(POSTOP)
 ];
@@ -1889,11 +1918,10 @@ pure_site_install ::
 # Ditto
 doc_perl_install ::
        $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLPRIVLIB)|'" >.MM_tmp
-       $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|'" >>.MM_tmp
-       $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|'" >>.MM_tmp
+       $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES)|'" >>.MM_tmp
 ],@docfiles,
 q%     $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp
-       $(NOECHO) $(PERL) -e "print q[print '=head3 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
+       $(NOECHO) $(PERL) -e "print q[print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
        $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp
        $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp
        $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
@@ -1902,11 +1930,10 @@ q%      $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp
 # And again
 doc_site_install ::
        $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLSITELIB)|'" >.MM_tmp
-       $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|'" >>.MM_tmp
-       $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|'" >>.MM_tmp
+       $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES)|'" >>.MM_tmp
 ],@docfiles,
 q%     $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp
-       $(NOECHO) $(PERL) -e "print q[print '=head3 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
+       $(NOECHO) $(PERL) -e "print q[print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
        $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp
        $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp
        $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
@@ -2353,5 +2380,9 @@ sub nicetext {
 
 1;
 
+=back
+
+=cut
+
 __END__