| 1 |
use v5; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
use lib 'inc'; |
| 6 |
use ExtUtils::CChecker 0.11; |
| 7 |
use Module::Build::with::XSTests; |
| 8 |
|
| 9 |
my @extra_compiler_flags = qw( -Ishare-keyword/include -Ishare-infix/include -Ihax ); |
| 10 |
|
| 11 |
# Perl 5.36 made -std=c99 standard; before then we'll have to request it specially |
| 12 |
push @extra_compiler_flags, qw( -std=c99 ) if $^V lt v5.36.0; |
| 13 |
|
| 14 |
push @extra_compiler_flags, qw( -DDEBUGGING=-g ) if $^X =~ m|/debugperl|; |
| 15 |
|
| 16 |
my $MIN_PERL = '5.014'; # PL_keyword_plugin |
| 17 |
|
| 18 |
# MSWin32 needs at least perl 5.22 |
| 19 |
# https://rt.cpan.org/Ticket/Display.html?id=136577 |
| 20 |
$MIN_PERL = '5.022' if $^O eq "MSWin32"; |
| 21 |
|
| 22 |
my $cc = ExtUtils::CChecker->new( quiet => 1 ); |
| 23 |
|
| 24 |
$cc->try_find_cflags_for( |
| 25 |
cflags => [ |
| 26 |
# Most systems will need no extra cflags |
| 27 |
[], |
| 28 |
# HPUX may need to be told +std=gnu in order to accept anon inner unions |
| 29 |
( $^O eq "hpux" ) ? [ "+std=gnu" ] : (), |
| 30 |
], |
| 31 |
source => <<'EOF' |
| 32 |
struct Named { |
| 33 |
union { int a, b; }; |
| 34 |
int c; |
| 35 |
}; |
| 36 |
int main(void) { struct Named n; n.a = 0; return n.a; } |
| 37 |
EOF |
| 38 |
) or die "OS unsupported - C compiler does not support anonymous inner unions\n"; |
| 39 |
|
| 40 |
my $build = Module::Build::with::XSTests->new( |
| 41 |
module_name => 'XS::Parse::Keyword', |
| 42 |
requires => { |
| 43 |
'perl' => $MIN_PERL, |
| 44 |
}, |
| 45 |
build_requires => { |
| 46 |
# We have multiple t/*.xs files, which requires a new enough version of |
| 47 |
# ExtUtils::ParseXS to cope with. |
| 48 |
# Unsure the exact version required. perl 5.14 normally ships with version |
| 49 |
# 2.2210 but that fails. perl 5.16's version 3.16 works fine. |
| 50 |
'ExtUtils::ParseXS' => '3.16', |
| 51 |
}, |
| 52 |
test_requires => { |
| 53 |
'Test2::V0' => 0, |
| 54 |
}, |
| 55 |
configure_requires => { |
| 56 |
'ExtUtils::CChecker' => '0.11', |
| 57 |
'Module::Build' => '0.4004', # test_requires |
| 58 |
}, |
| 59 |
share_dir => { |
| 60 |
module => { |
| 61 |
"XS::Parse::Infix" => [ 'share-infix' ], |
| 62 |
"XS::Parse::Keyword" => [ 'share-keyword' ], |
| 63 |
}, |
| 64 |
}, |
| 65 |
license => 'perl', |
| 66 |
create_license => 1, |
| 67 |
create_readme => 1, |
| 68 |
|
| 69 |
extra_compiler_flags => \@extra_compiler_flags, |
| 70 |
c_source => [ "src/" ], |
| 71 |
); |
| 72 |
|
| 73 |
$cc->extend_module_build( $build ); |
| 74 |
$build->notes( builder_cflags => $cc->extra_compiler_flags ); |
| 75 |
|
| 76 |
$build->create_build_script; |