This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta for changes to perlexperiment
[perl5.git] / make_ext.pl
index 28a67a3..799ab8b 100644 (file)
@@ -43,7 +43,7 @@ my $ext_dirs_re = '(?:' . join('|', @ext_dirs) . ')';
 # Mostly because they still not ported to specified platform.
 # 
 # If any extensions are listed with a '+' char then only those
-# extensions will be built, but only if they arent countermanded
+# extensions will be built, but only if they aren't countermanded
 # by an '!ext' and are appropriate to the type of building being done.
 
 # It may be deleted in a later release of perl so try to
@@ -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";