-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.PL
394 lines (342 loc) · 9.25 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# This Makefile.PL for Qgoda was generated by
# Dist::Zilla::Plugin::MakeMaker::Awesome 0.49.
# Don't edit it but the dist.ini and plugins used to construct it.
use strict;
use warnings;
use 5.018;
use ExtUtils::MakeMaker 7.1101;
#! /bin/false
# Copyright (C) 2016-2020 Guido Flohr <[email protected]>,
# all rights reserved.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Included snippet for Makefile.PL.
use strict;
use File::Spec;
sub empty(;$);
sub check_for_pm($);
# Is this a git checkout or a regular installation?
my $is_git = -e '.git';
my $qgoda_dir = File::Spec->catdir('lib', 'Qgoda');
my $package_json = File::Spec->catfile($qgoda_dir, 'package.json');
my $node_modules = File::Spec->catdir($qgoda_dir, 'node_modules');
my $npm_installed = File::Spec->catfile($qgoda_dir, 'npm_installed');
# Determine whether to use yarn, npm, or something user supplied.
my $npm;
if (empty $ENV{QGODA_PACKAGE_MANAGER}) {
if (check_for_pm 'yarn') {
$npm = ('yarn');
} elsif (check_for_pm 'npm') {
$npm = 'npm';
} else {
die <<'EOF';
*** error: Neither a working 'yarn' or 'npm' installation was found on your
system! You can try to build Qgoda again after setting the environment variable
QGODA_PACKAGE_MANAGER to either a working "yarn" or "npm".
EOF
}
} else {
$npm = $ENV{QGODA_PACKAGE_MANAGER};
# We support space characters and double quotes in the name. Everything
# else will probably fail.
if ($npm =~ s{([ "])}{\\$1}g) {
$npm = qq{"$npm"};
}
}
my $package_lock_warning = '';
if ($npm =~ /yarn/) {
$package_lock_warning = <<'EOF';
$(NOECHO) $(ECHO) Please ignore warnings about 'package-lock.json' being found.
EOF
$package_lock_warning .= "\t";
}
sub empty(;$) {
my ($what) = @_;
$what = $_ if !@_;
return if defined $what && length $what;
return 1;
}
sub check_for_pm($) {
my ($pm) = @_;
print "Checking for $pm ... ";
autoflush STDOUT, 1;
return if 0 != system $pm, '--version';
return 1;
}
package MY;
use strict;
use IO::Handle;
use Cwd qw(abs_path);
use File::Spec;
sub postamble {
my ($self) = @_;
my @post;
push @post, <<EOF;
QGODA_DIR = $qgoda_dir
NPM = $npm
PACKAGE_JSON = $package_json
NODE_MODULES = $node_modules
NPM_INSTALLED = $npm_installed
.PHONY: js_to_blib
\$(NPM_INSTALLED): \$(PACKAGE_JSON)
${package_lock_warning}cd \$(QGODA_DIR) && \\
\$(NPM) install && \\
\$(TOUCH) npm_installed
js_to_blib: \$(FIRST_MAKEFILE) $npm_installed
\$(NOECHO) \$(ABSPERLRUN) JS_TO_BLIB "\$(INST_LIB)/auto" \$(PERM_DIR) 2304
EOF
if (-e 'maintainer.mk') {
open my $fh, '<', 'maintainer.mk'
or die "Cannot open 'maintainer.mk': $!\n";
local $/;
push @post, <$fh>;
}
return join "\n", @post;
}
package MM;
use strict;
use File::Spec;
sub pm_to_blib {
my ($self) = @_;
# Make pm_to_blib depend on our phony js_to_blib target.
my $code = $self->SUPER::pm_to_blib(@_);
$code =~ s{^(pm_to_blib.*)}{$1 js_to_blib lib/Qgoda/npm_installed}m;
return $code;
}
sub realclean {
my ($self, @args) = @_;
my $npm_installed = File::Spec->catfile('$(QGODA_DIR)', 'npm_installed');
my $node_modules = File::Spec->catdir('$(QGODA_DIR)', 'node_modules');
my $code = $self->SUPER::realclean(@args);
$code =~ s/[ \t\r\n]*$/\n/;
$code .= "\t\- \$(RM_F) $npm_installed\n";
$code .= "\t\- \$(RM_RF) $node_modules\n";
return $code;
}
package main;
my %WriteMakefileArgs = (
"ABSTRACT" => "The Qgoda Static Site Generator",
"AUTHOR" => "Guido Flohr <guido.flohr\@cantanea.com>",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "7.1101"
},
"DISTNAME" => "Qgoda",
"EXE_FILES" => [
"bin/qgoda"
],
"LICENSE" => "gpl",
"MIN_PERL_VERSION" => "5.018",
"NAME" => "Qgoda",
"PREREQ_PM" => {
"AnyEvent" => 0,
"AnyEvent::Filesys::Watcher" => 0,
"AnyEvent::Handle" => 0,
"AnyEvent::Loop" => 0,
"AnyEvent::Util" => 0,
"Archive::Extract" => 0,
"Cpanel::JSON::XS" => 0,
"Cwd" => 0,
"Data::Dump" => 0,
"Data::Dumper" => 0,
"Data::Walk" => "2.00",
"Date::Parse" => 0,
"Encode" => "2.12",
"Exporter" => 0,
"File::Basename" => 0,
"File::Copy" => 0,
"File::Copy::Recursive" => 0,
"File::Find" => 0,
"File::Globstar" => "0.6",
"File::Globstar::ListMatch" => 0,
"File::HomeDir" => 0,
"File::Path" => 0,
"File::Spec" => 0,
"File::Temp" => 0,
"Filter::Util::Call" => 0,
"Getopt::Long" => "2.36",
"Git" => 0,
"HTML::Parser" => 0,
"HTML::TreeBuilder" => 0,
"IO::File" => 0,
"IO::Handle" => 0,
"IO::Interactive" => 0,
"IPC::Open3" => 0,
"Inline" => 0,
"JSON" => "2.0",
"JSON::PP" => 0,
"JavaScript::Duktape::XS" => "0.000074",
"LWP::UserAgent" => 0,
"List::Util" => "1.45",
"Locale::Language" => 0,
"Locale::Messages" => 0,
"Locale::TextDomain" => "1.30",
"Locale::Util" => 0,
"Locale::XGettext" => "0.7",
"Locale::gettext_dumb" => 0,
"MIME::Base64" => 0,
"POSIX" => 0,
"Pod::Perldoc" => 0,
"Scalar::Util" => 0,
"Socket" => 0,
"Storable" => 0,
"Symbol" => 0,
"Template" => 0,
"Template::Constants" => 0,
"Template::Plugin" => 0,
"Template::Plugin::Filter" => 0,
"Template::Plugin::Gettext" => "0.7",
"Template::Provider" => 0,
"Template::Stash" => 0,
"Term::ANSIColor" => 0,
"Text::Markdown::Discount" => 0,
"Text::Unidecode" => 0,
"Time::HiRes" => 0,
"URI" => 0,
"URI::Escape" => 0,
"URI::file" => 0,
"URI::git" => "0.02",
"YAML" => 0,
"YAML::XS" => "0.67",
"base" => 0,
"boolean" => 0,
"constant" => 0,
"integer" => 0,
"overload" => 0,
"strict" => 0,
"vars" => 0,
"version" => 0,
"warnings" => 0
},
"TEST_REQUIRES" => {
"Carp" => 0,
"Git::Repository" => "1.321",
"Locale::PO" => 0,
"Test::More" => 0,
"Time::Local" => 0,
"autodie" => 0,
"common::sense" => 0,
"lib" => 0,
"utf8" => 0
},
"VERSION" => "v0.10.1",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"AnyEvent" => 0,
"AnyEvent::Filesys::Watcher" => 0,
"AnyEvent::Handle" => 0,
"AnyEvent::Loop" => 0,
"AnyEvent::Util" => 0,
"Archive::Extract" => 0,
"Carp" => 0,
"Cpanel::JSON::XS" => 0,
"Cwd" => 0,
"Data::Dump" => 0,
"Data::Dumper" => 0,
"Data::Walk" => "2.00",
"Date::Parse" => 0,
"Encode" => "2.12",
"Exporter" => 0,
"File::Basename" => 0,
"File::Copy" => 0,
"File::Copy::Recursive" => 0,
"File::Find" => 0,
"File::Globstar" => "0.6",
"File::Globstar::ListMatch" => 0,
"File::HomeDir" => 0,
"File::Path" => 0,
"File::Spec" => 0,
"File::Temp" => 0,
"Filter::Util::Call" => 0,
"Getopt::Long" => "2.36",
"Git" => 0,
"Git::Repository" => "1.321",
"HTML::Parser" => 0,
"HTML::TreeBuilder" => 0,
"IO::File" => 0,
"IO::Handle" => 0,
"IO::Interactive" => 0,
"IPC::Open3" => 0,
"Inline" => 0,
"JSON" => "2.0",
"JSON::PP" => 0,
"JavaScript::Duktape::XS" => "0.000074",
"LWP::UserAgent" => 0,
"List::Util" => "1.45",
"Locale::Language" => 0,
"Locale::Messages" => 0,
"Locale::PO" => 0,
"Locale::TextDomain" => "1.30",
"Locale::Util" => 0,
"Locale::XGettext" => "0.7",
"Locale::gettext_dumb" => 0,
"MIME::Base64" => 0,
"POSIX" => 0,
"Pod::Perldoc" => 0,
"Scalar::Util" => 0,
"Socket" => 0,
"Storable" => 0,
"Symbol" => 0,
"Template" => 0,
"Template::Constants" => 0,
"Template::Plugin" => 0,
"Template::Plugin::Filter" => 0,
"Template::Plugin::Gettext" => "0.7",
"Template::Provider" => 0,
"Template::Stash" => 0,
"Term::ANSIColor" => 0,
"Test::More" => 0,
"Text::Markdown::Discount" => 0,
"Text::Unidecode" => 0,
"Time::HiRes" => 0,
"Time::Local" => 0,
"URI" => 0,
"URI::Escape" => 0,
"URI::file" => 0,
"URI::git" => "0.02",
"YAML" => 0,
"YAML::XS" => "0.67",
"autodie" => 0,
"base" => 0,
"boolean" => 0,
"common::sense" => 0,
"constant" => 0,
"integer" => 0,
"lib" => 0,
"overload" => 0,
"strict" => 0,
"utf8" => 0,
"vars" => 0,
"version" => 0,
"warnings" => 0
);
unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
if ( $^O eq 'linux' ) {
$WriteMakefileArgs{PREREQ_PM}{'Linux::Inotify2'} = $FallbackPrereqs{'Linux::Inotify2'} = '1.22';
}
if ( $^O eq 'darwin' ) {
$WriteMakefileArgs{PREREQ_PM}{'Mac::FSEvents'} = $FallbackPrereqs{'Mac::FSEvents'} = '0.14';
}
if ( $^O =~ /bsd/i ) {
$WriteMakefileArgs{PREREQ_PM}{'IO::KQueue'} = $FallbackPrereqs{'IO::KQueue'} = '0.34';
}
if ( $^O eq 'Win32' ) {
$WriteMakefileArgs{PREREQ_PM}{'Win32::Process'} = $FallbackPrereqs{'Win32::Process'} = '0';
}
WriteMakefile(%WriteMakefileArgs);