Re: Net::SMTP can't send large messages with bleadperl
[p5sagit/p5-mst-13.2.git] / win32 / buildext.pl
index 0ae9f74..7578669 100644 (file)
@@ -4,7 +4,7 @@ buildext.pl - build extensions
 
 =head1 SYNOPSIS
 
-    buildext.pl make [-make_opts] dep directory [target] [--static|--dynamic] !ext1 !ext2
+    buildext.pl make [-make_opts] dep directory [target] [--static|--dynamic] +ext2 !ext1
 
 E.g.
 
@@ -19,6 +19,10 @@ E.g.
 Will skip building extensions which are marked with an '!' char.
 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
+by an '!ext' and are appropriate to the type of building being done.
+
 If '--static' specified, only static extensions will be built.
 If '--dynamic' specified, only dynamic extensions will be built.
 
@@ -29,7 +33,6 @@ If '--dynamic' specified, only dynamic extensions will be built.
 
 =cut
 
-use File::Basename;
 use Cwd;
 use FindExt;
 use Config;
@@ -37,6 +40,9 @@ use Config;
 # @ARGV with '!' at first position are exclusions
 my %excl = map {$_=>1} map {/^!(.*)$/} @ARGV;
 @ARGV = grep {!/^!/} @ARGV;
+# @ARGV with '+' at first position are inclusions
+my %incl = map {$_=>1} map {/^\+(.*)$/} @ARGV;
+@ARGV = grep {!/^\+/} @ARGV;
 
 # --static/--dynamic
 my %opts = map {$_=>1} map {/^--([\w\-]+)$/} @ARGV;
@@ -46,18 +52,17 @@ if ("$static,$dynamic" eq "0,0") {
   ($static,$dynamic) = (1,1);
 }
 if ($opts{'list-static-libs'} || $opts{'create-perllibst-h'}) {
-  my @statics = grep{!/^DynaLoader$/} split /\s+/, $Config{static_ext};
+  my @statics = split /\s+/, $Config{static_ext};
   if ($opts{'create-perllibst-h'}) {
-    # at moment of creation of perllibst.h no luck consulting Config.pm,
-    # so list of static extensions passed with @ARGV
-    @statics = grep{!/^DynaLoader$/} @ARGV;
-    open my $fh, ">perllibst.h";
+    open my $fh, ">perllibst.h"
+        or die "Failed to write to perllibst.h:$!";
     my @statics1 = map {local $_=$_;s/\//__/g;$_} @statics;
     my @statics2 = map {local $_=$_;s/\//::/g;$_} @statics;
     print $fh "/*DO NOT EDIT\n  this file is included from perllib.c to init static extensions */\n";
     print $fh "#ifdef STATIC1\n",(map {"    \"$_\",\n"} @statics),"#undef STATIC1\n#endif\n";
     print $fh "#ifdef STATIC2\n",(map {"    EXTERN_C void boot_$_ (pTHX_ CV* cv);\n"} @statics1),"#undef STATIC2\n#endif\n";
     print $fh "#ifdef STATIC3\n",(map {"    newXS(\"$statics2[$_]::bootstrap\", boot_$statics1[$_], file);\n"} 0 .. $#statics),"#undef STATIC3\n#endif\n";
+    close $fh;
   }
   else {
     my %extralibs;
@@ -65,10 +70,10 @@ if ($opts{'list-static-libs'} || $opts{'create-perllibst-h'}) {
       open my $fh, "<..\\lib\\auto\\$_\\extralibs.ld" or die "can't open <..\\lib\\auto\\$_\\extralibs.ld: $!";
       $extralibs{$_}++ for grep {/\S/} split /\s+/, join '', <$fh>;
     }
-    print map {/([^\/]+)$/;"..\\lib\\auto\\$_/$1.lib "} @statics;
+    print map {s|/|\\|g;m|([^\\]+)$|;"..\\lib\\auto\\$_\\$1$Config{_a} "} @statics;
     print map {"$_ "} sort keys %extralibs;
   }
-  exit;
+  exit(0);
 }
 
 my $here = getcwd();
@@ -98,15 +103,19 @@ my $targ  = shift;
 (my $ext = getcwd()) =~ s,/,\\,g;
 my $code;
 FindExt::scan_ext($ext);
+FindExt::set_static_extensions(split ' ', $Config{static_ext}) if $ext ne "ext";
 
-my @ext = FindExt::extensions();
-my %static_exts = map {$_=>1} split /\s+/, $Config{static_ext};
+my @ext;
+push @ext, FindExt::static_ext() if $static;
+push @ext, FindExt::dynamic_ext(), FindExt::nonxs_ext() if $dynamic;
 
-if ("$static$dynamic" eq "01") {@ext = grep {!exists $static_exts{$_}} @ext}
-elsif ("$static$dynamic" eq "10") {@ext = grep {exists $static_exts{$_}} @ext}
 
 foreach $dir (sort @ext)
  {
+  if (%incl and !exists $incl{$dir}) {
+    #warn "Skipping extension $ext\\$dir, not in inclusion list\n";
+    next;
+  }
   if (exists $excl{$dir}) {
     warn "Skipping extension $ext\\$dir, not ported to current platform";
     next;
@@ -119,7 +128,8 @@ foreach $dir (sort @ext)
       print "\nRunning Makefile.PL in $dir\n";
       my @perl = ($perl, "-I$here\\..\\lib", 'Makefile.PL',
                   'INSTALLDIRS=perl', 'PERL_CORE=1',
-                 ($static_exts{$dir}?('LINKTYPE=static'):()), # if ext is static
+                 (FindExt::is_static($dir)
+                   ? ('LINKTYPE=static') : ()), # if ext is static
                );
       if (defined $::Cross::platform) {
        @perl = (@perl[0,1],"-MCross=$::Cross::platform",@perl[2..$#perl]);