From: Steve Hay Date: Tue, 29 Sep 2009 14:41:06 +0000 (+0100) Subject: Fix distclean on Win32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a85e0e8cf88042961f6f69a4f64e20f985d31654;p=p5sagit%2Fp5-mst-13.2.git Fix distclean on Win32 nmake realclean in the Encode sub-dirs didn't work because it needed an extra ../ on the relative paths in @INC. Make the paths absolute instead. nmake realclean in DynaLoader didn't work either because it tried to make DynaLoader.c... three times. Move the loop over @ext out of the loop over @dirs to fix the repetitions, but don't add DynaLoader.c anyway when just making a 'clean' target. Also clean up the XSLoader.pm that gets left behind. --- diff --git a/make_ext.pl b/make_ext.pl index b1980a5..e272d5b 100644 --- a/make_ext.pl +++ b/make_ext.pl @@ -3,9 +3,10 @@ use strict; use warnings; use Config; BEGIN { - unshift @INC, $^O eq 'MSWin32' ? '../cpan/Cwd' : 'cpan/Cwd'; + unshift @INC, $^O eq 'MSWin32' ? ('../cpan/Cwd', '../cpan/Cwd/lib') : 'cpan/Cwd'; } use Cwd; +use File::Spec::Functions qw(rel2abs); # To clarify, this isn't the entire suite of modules considered "toolchain" # It's not even all modules needed to build ext/ @@ -179,35 +180,36 @@ if ($is_Win32) { (my $ext = getcwd()) =~ s{/}{\\}g; FindExt::scan_ext($ext); FindExt::set_static_extensions(split ' ', $Config{static_ext}); + chdir $build + or die "Couldn't chdir to '$build': $!"; # restore our start directory + } - my @ext; - push @ext, FindExt::static_ext() if $static; - push @ext, FindExt::dynamic_ext() if $dynamic; - push @ext, FindExt::nonxs_ext() if $nonxs; - push @ext, 'DynaLoader' if $dynaloader; + my @ext; + push @ext, FindExt::static_ext() if $static; + push @ext, FindExt::dynamic_ext() if $dynamic; + push @ext, FindExt::nonxs_ext() if $nonxs; + push @ext, 'DynaLoader' if $dynaloader; - foreach (sort @ext) { - if (%incl and !exists $incl{$_}) { - #warn "Skipping extension $ext\\$_, not in inclusion list\n"; - next; - } - if (exists $excl{$_}) { - warn "Skipping extension $ext\\$_, not ported to current platform"; - next; - } - push @extspec, $_; - if($_ eq 'DynaLoader') { - # No, we don't know why nmake can't work out the dependency chain - push @{$extra_passthrough{$_}}, 'DynaLoader.c'; - } elsif(FindExt::is_static($_)) { - push @{$extra_passthrough{$_}}, 'LINKTYPE=static'; - } + foreach (sort @ext) { + if (%incl and !exists $incl{$_}) { + #warn "Skipping extension $_, not in inclusion list\n"; + next; + } + if (exists $excl{$_}) { + warn "Skipping extension $_, not ported to current platform"; + next; + } + push @extspec, $_; + if($_ eq 'DynaLoader' and $target !~ /clean$/) { + # No, we don't know why nmake can't work out the dependency chain + push @{$extra_passthrough{$_}}, 'DynaLoader.c'; + } elsif(FindExt::is_static($_)) { + push @{$extra_passthrough{$_}}, 'LINKTYPE=static'; } - chdir $build - or die "Couldn't chdir to '$build': $!"; # restore our start directory } + chdir '..' - or die "Couldn't chdir to build directory: $!"; # now in the Perl build directory + or die "Couldn't chdir to build directory: $!"; # now in the Perl build } elsif ($is_VMS) { $perl = $^X; @@ -271,6 +273,11 @@ foreach my $spec (@extspec) { sub build_extension { my ($ext_dir, $perl, $mname, $pass_through) = @_; + unless (chdir "$ext_dir") { + warn "Cannot cd to $ext_dir: $!"; + return; + } + my $up = $ext_dir; $up =~ s![^/]+!..!g; @@ -280,14 +287,13 @@ sub build_extension { # $lib_dir must be last, as we're copying files into it, and in a parallel # make there's a race condition if one process tries to open a module that # another process has half-written. - $ENV{PERL5LIB} - = join $Config{path_sep}, (map {"$up/$_"} @toolchain), $lib_dir; + my @new_inc = ((map {"$up/$_"} @toolchain), $lib_dir); + if ($is_Win32) { + @new_inc = map {rel2abs($_)} @new_inc; + } + $ENV{PERL5LIB} = join $Config{path_sep}, @new_inc; $ENV{PERL_CORE} = 1; - unless (chdir "$ext_dir") { - warn "Cannot cd to $ext_dir: $!"; - return; - } my $makefile; if ($is_VMS) { $makefile = 'descrip.mms'; diff --git a/win32/Makefile b/win32/Makefile index 3459014..e59bbe1 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -1152,6 +1152,7 @@ distclean: realclean -del /f $(LIBDIR)\Win32CORE.pm -del /f $(LIBDIR)\Win32API\File.pm -del /f $(LIBDIR)\Win32API\File\cFile.pc + -del /f $(DISTDIR)\XSLoader\XSLoader.pm -if exist $(LIBDIR)\B rmdir /s /q $(LIBDIR)\B -if exist $(LIBDIR)\Compress rmdir /s /q $(LIBDIR)\Compress -if exist $(LIBDIR)\Data rmdir /s /q $(LIBDIR)\Data diff --git a/win32/makefile.mk b/win32/makefile.mk index 3dc0fe5..04d7143 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -1485,6 +1485,7 @@ distclean: realclean -del /f $(LIBDIR)\Win32CORE.pm -del /f $(LIBDIR)\Win32API\File.pm -del /f $(LIBDIR)\Win32API\File\cFile.pc + -del /f $(DISTDIR)\XSLoader\XSLoader.pm -if exist $(LIBDIR)\B rmdir /s /q $(LIBDIR)\B -if exist $(LIBDIR)\Compress rmdir /s /q $(LIBDIR)\Compress -if exist $(LIBDIR)\Data rmdir /s /q $(LIBDIR)\Data