summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-07-28 22:48:27 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-07-29 10:51:30 -0700
commitbaff067e717fe1c071dea706f7425994cc1d4ce9 (patch)
tree2760b0c151e0cc9f6c16a3f0978b7f253abcd6e5
parentd96ab1b5f316fcb0109627c2060d3b7f8a7b5016 (diff)
downloadperl-baff067e717fe1c071dea706f7425994cc1d4ce9.tar.gz
[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.
-rw-r--r--make_ext.pl22
1 files changed, 22 insertions, 0 deletions
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";