-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile.PL
276 lines (247 loc) · 7.14 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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#! perl -w
use strict;
use v5.10;
use ExtUtils::MakeMaker 6.55_03;
use Config;
my $findbin;
use File::Basename;
BEGIN { $findbin = dirname $0 }
use File::Spec::Functions qw( :DEFAULT rel2abs );
use Cwd;
use File::Path;
use Text::ParseWords qw( quotewords shellwords );
# Some strange stuff happens when WriteMakefile() is called
# on a non-clean distribution, cleanup before
if (-f 'Makefile') {
local *SAVEERR; open SAVEERR, ">&STDERR";
local *SAVEOUT; open SAVEOUT, ">&STDOUT";
close STDERR; close STDOUT;
my $opt = $^O eq 'VMS'
? '/IGNORE'
: $^O eq 'haiku'
? ''
: ' -i';
system "$Config{make}$opt distclean";
open STDOUT, ">&SAVEOUT"; close SAVEOUT;
open STDERR, ">&SAVEERR"; close SAVEERR;
}
my $mmver = eval "ExtUtils::MakeMaker->VERSION";
my $prefix_or_base = 'PREFIX';
if (my $perl_mm_opt = $ENV{PERL_MM_OPT}) {
my @mm_opts = shellwords($perl_mm_opt);
my ($install_base) = grep { m<^ INSTALL_BASE= >x } @mm_opts;
if ($install_base) {
$prefix_or_base = 'INSTALL_BASE';
my (undef, $install_path) = quotewords('=', 0, $install_base);
$ENV{SMOKE_INSTDIR} //= $install_path if $install_path;
}
}
my %install = ( );
if (!@ARGV and !$ENV{SMOKE_INST_SITE_LIB}) {
my $dft_install = exists $ENV{SMOKE_INSTDIR} && $ENV{SMOKE_INSTDIR} ne ""
? $ENV{SMOKE_INSTDIR}
: catdir( updir(), 'smoke' );
$dft_install = rel2abs( $dft_install );
my $install_dir = $dft_install;
if (!$ENV{AUTOMATED_TESTING}) {
# So CPAN.pm will ask for install-directory!
local $ENV{PERL_MM_USE_DEFAULT};
$install_dir = dir_prompt(
"Where would you like to install Test::Smoke?\n",
$dft_install
);
}
%install = (
INSTALLSITESCRIPT => $install_dir,
$prefix_or_base => $install_dir,
($prefix_or_base eq 'PREFIX'
? (LIB => "$install_dir/lib")
: ()
),
);
}
else { # this will be the default in some time
if (my ($switch) = grep { m{^--site-lib$} } @ARGV) {
@ARGV = grep { $_ !~ m{^--site-lib$} } @ARGV;
}
}
my @scripts = qw(
smokestatus.pl chkbcfg.pl sysinfo.pl
tssynctree.pl tsrunsmoke.pl tssendrpt.pl tsarchive.pl
tssmokeperl.pl tsreport.pl tsrepostjsn.pl
tsw32configure.pl tsconfigsmoke.pl
);
my @pod_scripts = grep {
local (@ARGV, $/) = (catfile('bin', $_));
my $content = <>;
$content =~ m/^=(?:head[1-6]|cut)/m ? 1 : ();
} @scripts;
my %extra_deps;
for ($^O) {
/MSWin32/ && do {
%extra_deps = (
'Win32' => 0,
'Win32::API' => 0,
'Win32::TieRegistry' => 0,
);
last;
};
/haiku/ && do {
%extra_deps = (
'Haiku::SysInfo' => 0,
);
last;
};
}
# We won't enforce JSON::PP if Cpanel::JSON::XS or JSON::XS is installed.
# But JSON serialisation is needed.
eval {require Cpanel::JSON::XS };
if ( $@ ) {
eval { require JSON::XS };
if ( $@ ) {
$extra_deps{'JSON::PP'} = 0;
}
else {
$extra_deps{'JSON::XS'} = 0;
}
}
else {
$extra_deps{'Cpanel::JSON::XS'} = 0;
}
my %posters;
my @ua_clients = qw/HTTP::Tiny LWP::UserAgent/;
for my $poster (@ua_clients) {
eval "require $poster;";
if ($@) { $posters{$poster} = 0 }
}
if (keys %posters == 3) {
# Check for the curlbin as fallback
local @INC = (@INC, 'lib');
require Test::Smoke::Util;
my $curlbin = Test::Smoke::Util::whereis('curl');
if (!$curlbin) {
$extra_deps{'HTTP::Tiny'} = 0;
}
else {
print "Found $curlbin\n";
}
}
else { # we have a perl module, so we need extra stuff
exists $posters{$_} or $extra_deps{$_} = 0, last
for @ua_clients;
$extra_deps{'Net::SSLeay'} = 0;
$extra_deps{'IO::Socket::SSL'} = 0;
$extra_deps{'LWP::Protocol::https'} = 6 if exists($posters{'LWP::UserAgent'});
}
my %BUILD_REQUIRES = (
'ExtUtils::MakeMaker' => '6.55_03',
);
my %TEST_REQUIRES = (
'Test::More' => 0.88,
'Test::NoWarnings' => 0,
'Test::Fatal' => 0,
'HTTP::Daemon' => 0,
'HTTP::Message' => 0,
'JSON' => 4.10,
($mmver > 6.64 ? (%BUILD_REQUIRES) : ()),
);
my $test_requires = (
$mmver >= 6.64
? 'TEST_REQUIRES'
: "BUILD_REQUIRES"
);
my %wm = (
NAME => "Test::Smoke",
DISTNAME => "Test-Smoke",
VERSION_FROM => "lib/Test/Smoke.pm",
AUTHOR => 'H.Merijn Brand <[email protected]>, '
. 'Nicholas Clark <[email protected]> and '
. 'Abe Timmerman <[email protected]>',
ABSTRACT_FROM => 'lib/Test/Smoke.pm',
MIN_PERL_VERSION => '5.010',
LICENSE => "perl_5",
dist => {
COMPRESS => "gzip -9f",
SUFFIX => ".gz",
},
PREREQ_PM => {
'URI' => '1.53',
'Capture::Tiny' => 0,
'File::Spec' => 0.82,
'POSIX' => 0,
'System::Info' => 0.050,
'autodie' => 0,
'Getopt::Long' => '2.39',
($test_requires eq 'PREREQ_PM' ? %TEST_REQUIRES : ()),
%extra_deps,
},
PMLIBDIRS => [qw/ lib /],
EXE_FILES => [ map "bin/$_", @scripts ],
MAN1PODS => {
'lib/configsmoke.pod' => 'blib/man1/configsmoke.1',
map { ("bin/$_" => "blib/man1/$_.1") } @pod_scripts,
},
test => {
TESTS => 't/*.t t/app/*.t',
},
META_ADD => {
"meta-spec" => {
version => 2,
},
"resources" => {
homepage => "http://perl5.test-smoke.org/",
repository => {
type => "git",
url => "https://github.com/abeltje/Test-Smoke.git",
web => "https://github.com/abeltje/Test-Smoke",
},
bugtracker => {
web => 'https://github.com/abeltje/Test-Smoke/issues',
},
x_IRC => "irc://irc.perl.org/#smoke",
},
},
);
if ($test_requires ne 'PREREQ_PM') {
$wm{$test_requires} = \%TEST_REQUIRES;
}
WriteMakefile(
%wm,
%install
);
sub dir_prompt {
GETDIR: {
my $dir = &prompt; # & -> pass @_
# thanks to perlfaq5
$dir =~ s{^ ~ ([^/]*)}
{$1 ? ( getpwnam $1 )[7] :
( $ENV{HOME} || $ENV{LOGDIR} ||
"$ENV{HOMEDRIVE}$ENV{HOMEPATH}" )
}ex;
my $cwd = cwd();
my $dir_existed = -d $dir;
File::Path::mkpath( $dir, 1, 0755 ) unless $dir_existed;
chdir $dir or warn "Cannot chdir($dir): $!\n" and redo GETDIR;
$dir = canonpath( cwd() );
chdir $cwd or warn "Cannot chdir($cwd) back: $!\n";
File::Path::rmtree( $dir ) unless $dir_existed;
print "Got [$dir]\n";
return $dir;
}
}
package MY;
sub test {
my $self = shift;
my $orig = $self->SUPER::test(@_);
$orig .= <<"EOM";
XTEST_FILES = xt/*.t
xtest ::
EOM
my $varpfx = $^O eq 'MSWin32' ? '$$' : '\$$';
$orig .= "\t"
. qq{\$(FULLPERLRUN) "-e" "my ${varpfx}sw=q[-wl]; }
. qq{${varpfx}sw .= q[v] if \$(TEST_VERBOSE); }
. qq{system qq[prove ${varpfx}sw \$(XTEST_FILES)]"};
return $orig;
}
1;