This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
resurrect change#19628 and make it work by generalizing
[perl5.git] / win32 / buildext.pl
index 59935ac..65b79be 100644 (file)
@@ -4,7 +4,7 @@ buildext.pl - build extensions
 
 =head1 SYNOPSIS
 
-    buildext.pl make [-make_opts] dep directory [target]
+    buildext.pl make [-make_opts] dep directory [target] !ext1 !ext2
 
 E.g.
 
@@ -16,11 +16,19 @@ E.g.
 
     buildext.pl dmake perldll.def ..\ext clean
 
+Will skip building extensions which are marked with an '!' char.
+Mostly because they still not ported to specified platform.
+
 =cut
 
 use File::Basename;
 use Cwd;
 use FindExt;
+
+# @ARGV with '!' at first position are exclusions
+my %excl = map {$_=>1} map {/^!(.*)$/} @ARGV;
+@ARGV = grep {!/^!/} @ARGV;
+
 my $here = getcwd();
 my $perl = $^X;
 $here =~ s,/,\\,g;
@@ -28,6 +36,16 @@ if ($perl =~ m#^\.\.#)
  {
   $perl = "$here\\$perl";
  }
+(my $topdir = $perl) =~ s/\\[^\\]+$//;
+# miniperl needs to find perlglob and pl2bat
+$ENV{PATH} = "$topdir;$topdir\\win32\\bin;$ENV{PATH}";
+#print "PATH=$ENV{PATH}\n";
+my $pl2bat = "$topdir\\win32\\bin\\pl2bat";
+unless (-f "$pl2bat.bat") {
+    my @args = ($perl, ("$pl2bat.pl") x 2);
+    print "@args\n";
+    system(@args) unless defined $::Cross::platform;
+}
 my $make = shift;
 $make .= " ".shift while $ARGV[0]=~/^-/;
 my $dep  = shift;
@@ -36,20 +54,30 @@ my $dir  = shift;
 chdir($dir) || die "Cannot cd to $dir\n";
 my $targ  = shift;
 (my $ext = getcwd()) =~ s,/,\\,g;
+my $code;
 FindExt::scan_ext($ext);
 
 my @ext = FindExt::extensions();
 
 foreach my $dir (sort @ext)
  {
+  if (exists $excl{$dir}) {
+    warn "Skipping extension $ext\\$dir, not ported to current platform";
+    next;
+  }
   if (chdir("$ext\\$dir"))
    {
     my $mmod = -M 'Makefile';
     if (!(-f 'Makefile') || $mmod > $dmod)
      {
       print "\nRunning Makefile.PL in $dir\n";
-      print "$perl \"-I$here\\..\\lib\" Makefile.PL INSTALLDIRS=perl\n";
-      my $code = system($perl,"-I$here\\..\\lib",'Makefile.PL','INSTALLDIRS=perl');
+      my @perl = ($perl, "-I$here\\..\\lib", 'Makefile.PL',
+                  'INSTALLDIRS=perl', 'PERL_CORE=1');
+      if (defined $::Cross::platform) {
+       @perl = (@perl[0,1],"-MCross=$::Cross::platform",@perl[2..$#perl]);
+      }
+      print join(' ', @perl), "\n";
+      $code = system(@perl);
       warn "$code from $dir's Makefile.PL" if $code;
       $mmod = -M 'Makefile';
       if ($mmod > $dmod)
@@ -60,12 +88,14 @@ foreach my $dir (sort @ext)
     if ($targ)
      {
       print "Making $targ in $dir\n$make $targ\n";
-      system($make,$targ);
+      $code = system("$make $targ");
+      die "Unsuccessful make($dir): code=$code" if $code!=0;
      }
     else
      {
       print "Making $dir\n$make\n";
-      system($make);
+      $code = system($make);
+      die "Unsuccessful make($dir): code=$code" if $code!=0;
      }
     chdir($here) || die "Cannot cd to $here:$!";
    }