[f7e958]: Makefile.PL  Maximize  Restore  History

Download this file

236 lines (196 with data), 5.8 kB

  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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/usr/bin/perl
# rocco // vim: ts=2 sw=2 expandtab
# Note to Dist::Zilla fans - This is NOT a standard Makefile.PL by ANY
# stretch of the imagination. If you want to port it to Dist::Zilla,
# you'll have a number of challenges ahead of you:
#
# - Custom Makefile.PL code.
#
# - Dynamic dependencies varying by $^O (see mylib/PoeBuildInfo.pm)
# and by $] (see IPv6 dependencies below).
#
# - Dynamically generated tests. See PREOP in WriteMakefile(), below.
#
# - Custom Makefile target "coverage". See MY::postamble, below.
#
# I have tried using Dist::Zilla::Plugin::Makemaker::Awesome, but the
# need to break encapsulation in order to make it work turned me away.
#
# People who love Dist::Zilla are welcome to replace this perfectly
# fine Makefile.PL, but you should be aware of some requirements
# before I'll accept the change:
#
# - Reproduce or improve upon all current Makefile.PL features. It's
# all there for one reason or another. The reasons are still largely
# pertinent. When in doubt, ask.
#
# - Limit your changes to replacing Makefile.PL and $VERSION. I'd
# rather be able to rely on error message line numbers than to add
# more moving parts to my build and test workflows.
use strict;
use ExtUtils::MakeMaker;
use Config;
# Switch to default behavior if STDIN isn't a tty.
unless (-t STDIN) {
warn(
"\n",
"=============================================\n\n",
"STDIN is not a terminal. Assuming --default.\n\n",
"=============================================\n\n",
);
push @ARGV, "--default";
}
# Remind the user she can use --default.
unless (grep /^--default$/, @ARGV) {
warn(
"\n",
"=============================================\n\n",
"Prompts may be bypassed by running:\n",
" $^X $0 --default\n\n",
"=============================================\n\n",
);
}
# Should we skip the network tests?
my $prompt = (
"Some of POE's tests require a functional network.\n" .
"You can skip these tests if you'd like.\n\n" .
"Would you like to skip the network tests?"
);
my $ret = "n";
if (grep /^--default$/, @ARGV) {
print $prompt, " [$ret] $ret\n\n";
}
else {
$ret = prompt($prompt, "n");
}
my $marker = 'run_network_tests';
unlink $marker;
unless ($ret =~ /^Y$/i) {
open(TOUCH,"+>$marker") and close TOUCH;
}
print "\n";
use lib qw(./mylib);
use PoeBuildInfo qw(
TEST_FILES
CLEAN_FILES
CORE_REQUIREMENTS
DIST_ABSTRACT
DIST_AUTHOR
CONFIG_REQUIREMENTS
HOMEPAGE
REPOSITORY
);
### Touch files that will be generated at "make dist" time.
### ExtUtils::MakeMaker will complain about them if
### they aren't present now.
open(TOUCH, ">>CHANGES") and close TOUCH;
### Touch gen-tests.perl so it always triggers.
utime(time(), time(), "mylib/gen-tests.perl");
### Some advisory dependency testing.
sub check_for_modules {
my ($dep_type, @modules) = @_;
my @failures;
while (@modules) {
my $module = shift @modules;
my $target = shift @modules;
my $version = eval "use $module (); return \$$module\::VERSION";
if ($@) {
push(
@failures,
"*** $module $target could not be loaded.\n"
);
}
elsif ($version < $target) {
push(
@failures,
"*** $module $target is $dep_type, " .
"but version $version is installed.\n"
);
}
}
if (@failures) {
warn(
"*** Some $dep_type features may not be available:\n",
@failures,
);
}
}
check_for_modules("required", CORE_REQUIREMENTS);
check_for_modules(
"optional",
"Compress::Zlib" => 1.33,
"Curses" => 1.08,
"IO::Poll" => 0.01,
"IO::Pty" => 1.02,
"LWP" => 5.79,
"Term::Cap" => 1.10,
"Term::ReadKey" => 2.21,
"URI" => 1.30,
);
# check for optional IPv6 stuff
{
# under perl-5.6.2 the warning "leaks" from the eval, while newer versions don't...
# it's due to Exporter.pm behaving differently, so we have to shut it up
no warnings 'redefine';
require Carp;
local *Carp::carp = sub { die @_ };
# On perl-5.14.0 Socket.pm provides getaddrinfo
# otherwise we need to use Socket::GetAddrInfo
eval { require Socket; Socket->import("getaddrinfo") };
if ($@) {
check_for_modules( "optional",
"Socket::GetAddrInfo" => "0.20",
);
}
# On perl-5.14.0 Socket.pm provides the needed IPv6 constants
# otherwise we need to use Socket6
eval { Socket->import( qw(AF_INET6 PF_INET6) ) };
if ($@) {
check_for_modules( "optional",
"Socket6" => "0.23",
);
}
}
### Generate Makefile.PL.
sub MY::postamble {
return <<EOF;
coverage: Makefile
\cI$^X mylib/coverage.perl
cover: coverage
EOF
}
WriteMakefile(
NAME => 'POE',
AUTHOR => DIST_AUTHOR,
ABSTRACT => DIST_ABSTRACT,
LICENSE => 'perl',
CONFIGURE_REQUIRES => { CONFIG_REQUIREMENTS },
BUILD_REQUIRES => { CONFIG_REQUIREMENTS },
VERSION_FROM => 'lib/POE.pm',
dist => {
COMPRESS => 'gzip -9f',
SUFFIX => 'gz',
PREOP => (
'git-log.pl | ' .
'/usr/bin/tee ./$(DISTNAME)-$(VERSION)/CHANGES > ./CHANGES; '
),
},
clean => { FILES => CLEAN_FILES },
test => { TESTS => TEST_FILES },
# Not executed on "make test".
PL_FILES => { 'mylib/gen-tests.perl' => [ 'lib/POE.pm' ] },
PREREQ_PM => { CORE_REQUIREMENTS },
META_MERGE => {
no_index => {
directory => [ 'mylib' ],
},
resources => {
homepage => HOMEPAGE,
license => 'http://dev.perl.org/licenses/',
repository => REPOSITORY,
},
},
# TODO - ExtUtils::MakeMaker doesn't generate 'provides'.
# Module::Build did, but we're not using it anymore.
);
1;