File Coverage

Makefile.PL
Criterion Covered Total %
statement n/a
branch n/a
condition n/a
subroutine n/a
pod n/a
total n/a


line stmt bran cond sub pod time code
1             use 5.006;
2             use strict;
3             use warnings;
4             use ExtUtils::MakeMaker;
5              
6             # ---------------------------------------------------------------------------
7             # Install-time C build support.
8             #
9             # When Inline::C is usable at configure time (and IF_NO_C isn't set), the
10             # generated Makefile gains a rule that compiles the Inline::C backend once
11             # during `make` and installs the shared object with the distribution, so
12             # users never pay the first-load compile and need neither a C compiler nor
13             # the Inline modules at run time.
14             #
15             # The IF_* environment variables (IF_OPT, IF_ARCH, IF_NATIVE, IF_NO_OPENMP)
16             # are captured *now* -- set them when running `perl Makefile.PL`, not
17             # `make` -- and recorded in the generated
18             # Algorithm::Classifier::IsolationForest::BuildFlags module. At run time
19             # those recorded values are the defaults: a process requesting the same
20             # flags loads the prebuilt object via XSLoader; one requesting different
21             # flags (or setting IF_RUNTIME_BUILD=1) falls back to the classic runtime
22             # Inline::C build under _Inline/. Validation mirrors the module's own,
23             # since these values reach a compiler command line.
24             # ---------------------------------------------------------------------------
25             my $if_opt = '-O3';
26             if ( defined $ENV{IF_OPT} ) {
27             if ( $ENV{IF_OPT} =~ /\A-O[0123sgz]\z/ ) {
28             $if_opt = $ENV{IF_OPT};
29             } else {
30             warn "Makefile.PL: ignoring invalid IF_OPT value '$ENV{IF_OPT}' "
31             . "(expected one of -O0 -O1 -O2 -O3 -Os -Og -Oz); using $if_opt\n";
32             }
33             }
34             my $if_arch = '';
35             if ( defined $ENV{IF_ARCH} ) {
36             if ( $ENV{IF_ARCH} eq '' or $ENV{IF_ARCH} eq 'none' ) {
37             $if_arch = ''; # explicit opt-out, same as the module's handling
38             } elsif ( $ENV{IF_ARCH} =~ /\A[A-Za-z0-9_.+=-]+\z/ ) {
39             $if_arch = $ENV{IF_ARCH};
40             } else {
41             warn "Makefile.PL: ignoring invalid IF_ARCH value '$ENV{IF_ARCH}'\n";
42             }
43             } elsif ( $ENV{IF_NATIVE} ) {
44             $if_arch = 'native';
45             }
46             my $if_no_openmp = $ENV{IF_NO_OPENMP} ? 1 : 0;
47              
48             # The install-time build needs Inline::C at make time and a Makefile rule
49             # syntax (env assignment prefixing the command) that nmake doesn't grok;
50             # without it the module simply keeps its historic behaviour of compiling
51             # at first load when Inline::C is present then.
52             my $prebuilt
53             = ( !$ENV{IF_NO_C} && $^O ne 'MSWin32' && eval { require Inline; Inline->VERSION('0.44'); require Inline::C; 1 } )
54             ? 1
55             : 0;
56              
57             # Record the captured configuration where the module can read it at load
58             # time. Generated before WriteMakefile so ExtUtils::MakeMaker's lib/ scan
59             # picks it up for blib and install. Not in MANIFEST: it is per-install
60             # state, never shipped.
61             my $bf_path = 'lib/Algorithm/Classifier/IsolationForest/BuildFlags.pm';
62             open my $bf_fh, '>', $bf_path
63             or die "Makefile.PL: can't write $bf_path: $!";
64             print $bf_fh <<"BUILDFLAGS";
65             package Algorithm::Classifier::IsolationForest::BuildFlags;
66              
67             # AUTOGENERATED by Makefile.PL -- do not edit and do not add to MANIFEST.
68             # Records per-install C build configuration; regenerate by re-running
69             # `perl Makefile.PL` (with IF_* environment variables as desired).
70              
71             use strict;
72             use warnings;
73              
74             =head1 NAME
75              
76             Algorithm::Classifier::IsolationForest::BuildFlags - C build flags captured at configure time
77              
78             =head1 DESCRIPTION
79              
80             Autogenerated by Makefile.PL. Records the IF_* environment values that
81             were active when the distribution was configured, and whether a prebuilt
82             Inline::C object was scheduled for installation. Read once by
83             Algorithm::Classifier::IsolationForest at load time; see "NATIVE
84             ACCELERATION" in that module's documentation.
85              
86             =head1 FUNCTIONS
87              
88             =head2 flags
89              
90             Returns a hashref with the keys C, C, C, and
91             C.
92              
93             =cut
94              
95             sub flags {
96             return {
97             opt => '$if_opt',
98             arch => '$if_arch',
99             no_openmp => $if_no_openmp,
100             prebuilt => $prebuilt,
101             };
102             }
103              
104             1;
105             BUILDFLAGS
106             close $bf_fh or die "Makefile.PL: closing $bf_path failed: $!";
107              
108             # Appended to the Makefile when the install-time build is on. Modelled on
109             # what Inline::MakeMaker generates, with two differences: only the one
110             # module that actually embeds C gets a rule (Inline::MakeMaker emits one
111             # per .pm in lib/), and install mode is signalled to the module via
112             # IF_INSTALL_BUILD=1 in the rule's environment instead of a global
113             # -MInline=_INSTALL_ import, so the module can pass Inline's _INSTALL_
114             # config itself alongside NAME/VERSION. Inline's install mode reads the
115             # version and blib/arch destination from @ARGV. The trailing -e writes a
116             # stub .inl file satisfying the make dependency (also what
117             # Inline::MakeMaker does); the compiled object itself lands under
118             # blib/arch/auto/ and is picked up by `make install`.
119             sub MY::postamble {
120             return '' unless $prebuilt;
121             return <<'POSTAMBLE';
122             # --- Inline::C install-time build (generated by Makefile.PL):
123              
124             Algorithm-Classifier-IsolationForest.inl : pm_to_blib
125             IF_INSTALL_BUILD=1 $(PERL) "-Mblib" "-MAlgorithm::Classifier::IsolationForest" -e"require Inline; my %A = (modinlname => 'Algorithm-Classifier-IsolationForest.inl', module => 'Algorithm::Classifier::IsolationForest'); my %S = (API => \%A); Inline::satisfy_makefile_dep(\%S);" $(VERSION) $(INST_ARCHLIB)
126              
127             dynamic :: Algorithm-Classifier-IsolationForest.inl
128              
129             POSTAMBLE
130             } ## end sub MY::postamble
131              
132             my %WriteMakefileArgs = (
133             NAME => 'Algorithm::Classifier::IsolationForest',
134             AUTHOR => q{Zane C. Bowers-Hadley },
135             VERSION_FROM => 'lib/Algorithm/Classifier/IsolationForest.pm',
136             ABSTRACT_FROM => 'lib/Algorithm/Classifier/IsolationForest.pm',
137             LICENSE => 'lgpl_2_1',
138             MIN_PERL_VERSION => '5.006',
139             INST_SCRIPT => 'bin',
140             EXE_FILES => ['src_bin/iforest'],
141             CONFIGURE_REQUIRES => {
142             'ExtUtils::MakeMaker' => '0',
143             },
144             TEST_REQUIRES => {
145             'Test::More' => '0',
146             'File::Temp' => '0',
147             'JSON::PP' => '0',
148             'List::Util' => '0',
149             },
150             PREREQ_PM => {
151             'App::Cmd' => '0',
152             'Carp' => '0',
153             'Config' => '0',
154             'File::Slurp' => '0',
155             'File::Spec' => '0',
156             'File::Temp' => '0',
157             'JSON::PP' => '0',
158              
159             # iforest streamd's wire protocol; XS-backed JSON when available,
160             # pure-Perl JSON::PP fallback otherwise, so it is safe as a hard
161             # prereq (streamd itself also degrades to a clear error without it).
162             'JSON::MaybeXS' => '0',
163             'List::Util' => '0',
164             'POSIX' => '0',
165             'Scalar::Util' => '0',
166             'Storable' => '0',
167             },
168             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
169             clean => {
170             FILES => 'Algorithm-Classifier-IsolationForest-* *.inl '
171             . 'lib/Algorithm/Classifier/IsolationForest/BuildFlags.pm'
172             },
173             META_MERGE => {
174             "meta-spec" => { version => 2 },
175             prereqs => {
176             runtime => {
177             # Inline / Inline::C unlock the native scoring backend
178             # (and OpenMP parallel tree-walk if libgomp is available
179             # at build time). The pure-Perl fallback works without
180             # them, just slower, so they are recommends rather than
181             # hard requires.
182             recommends => {
183             'Inline' => '0',
184             'Inline::C' => '0',
185              
186             # Unlocks the mungers knob: declarative raw-value ->
187             # number munging for tagged data, with the spec saved
188             # in the model. Everything else works without it.
189             'Algorithm::ToNumberMunger' => '0.0.1',
190             },
191             },
192             },
193             resources => {
194             repository => {
195             type => 'git',
196             url => 'git@github.com:LilithSec/Algorithm-Classifier-IsolationForest.git',
197             web => 'https://github.com/LilithSec/Algorithm-Classifier-IsolationForest',
198             },
199             },
200             }
201             );
202              
203             # Compatibility with old versions of ExtUtils::MakeMaker
204             unless ( eval { ExtUtils::MakeMaker->VERSION('6.64'); 1 } ) {
205             my $test_requires = delete $WriteMakefileArgs{TEST_REQUIRES} || {};
206             @{ $WriteMakefileArgs{PREREQ_PM} }{ keys %$test_requires } = values %$test_requires;
207             }
208              
209             unless ( eval { ExtUtils::MakeMaker->VERSION('6.55_03'); 1 } ) {
210             my $build_requires = delete $WriteMakefileArgs{BUILD_REQUIRES} || {};
211             @{ $WriteMakefileArgs{PREREQ_PM} }{ keys %$build_requires } = values %$build_requires;
212             }
213              
214             delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
215             unless eval { ExtUtils::MakeMaker->VERSION('6.52'); 1 };
216             delete $WriteMakefileArgs{MIN_PERL_VERSION}
217             unless eval { ExtUtils::MakeMaker->VERSION('6.48'); 1 };
218             delete $WriteMakefileArgs{LICENSE}
219             unless eval { ExtUtils::MakeMaker->VERSION('6.31'); 1 };
220              
221             WriteMakefile(%WriteMakefileArgs);