-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile.PL
140 lines (116 loc) · 3.57 KB
/
Makefile.PL
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
use 5.008001;
use strict;
use warnings;
use Config;
use ExtUtils::Depends;
use ExtUtils::MakeMaker;
use File::Copy 'copy';
our $EUMM_VERSION = eval($ExtUtils::MakeMaker::VERSION);
our $OPTIMIZE;
if ($Config{gccversion}) {
$OPTIMIZE = '-O3 -Wall -W';
$OPTIMIZE .= ' -g -Wextra -Wdeclaration-after-statement' if (-d 'dev');
} elsif ($Config{osname} eq 'MSWin32') {
$OPTIMIZE = '-O2 -W4';
} else {
$OPTIMIZE = $Config{optimize};
}
our %XS_PREREQUISITES = (
'B::Hooks::OP::Annotation' => '0.44',
'B::Hooks::OP::Check' => '0.22',
);
our %XS_DEPENDENCIES = ExtUtils::Depends->new(
'true',
keys(%XS_PREREQUISITES)
)->get_makefile_vars();
# test dependencies
our %TEST_REQUIRES = (
# perl 5.8's Test::More doesn't support `subtest`
'Test::Simple' => '1.302183',
);
# Function::Parameters requires perl >= v5.14.0
if ($] >= 5.014000) {
%TEST_REQUIRES = (
%TEST_REQUIRES,
# https://rt.cpan.org/Ticket/Display.html?id=124745
'Moo' => '2.003004',
'Function::Parameters' => '2.001003',
);
}
sub ensure_activeperl_dep_files_exist($) {
return if $^O ne 'MSWin32';
return if $Config{make} !~ /dmake/;
return if $Config{cc} !~ /gcc/;
return if $Config{cf_email} !~ /ActiveState/;
my $libs = shift;
my @libs = split ' ', $libs;
my @dirs = grep { /^-L.+/ } @libs;
my @files = grep { /^-l.+/ } @libs;
s/^-L// for @dirs;
s/^-l// for @files;
for my $dir (@dirs) {
for my $file (@files) {
my $base = "$dir/$file";
my $want = "$base.a";
my $maybe = "$base.lib";
# everything OK: next
next if -f $want;
# if neither file exists, either this one is elsewhere
# or we have a problem: next
next unless -f $maybe;
# .a is missing, but .lib exists, so just copy it over
copy($maybe, $want);
}
}
}
ensure_activeperl_dep_files_exist($XS_DEPENDENCIES{LIBS});
my %META = (
NAME => 'true',
VERSION_FROM => 'lib/true.pm',
PREREQ_PM => {
%XS_PREREQUISITES,
'Devel::StackTrace' => '2.03',
'version' => '0.77',
},
ABSTRACT_FROM => 'lib/true.pm',
AUTHOR => 'chocolateboy <chocolate@cpan.org>',
LIBS => [''],
DEFINE => '',
INC => '-I.',
OPTIMIZE => $OPTIMIZE,
%XS_DEPENDENCIES,
);
if ($EUMM_VERSION >= 6.31) {
$META{LICENSE} = 'artistic_2';
}
if ($EUMM_VERSION >= 6.46) {
$META{META_MERGE} = {
configure_requires => {
'ExtUtils::Depends' => '0.405',
%XS_PREREQUISITES
},
dynamic_config => 1, # [1]
resources => {
repository => 'https://github.com/chocolateboy/true',
bugtracker => 'https://github.com/chocolateboy/true/issues',
},
};
}
# [1] make sure this script is always run (to correctly handle the
# conditional test dependency on Function::Parameters). this avoids signaling to
# clients that the static metadata in META.yml or META.json is sufficient for
# every build
#
# http://blogs.perl.org/users/neilb/2017/04/an-introduction-to-distribution-metadata.html
# https://github.com/Perl-Toolchain-Gang/CPAN-Meta/issues/112
if ($EUMM_VERSION >= 6.48) {
$META{MIN_PERL_VERSION} = '5.008';
}
if ($EUMM_VERSION >= 6.64) {
$META{TEST_REQUIRES} = \%TEST_REQUIRES;
} elsif ($EUMM_VERSION >= 6.55_03) {
$META{BUILD_REQUIRES} = \%TEST_REQUIRES;
} else {
$META{PREREQ_PM} = { %{ $META{PREREQ_PM} || {} }, %TEST_REQUIRES };
}
WriteMakefile(%META);