This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip dynaloader test on Bitrig like we do for OpenBSD
[perl5.git] / ext / B / Makefile.PL
1 use ExtUtils::MakeMaker;
2 use ExtUtils::Constant 0.23 'WriteConstants';
3 use File::Spec;
4 use strict;
5 use warnings;
6
7 my $core = grep { $_ eq 'PERL_CORE=1' } @ARGV;
8
9 WriteMakefile(
10     NAME            => "B",
11     VERSION_FROM    => "B.pm",
12     realclean       => {FILES=> 'const-c.inc const-xs.inc'},
13 );
14
15 my $headerpath;
16 if ($core) {
17     $headerpath = File::Spec->catdir(File::Spec->updir, File::Spec->updir);
18 } else {
19         require Config;
20     $headerpath = File::Spec->catdir($Config::Config{archlibexp}, "CORE");
21 }
22
23 my @names = ({ name => 'HEf_SVKEY', macro => 1, type => "IV" },
24              qw(SVTYPEMASK SVt_PVGV SVt_PVHV PAD_FAKELEX_ANON PAD_FAKELEX_MULTI));
25
26
27 # First element in each tuple is the file; second is a regex snippet
28 # giving the prefix to limit the names of symbols to define that come
29 # from that file.  If none, all symbols will be defined whose values
30 # match the pattern below.
31 foreach my $tuple (['cop.h'],
32                    ['cv.h', 'CVf'],
33                    ['gv.h', 'GVf'],
34                    ['op.h'],
35                    ['op_reg_common.h','(?:(?:RXf_)?PMf_)'],
36                    ['regexp.h','RXf_'],
37                    ['sv.h', 'SV(?:[fps]|pad)_'],
38                   ) {
39     my $file = $tuple->[0];
40     my $pfx = $tuple->[1] || '';
41     my $path = File::Spec->catfile($headerpath, $file);
42     open my $fh, '<', $path or die "Cannot open $path: $!";
43     while (<$fh>) {
44         push @names, $1 if (/ \#define \s+ ( $pfx \w+ ) \s+
45                               ( [()|\dx]+             # Parens, '|', digits, 'x'
46                               | \(? \d+ \s* << .*?    # digits left shifted by anything
47                               ) \s* (?: $| \/ \* )    # ending at comment or $
48                             /x);
49     }
50     close $fh;
51 }
52
53 # Currently only SVt_PVGV and SVt_PVHV aren't macros, but everything we name
54 # should exist, so ensure that the C compile breaks if anything does not.
55 WriteConstants(
56     PROXYSUBS => {push => 'EXPORT_OK'},
57     NAME => 'B',
58     NAMES => [map {ref $_ ? $_ : {name=>$_, macro=>1, type=>"UV"}} @names],
59     XS_SUBNAME => undef,
60 );