-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.PL
More file actions
213 lines (187 loc) · 5.72 KB
/
Makefile.PL
File metadata and controls
213 lines (187 loc) · 5.72 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
use 5.006;
use strict;
use ExtUtils::MakeMaker;
my $mm_ver=$ExtUtils::MakeMaker::VERSION;
if ($mm_ver=~/_/) { # dev version
$mm_ver=eval $mm_ver;
die $@ if $@;
}
my %WriteMakefile=(
NAME => 'WebDyne',
VERSION_FROM => 'lib/WebDyne.pm',
ABSTRACT_FROM => 'lib/WebDyne.pm',
EXE_FILES => do {
[
'bin/wdcompile',
'bin/wdrender',
'bin/wddump',
'bin/wdapacheinit',
'bin/wddebug',
'bin/wdlint',
'bin/webdyne.psgi'
]
},
LICENSE => 'perl',
AUTHOR => 'Andrew Speer <andrew.speer@isolutions.com.au>',
MIN_PERL_VERSION => '5.006',
PREREQ_PM => {
'CGI::Simple' => 0,
'HTML::Tiny' => 0,
'JSON' => 0,
'IO::String' => 0,
'Digest::MD5' => 0,
'HTTP::Status' => 0,
'HTML::Tagset' => 0,
'HTML::TreeBuilder' => 0,
'Storable' => 0,
'Tie::IxHash' => 0,
'Devel::Confess' => 0,
'Router::Simple' => 0,
'Hash::MultiValue' => 0,
'Devel::Confess' => 0,
'Time::HiRes' => 0,
# Plack recommended but not mandatory
#
#'Plack' => 0,
#'Plack::Middleware::ForceEnv => 0,
# Needed for installer - can be ignored if not using installer
'Text::Template' => 0,
'Env::Path' => 0,
},
BUILD_REQUIRES => {
'Test::Simple' => 0.44,
'Test::More' => 0,
'Capture::Tiny' => 0,
'Test::Deep' => 0,
'Test::Exception' => 0,
'Text::Diff' => 0
},
META_MERGE => {
'meta-spec' => {
version => 2
},
"prereqs" => {
"runtime" => {
"recommends" => {
'Plack' => 0,
},
},
},
resources => {
homepage => 'https://github.com/aspeer/WebDyne',
repository => {
type => 'git',
url => 'https://github.com/aspeer/WebDyne.git',
web => 'https://github.com/aspeer/WebDyne'
}
},
x_authority => 'cpan:ASPEER'
},
PM_FILTER => $ENV{'PM_DEBUG'} || $ENV{'WEBDYNE_DEBUG'} || do {
use IO::File;
my $fn='.pm_filter.pf';
my $fh=IO::File->new($fn, O_WRONLY | O_CREAT | O_TRUNC) ||
die("unable to write filter file '$fn', $!");
print $fh 's/^(\s*)debug\\(/${1}0 && debug\\(/m; print';
$fh->close();
my $pm_filter="\$(PERL) -nl $fn";
},
'depend' => {
Makefile => '$(VERSION_FROM)',
},
'dist' => {
COMPRESS => 'gzip -9f',
SUFFIX => '.gz'
},
);
my %MM_Compat=(
'5.46' => [q(PM_FILTER)],
'6.31' => [q(LICENSE)],
'6.46' => [q(META_MERGE)],
'6.48' => [q(MIN_PERL_VERSION)],
'6.52' => [q(CONFIGURE_REQUIRES)],
'6.5503' => [q(BUILD_REQUIRES)],
'6.64' => [q(TEST_REQUIRES)],
);
while (my ($mm_ver_test, $ar)=each %MM_Compat) {
if (version->parse($mm_ver) < version->parse($mm_ver_test)) {
delete @WriteMakefile{@{$ar}};
}
}
WriteMakefile(%WriteMakefile);
package MY;
use File::Copy qw(copy);
use File::Spec;
use Cwd qw(abs_path);
use Tie::File;
sub post_initialize {
# Add license file, other support files here
#
my $mm_or=shift();
$mm_or->{'PM'}{'LICENSE'}='$(INST_LIBDIR)/$(BASEEXT)/LICENSE' if -e 'LICENSE';
# Add git ref if needed
#
if (grep {$mm_or->{'VERSION_FROM'} eq $_} @{$mm_or->{'EXE_FILES'}}) {
push @{$mm_or->{'EXE_FILES'}}, $mm_or->{'VERSION_FROM'}.'.sha';
}
# Don't install docs/tmp files etc.
#
my %pm=map { $_=>$mm_or->{'PM'}{$_} } grep { !/\.(?:md|xml|pod|bak|tmp|0)$/ } keys %{$mm_or->{'PM'}};
$mm_or->{'PM'}=\%pm;
# Update Git Ref in file if needed/available
#
my $devnull=File::Spec->devnull();
if (my $git_version=qx(git rev-parse --short HEAD 2>$devnull)) {
chomp $git_version;
tie my @lines, 'Tie::File', $mm_or->{'VERSION_FROM'} . '.sha' || die "error on Tie::File, $!";
$lines[0]=$git_version;
}
$mm_or->SUPER::post_initialize;
}
sub postamble {
my $mm_or=shift();
my $postamble;
eval {ExtUtils::Git->import(); $postamble=&MY::postamble($mm_or)};
$postamble.=<<'END';
doc_xml:
@echo Generating doc
docbook-convert --markdown -o .md *.xml
docbook-convert --markdown --recursedir=./bin -o .md
docbook-convert --markdown --recursedir=./lib -o .md
docbook-convert --pod --recursedir=./bin --merge
docbook-convert --pod --recursedir=./lib --merge
pandoc --defaults=plain -f docbook -t plain README.xml > README
XML_TIDY = sh -c 'xmlstarlet fo "$$1" | sponge "$$1"'
doc_xml_tidy:
find bin -type f -name '*.xml' -exec $(XML_TIDY) _ {} \;
find lib -type f -name '*.xml' -exec $(XML_TIDY) _ {} \;
filter_scripts :
@for f in $(EXE_FILES); do \
echo "Applying PM_FILTER to $$f..."; \
cat $$f | $(PM_FILTER) > blib/script/`basename $$f`; \
done
pure_all :: filter_scripts
git_version_increment0 ::
cd docker && $(PERL) build.pl
docker_update ::
cd docker && $(PERL) build.pl
END
return $postamble;
}
sub MM::init_main {
# Strip .pl, .sh extension from script files before installing
#
my $mm_or=shift();
my @fn;
foreach my $fn (@{$mm_or->{'EXE_FILES'}}) {
(my $fn_new=$fn)=~s/\.(?:pl|sh)$//;
if ($fn_new ne $fn) {
-f $fn_new || do {
eval {symlink(abs_path($fn), $fn_new)} || copy(abs_path($fn), $fn_new)
}
}
push @fn, $fn_new;
}
$mm_or->{'EXE_FILES'}=\@fn;
$mm_or->SUPER::init_main();
}