develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH 5.7.2] MakeMaker subdir

From:
Ilya Zakharevich
Date:
July 23, 2001 15:33
Subject:
[PATCH 5.7.2] MakeMaker subdir
Message ID:
20010723183316.A14298@math.ohio-state.edu
MakeMaker is often called with relative paths in @INC (see
ext/utils/make_ext), it does a lot of just-in-time require(), *and*
chdir()s to subdirectories to eval the subdir's Makefile.PLs.

The first chunk fixes this deadly combination.  The second chunk makes
WriteEmptyMakefile() grant the {FIRST_,}MAKEFILE parameter.

Enjoy,
Ilya

--- ./lib/ExtUtils/MakeMaker.pm-ini	Sat Jun 16 12:20:40 2001
+++ ./lib/ExtUtils/MakeMaker.pm	Sun Jul 22 14:51:08 2001
@@ -150,8 +150,9 @@ sub prompt ($;$) {
 sub eval_in_subdirs {
     my($self) = @_;
     my($dir);
-    use Cwd 'cwd';
+    use Cwd qw(cwd abs_path);
     my $pwd = cwd();
+    local @INC = map abs_path($_), @INC;
 
     foreach $dir (@{$self->{DIR}}){
 	my($abs) = $self->catdir($pwd,$dir);
@@ -520,14 +523,20 @@ END
 }
 
 sub WriteEmptyMakefile {
-  if (-f 'Makefile.old') {
-    chmod 0666, 'Makefile.old';
-    unlink 'Makefile.old' or warn "unlink Makefile.old: $!";
-  }
-  rename 'Makefile', 'Makefile.old' or warn "rename Makefile Makefile.old: $!"
-    if -f 'Makefile';
-  open MF, '> Makefile' or die "open Makefile for write: $!";
-  print MF <<'EOP';
+    Carp::croak "WriteEmptyMakefile: Need even number of args" if @_ % 2;
+    local $SIG{__WARN__} = \&warnhandler;
+
+    my %att = @_;
+    my $self = MM->new(\%att);
+    if (-f "$self->{MAKEFILE}.old") {
+      chmod 0666, "$self->{MAKEFILE}.old";
+      unlink "$self->{MAKEFILE}.old" or warn "unlink $self->{MAKEFILE}.old: $!";
+    }
+    rename $self->{MAKEFILE}, "$self->{MAKEFILE}.old"
+      or warn "rename $self->{MAKEFILE} $self->{MAKEFILE}.old: $!"
+        if -f $self->{MAKEFILE};
+    open MF, '>', $self->{MAKEFILE} or die "open $self->{MAKEFILE} for write: $!";
+    print MF <<'EOP';
 all:
 
 clean:
@@ -539,7 +548,7 @@ makemakerdflt:
 test:
 
 EOP
-  close MF or die "close Makefile for write: $!";
+    close MF or die "close $self->{MAKEFILE} for write: $!";
 }
 
 sub check_manifest {



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