From baff067e717fe1c071dea706f7425994cc1d4ce9 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 28 Jul 2012 22:48:27 -0700 Subject: [perl #113940] Make make_ext delete Makefiles when version changes This eliminates this annoyance: $ ./perl -Ilib -MStorable -e0 Storable object version 2.37 does not match bootstrap parameter 2.38 at lib/XSLoader.pm line 95. Compilation failed in require. BEGIN failed--compilation aborted. --- make_ext.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'make_ext.pl') diff --git a/make_ext.pl b/make_ext.pl index 28a67a33f9..32546282c0 100644 --- a/make_ext.pl +++ b/make_ext.pl @@ -281,6 +281,28 @@ sub build_extension { $makefile = 'Makefile'; } + if (-f $makefile) { + open my $mfh, $makefile or die "Cannot open $makefile: $!"; + while (<$mfh>) { + # Plagiarised from CPAN::Distribution + last if /MakeMaker post_initialize section/; + next unless /^#\s+VERSION_FROM\s+=>\s+(.+)/; + my $vmod = eval $1; + my $oldv; + while (<$mfh>) { + next unless /^XS_VERSION = (\S+)/; + $oldv = $1; + last; + } + last unless defined $oldv; + require ExtUtils::MM_Unix; + defined (my $newv = parse_version MM $vmod) or last; + if ($newv ne $oldv) { + 1 while unlink $makefile + } + } + } + if (!-f $makefile) { if (!-f 'Makefile.PL') { print "\nCreating Makefile.PL in $ext_dir for $mname\n"; -- cgit v1.2.1