1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-2.0-only
## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved.
# code stolen from Perl 5.004_04's ExtUtils::Embed because
# this module is only available in newer Perl versions.
use Config;
sub static_ext {
unless (scalar @Extensions) {
@Extensions = sort split /\s+/, $Config{static_ext};
unshift @Extensions, qw(DynaLoader);
}
return @Extensions;
}
sub xsi_body {
my(@exts) = @_;
my($pname,@retval,%seen);
my($dl) = canon('DynaLoader');
foreach $_ (@exts){
my($pname) = canon($_);
my($mname, $cname, $ccode);
($mname = $pname) =~ s!/!::!g;
($cname = $pname) =~ s!/!__!g;
if ($pname eq $dl){
$ccode = "newXS(\"${mname}::boot_${cname}\", boot_${cname}, __FILE__); ";
} else {
$ccode = "newXS(\"${mname}::bootstrap\", boot_${cname}, __FILE__); ";
}
push(@retval, $ccode) unless $seen{$ccode}++;
}
return join '', @retval;
}
sub canon {
my(@ext) = @_;
foreach(@ext) {
# might be X::Y or lib/auto/X/Y/Y.a
next if s!::!/!g;
s:^(lib|ext)/(auto/)?::;
s:/\w+\.\w+$::;
}
return @ext;
}
@mods = ();
push(@mods, static_ext());
@mods = grep(!$seen{$_}++, @mods);
print xsi_body(@mods);
|