develooper Front page | perl.vmsperl | Postings from December 2001

provisional MakeMaker patch for VMS

Thread Next
From:
Craig A. Berry
Date:
December 27, 2001 20:30
Subject:
provisional MakeMaker patch for VMS
Message ID:
a05101004b8515264aa3a@[172.16.52.1]
Change #13880 (replace all the MakeMaker $self->foo calls with 
File::Spec->foo) stopped all builds in their tracks on VMS.  The 
patch at the end of this message gets us building successfully again 
but needs testing on other platforms.

There were two main problems.

1.)  If ExtUtils::MM_VMS no longer inherits from File::Spec, then 
$self->fixpath() and $self->eliminate_macros() are orphaned.  If 
these methods are called directly in File::Spec, then their use of 
the $self object refers to File::Spec rather than MakeMaker, but they 
have to consider themselves part of MakeMasker to work in the context 
of MakeMaker.  I've restored the inheritance.

2.) Under the previous dispensation, $self->catdir was not equivalent 
to File::Spec->catdir but rather to File::Spec::Unix->catdir.  Ditto 
for catfile.  As far as I can see this was true on all platforms 
except Win32, which had its own versions with backward slashes 
instead of forward slashes.  On VMS we needed the old behavior 
because the following order works:

    A. use Unix syntax to concatenate filespecs containing macros
    B.  expand macros
    C.  convert filespecs from Unix to VMS syntax

but the order we are now getting (which doesn't work) is: 

    A.  use native syntax to concatenate filespecs containing macros
    B.  expand macros

Basically you end up seeing things like '[.foo$(DIR).bar]' turned 
into '[.foo[.dir].bar]' and that's not a valid directory spec.

My solution to problem #2 is a bit lame but it's all I could come up 
with after wasting most of a day wrestling with this.  I just used 
trial and error to figure out which macros had the problem and 
replaced them with literal values as in "$self->{FOO}" for "$(FOO)". 
Luckily there weren't very many of these.  I welcome a better 
suggestion if somebody has one.

BTW, on a related note, I wonder why ExtUtils::Liblist wasn't also 
changed to use the File::Spec methods instead of the $self methods?

And the patch, which has only been tested on VMS:


--- lib/ExtUtils/MM_Unix.pm;-0	Mon Dec 24 17:35:05 2001
+++ lib/ExtUtils/MM_Unix.pm	Thu Dec 27 21:12:13 2001
@@ -1442,9 +1442,9 @@
 	    if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
 		($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
 	    }
-	    else { $pm{$name} = File::Spec->catfile('$(INST_LIBDIR)',$name); }
+	    else { $pm{$name} = File::Spec->catfile($self->{INST_LIBDIR},$name); }
 	} elsif ($name =~ /\.(p[ml]|pod)\z/){
-	    $pm{$name} = File::Spec->catfile('$(INST_LIBDIR)',$name);
+	    $pm{$name} = File::Spec->catfile($self->{INST_LIBDIR},$name);
 	}
     }
 
@@ -1500,9 +1500,9 @@
 		return;
 	    }
 	    return if /\#/;
-	    my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
+	    my($path, $prefix) = ($File::Find::name, $self->{INST_LIBDIR});
 	    my($striplibpath,$striplibname);
-	    $prefix =  '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i);
+	    $prefix =  $self->{INST_LIB} if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i);
 	    ($striplibname,$striplibpath) = fileparse($striplibpath);
 	    my($inst) = File::Spec->catfile($prefix,$striplibpath,$striplibname);
 	    local($_) = $inst; # for backwards compatibility
@@ -1791,10 +1791,10 @@
 
     # We need to set up INST_LIBDIR before init_libscan() for VMS
     my @parentdir = split(/::/, $self->{PARENT_NAME});
-    $self->{INST_LIBDIR} = File::Spec->catdir('$(INST_LIB)',@parentdir);
-    $self->{INST_ARCHLIBDIR} = File::Spec->catdir('$(INST_ARCHLIB)',@parentdir);
-    $self->{INST_AUTODIR} = File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)');
-    $self->{INST_ARCHAUTODIR} = File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)');
+    $self->{INST_LIBDIR} = File::Spec->catdir($self->{INST_LIB},@parentdir);
+    $self->{INST_ARCHLIBDIR} = File::Spec->catdir($self->{INST_ARCHLIB},@parentdir);
+    $self->{INST_AUTODIR} = File::Spec->catdir($self->{INST_LIB},'auto',$self->{FULLEXT});
+    $self->{INST_ARCHAUTODIR} = File::Spec->catdir($self->{INST_ARCHLIB},'auto',$self->{FULLEXT});
 
     # INST_EXE is deprecated, should go away March '97
     $self->{INST_EXE} ||= File::Spec->catdir(File::Spec->curdir,'blib','script');
--- lib/ExtUtils/MM_VMS.pm;-0	Mon Dec 24 17:35:05 2001
+++ lib/ExtUtils/MM_VMS.pm	Thu Dec 27 21:14:20 2001
@@ -19,6 +19,7 @@
 # All on one line so MakeMaker can see it.
 ($VERSION) = ($Revision = '5.56 (27-Apr-1999)') =~ /^([\d.]+)/;
 
+@ISA = qw( File::Spec );
 unshift @MM::ISA, 'ExtUtils::MM_VMS';
 
 require ExtUtils::MakeMaker;
@@ -73,7 +74,7 @@
 =cut
 
 sub rootdir {
-    return File::Spec->rootdir();'
+    return File::Spec->rootdir();
 }
 
 package ExtUtils::MM_VMS;
@@ -803,7 +804,7 @@
 sub pm_to_blib {
     my($self) = @_;
     my($line,$from,$to,@m);
-    my($autodir) = File::Spec->catdir('$(INST_LIB)','auto');
+    my($autodir) = File::Spec->catdir($self->{INST_LIB},'auto');
     my(@files) = @{$self->{PM_TO_BLIB}};
 
     push @m, q{
[end of patch]

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About