diff options
author | Vadim Konovalov <vkonovalov@lucent.com> | 2004-10-12 02:57:00 +0400 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2004-10-12 13:02:44 +0000 |
commit | d2b2597412218806baa0430cf97cc8334ac3ec71 (patch) | |
tree | 1385982f3c73ab987dad0b15eecc442442c570d7 /win32/buildext.pl | |
parent | 2d2b274444abe9850378c8466aa976c778ccebb2 (diff) | |
download | perl-d2b2597412218806baa0430cf97cc8334ac3ec71.tar.gz |
enable statically linked extensions for Win32
Message-ID: <80173417046.20041011225700@vkonovalov.ru>
p4raw-id: //depot/perl@23360
Diffstat (limited to 'win32/buildext.pl')
-rw-r--r-- | win32/buildext.pl | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/win32/buildext.pl b/win32/buildext.pl index 65b79beb94..50fe4c1d97 100644 --- a/win32/buildext.pl +++ b/win32/buildext.pl @@ -4,7 +4,7 @@ buildext.pl - build extensions =head1 SYNOPSIS - buildext.pl make [-make_opts] dep directory [target] !ext1 !ext2 + buildext.pl make [-make_opts] dep directory [target] [--static|--dynamic] !ext1 !ext2 E.g. @@ -19,16 +19,52 @@ E.g. Will skip building extensions which are marked with an '!' char. Mostly because they still not ported to specified platform. +If '--static' specified, only static extensions will be built. +If '--dynamic' specified, only dynamic extensions will be built. + +--create-perllibst-h + creates perllibst.h file for inclusion from perllib.c +--list-static-libs: + prints libraries for static linking and exits + =cut use File::Basename; use Cwd; use FindExt; +use Config; # @ARGV with '!' at first position are exclusions my %excl = map {$_=>1} map {/^!(.*)$/} @ARGV; @ARGV = grep {!/^!/} @ARGV; +# --static/--dynamic +my %opts = map {$_=>1} map {/^--([\w\-]+)$/} @ARGV; +@ARGV = grep {!/^--([\w\-]+)$/} @ARGV; +my ($static,$dynamic) = ((exists $opts{static}?1:0),(exists $opts{dynamic}?1:0)); +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}; + 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"; + 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"; + } + else { + print map {/([^\/]+)$/;"$_/$1.lib "} @statics; + } + exit; +} + my $here = getcwd(); my $perl = $^X; $here =~ s,/,\\,g; @@ -58,8 +94,12 @@ my $code; FindExt::scan_ext($ext); my @ext = FindExt::extensions(); +my %static_exts = map {$_=>1} split /\s+/, $Config{static_ext}; + +if ("$static$dynamic" eq "01") {@ext = grep {!exists $static_exts{$_}} @ext} +elsif ("$static$dynamic" eq "10") {@ext = grep {exists $static_exts{$_}} @ext} -foreach my $dir (sort @ext) +foreach $dir (sort @ext) { if (exists $excl{$dir}) { warn "Skipping extension $ext\\$dir, not ported to current platform"; @@ -72,13 +112,15 @@ foreach my $dir (sort @ext) { print "\nRunning Makefile.PL in $dir\n"; my @perl = ($perl, "-I$here\\..\\lib", 'Makefile.PL', - 'INSTALLDIRS=perl', 'PERL_CORE=1'); + 'INSTALLDIRS=perl', 'PERL_CORE=1', + ($static_exts{$dir}?('LINKTYPE=static'):()), # if ext is static + ); 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; + warn "$code from $dir\'s Makefile.PL" if $code; $mmod = -M 'Makefile'; if ($mmod > $dmod) { |