This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge the implementation of B::IV::{needs64bits,packiv} using ALIAS.
[perl5.git] / ext / B / Makefile.PL
CommitLineData
a8a597b2 1use ExtUtils::MakeMaker;
b1826b71 2use ExtUtils::Constant 0.23 'WriteConstants';
29fc1735 3use File::Spec;
b1826b71
NC
4use strict;
5use warnings;
6
b7254abc 7my $core = grep { $_ eq 'PERL_CORE=1' } @ARGV;
a8a597b2
MB
8
9WriteMakefile(
51a5edaf
RGS
10 NAME => "B",
11 VERSION_FROM => "B.pm",
b1826b71 12 realclean => {FILES=> 'const-c.inc const-xs.inc'},
51a5edaf 13);
a8a597b2 14
b1826b71
NC
15my $headerpath;
16if ($core) {
17 $headerpath = File::Spec->catdir(File::Spec->updir, File::Spec->updir);
18} else {
4a46fe99 19 require Config;
b1826b71 20 $headerpath = File::Spec->catdir($Config::Config{archlibexp}, "CORE");
29fc1735
JH
21}
22
b1826b71
NC
23my @names = qw(CVf_ANON CVf_CLONE CVf_CLONED CVf_CONST CVf_LVALUE CVf_METHOD
24 CVf_NODEBUG CVf_UNIQUE CVf_WEAKOUTSIDE
25 GVf_IMPORTED_AV GVf_IMPORTED_CV GVf_IMPORTED_HV GVf_IMPORTED_SV
26 HEf_SVKEY
27 SVTYPEMASK SVt_PVGV SVt_PVHV
28 SVf_FAKE SVf_IOK SVf_IVisUV SVf_NOK SVf_POK SVf_READONLY
29 SVf_ROK SVp_IOK SVp_NOK SVp_POK SVpad_OUR SVs_RMG SVs_SMG
30 PAD_FAKELEX_ANON PAD_FAKELEX_MULTI);
b7254abc 31
b1826b71
NC
32if ($] >= 5.009) {
33 push @names, 'CVf_ISXSUB';
34} else {
35 # Constant not present after 5.8.x
36 push @names, 'AVf_REAL';
37 # This is only present in 5.10, but it's useful to B::Deparse to be able
38 # to import a dummy value from B
39 push @names, 'OPpPAD_STATE';
40}
d19af0aa 41
b1826b71
NC
42if ($] < 5.011) {
43 # Constant not present after 5.10.x
44 push @names, 'CVf_LOCKED';
a8a597b2 45}
b7254abc 46
b1826b71
NC
47# First element in each tuple is the file; second is a regex snippet
48# giving the prefix to limit the names of symbols to define that come
49# from that file. If none, all symbols will be defined whose values
50# match the pattern below.
51foreach my $tuple (['op_reg_common.h','(?:(?:RXf_)?PMf_)'],
52 ['op.h'],
53 ['cop.h'],
54 ['regexp.h','RXf_']) {
55 my $file = $tuple->[0];
56 my $pfx = $tuple->[1] || '';
57 my $path = File::Spec->catfile($headerpath, $file);
58 open my $fh, '<', $path or die "Cannot open $path: $!";
59 while (<$fh>) {
60 push @names, $1 if (/ \#define \s+ ( $pfx \w+ ) \s+
61 ( [()|\dx]+ # Parens, '|', digits, 'x'
62 | \(? \d+ \s* << .*? # digits left shifted by anything
63 ) \s* (?: $| \/ \* ) # ending at comment or $
64 /x);
65 }
66 close $fh;
b7254abc 67}
b1826b71
NC
68
69# Currently only SVt_PVGV and SVt_PVHV aren't macros, but everything we name
70# should exist, so ensure that the C compile breaks if anything does not.
71WriteConstants(
72 PROXYSUBS => {push => 'EXPORT_OK'},
73 NAME => 'B',
74 NAMES => [map {{name=>$_, macro=>1}} @names],
75 XS_SUBNAME => undef,
76);