B-C
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use strict;
use ExtUtils::MakeMaker;
use Config;
use File::Spec;
use 5.006;
use Carp;
if ($Config{d_cplusplus}) {
# ByteLoader/Bytecode can but don't bother
print "error B-C cannot yet be compiled with C++\n";
exit(1);
}
my $CORE = $ENV{PERL_CORE} || grep { $_ eq 'PERL_CORE=1' } @ARGV;
mkdir "lib/B/C" unless -d "lib/B/C";
unless (-e 'lib/B/C/Config.pm') {
open PH, ">", "lib/B/C/Config.pm";
print PH "package B::C::Config;\n\n";
print PH "\n1;\n";
close PH;
chmod 0644, "lib/B/C/Config.pm";
}
# my $X = $^X =~ / / ? qq("$^X") : $^X;
if ($CORE) {
$ENV{PERL_CORE} = 1;
system($^X,"-I".File::Spec->catfile(qw(.. .. lib)),
"-I".File::Spec->catfile(qw(.. .. regen)),
"bytecode.pl");
} else {
my $asmdata = File::Spec->catfile('lib', 'B', 'Asmdata.pm');
# generate lib/B/Asmdata.pm
unlink $asmdata if -f $asmdata;
system($^X, "bytecode.pl");
}
my ($use_declare_independent_comalloc, $extra_cflags, $extra_libs) = (0, "", "");
my $have_independent_comalloc = check_independent_comalloc();
if (grep { $_ eq 'INSTALL_PTMALLOC3' } @ARGV) {
install_independent_comalloc() ;
$have_independent_comalloc = check_independent_comalloc();
}
my $have_op_rettype = check_op_rettype();
my $have_HEK_STATIC = check_hek_static();
{
my ($e_c) = grep { /-extra-cflags[= ](.+)/ } @ARGV;
my ($e_l) = grep { /-extra-libs[= ](.+)/ } @ARGV;
$extra_cflags .= " $e_c" if $e_c;
$extra_libs .= " $e_l" if $e_l;
}
# cygwin still has the old gdb-6 debugger which does not understand dwarf4 features from gcc-4.5
#if ($Config{gccversion} =~ /^4\.[56]\./) {
# my $gdb_ver = `gdb --version`;
# if ($gdb_ver =~ /gdb 6\./) {
# print "Adding extra_cflags=-gstrict-dwarf for gcc-4.5 for a gdb-6 debugger which does not understand dwarf4 features\n";
# $extra_cflags .= " -gstrict-dwarf";
# }
#}
my $have_byteloader = $] < 5.022 ? 1 : check_byteloader();
# does not work with miniperl
sub b_c_deps {
my $X = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
my $blib = "-I".File::Spec->catfile(qw(.. .. lib auto))
." -I".File::Spec->catfile(qw(.. .. lib));
my $runperl = $X . ($CORE ? ' '.$blib : "");
return "AnyDBM_File AutoLoader B B::AV B::Asmdata B::BINOP B::BM B::C B::C::Config B::C::InitSection B::C::Section B::CC B::COP B::CV B::FAKEOP B::FM B::GV B::HE B::HV B::INVLIST B::IO B::IV B::LEXWARN B::LISTOP B::LOGOP B::LOOP B::MAGIC B::METHO...
return `$runperl -Ilib -mB::C -mO -MB -e"B::C::collect_deps()"`;
}
# does not work with miniperl
sub write_b_c_config {
my $version = shift;
mkdir "lib/B/C" unless -d "lib/B/C";
my $b_c_deps = b_c_deps();
$b_c_deps .= " Socket" if $] > 5.021;
open PH, ">", "lib/B/C/Config.pm";
print PH "# written by B::C Makefile.PL. \$extra_{cflags,libs} need a leading space if used.\n";
print PH "package B::C::Config;\n\n";
my $devnull = $^O eq 'MSWin32' ? 'NUL' : '/dev/null';
print PH "\$VERSION = '$version';\n";
Makefile.PL view on Meta::CPAN
print PH "\$B::C::REVISION = '$REV';\n\n";
}
print PH "# -fav-init optimization\n";
print PH "\$have_independent_comalloc = $have_independent_comalloc;\n";
print PH "\$use_declare_independent_comalloc = $use_declare_independent_comalloc;\n\n";
print PH "# broken or patched upstream 5.22 ByteLoader. undef for yet undecided\n";
$have_byteloader = 0 if $Config{usecperl}; # have it, but still broken
print PH "\$have_byteloader = $have_byteloader;\n";
print PH "# since cperl 5.22.2:\n";
print PH "\$have_op_rettype = $have_op_rettype;\n";
print PH "\$have_HEK_STATIC = $have_HEK_STATIC;\n";
print PH "# use extra compiler flags, after ccopts, resp. ldopts\n";
print PH "\$extra_cflags = \"$extra_cflags\";\n";
print PH "\$extra_libs = \"$extra_libs\";\n";
print PH "\@deps = qw( ", $b_c_deps, " );\n\n";
if (!$CORE) { # miniperl cannot load Scalar::Util
require Data::Dumper;
$Data::Dumper::Terse=1;
$Data::Dumper::Sortkeys=1;
}
my %cfg;
my $conf = "(\n";
# Ensure to add all used Config keys in B::C here, otherwise they will be silently empty.
# easier hash key/value slices only came with 5.22.
# Some keys are only needed with cross
for my $s (qw(archname archlib sitearch sitelib byteorder cc ccflags
d_c99_variadic_macros d_dlopen d_isinf d_isnan d_longdbl dlext
i_dlfcn ivdformat ivsize ld ldflags libs longsize mad nvgformat
osname osvers perlpath privlib ptrsize sizesize static_ext
usecperl usedl useithreads uselongdouble usemultiplicity
usemymalloc uvuformat version))
# maybe: use64bitall use64bitint
{
if ($CORE) {
my $v = $Config::Config{$s};
if (!defined $v) {
$v = 'undef';
} else {
$v =~ s/'/\\'/g;
if ($v !~ /^\d+$/) {
$v = "'".$v."'";
}
}
$conf .= "\t$s => $v,\n";
} else {
$cfg{$s} = $Config::Config{$s};
}
}
if ($CORE) {
$conf .= ");";
} else {
$conf = Data::Dumper::Dumper(\%cfg);
$conf =~ s/^\s*{/(/;
$conf =~ s/}\s*$/);/;
}
print PH "our \%Config = $conf\n";
print PH "\n";
print PH "1;\n";
close PH;
chmod 0644, "lib/B/C/Config.pm";
}
# XXX Check for 5.16.0 B-1.34 and offer to patch it? rather use `perlall build --patches=Compiler`
my $unicode_warning =
" Perl handling of new unicode identifiers - package and symbol names - \n".
" without proper TR39 handling is considered a security risc and is not fully supported.\n".
" See http://websec.github.io/unicode-security-guide/\n\n";
if ($ENV{PERL_CORE}) {
# supress the TR39 warnings in core
}
elsif ($] > 5.015005 and $] < 5.019004) {
# We do not want to support binary identifiers. syscalls with 5.019004 should be enabled
warn "Warning: Bad perl version $]\n".
$unicode_warning.
" Check your code for syntax spoofs, confusables, esp. strip \\0 from package names.\n";
} elsif ($] >= 5.019004 and !($Config{usecperl} and $] >= 5.025002)) {
warn "Warning:\n".
$unicode_warning.
" Check your code for syntax spoofs, confusables, strip \\0 from package names.\n".
($Config{usecperl} ? "" :
" Enable use warnings 'syscalls'.\n");
}
my $carp_warning =
" Perl5 broke Carp for the compiler with 5.26 with a dynamic _fetch_sub()\n".
" Either use an earlier Carp (<1.42) or check the cperl patches, replacing it\n".
" with a simple version check.\n";
if ($] >= 5.025004 and !$Config{usecperl}) {
warn "Warning: Unsupported perl version $]\n".
$carp_warning;
}
my $perlcc = File::Spec->catfile("script", "perlcc");
if ($CORE and $^O eq 'MSWin32') {
my $perldll = $Config{usecperl} ? "cperl*.dll" : "perl*.dll";
system("copy ..\..\$perldll *.*");
}
WriteMakefile(
NAME => "B::C",
VERSION_FROM => "lib/B/C.pm",
PL_FILES => { $perlcc.'.PL' => $perlcc },
EXE_FILES => [$perlcc, qw(script/cc_harness script/assemble script/disassemble)],
PREREQ_PM => {'Opcodes' => '0', # optional
'IPC::Run' => '0', # optional
'B::Flags' => '0.15', # optional
'Time::HiRes' => '0', # optional
'ExtUtils::Embed' => '1.25' # mandatory (missing on redhat)
#'B' => '1.0901' # required but in CORE
},
'AUTHOR' => 'Reini Urban <rurban@cpan.org>, '
. 'Malcolm Beattie (retired)',
'ABSTRACT' => 'Perl compiler',
'LICENSE' => 'perl',
# was in core until 5.9.5, need to update it there
(($] < 5.010 || $Config{usecperl}) ?
('INSTALLDIRS' => 'perl') : ()),
(($ExtUtils::MakeMaker::VERSION gt '6.31' and $ExtUtils::MakeMaker::VERSION lt '6.46') ?
('EXTRA_META' => "recommends:\n" .
" B::Flags: 0.15\n".
" B::Debug: 1.16\n".
( run in 0.934 second using v1.01-cache-2.11-cpan-437f7b0c052 )