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             }
30             else {
31             warn "Makefile.PL: ignoring invalid IF_OPT value '$ENV{IF_OPT}' "
32             . "(expected one of -O0 -O1 -O2 -O3 -Os -Og -Oz); using $if_opt\n";
33             }
34             }
35             my $if_arch = '';
36             if ( defined $ENV{IF_ARCH} ) {
37             if ( $ENV{IF_ARCH} eq '' or $ENV{IF_ARCH} eq 'none' ) {
38             $if_arch = ''; # explicit opt-out, same as the module's handling
39             }
40             elsif ( $ENV{IF_ARCH} =~ /\A[A-Za-z0-9_.+=-]+\z/ ) {
41             $if_arch = $ENV{IF_ARCH};
42             }
43             else {
44             warn "Makefile.PL: ignoring invalid IF_ARCH value '$ENV{IF_ARCH}'\n";
45             }
46             }
47             elsif ( $ENV{IF_NATIVE} ) {
48             $if_arch = 'native';
49             }
50             my $if_no_openmp = $ENV{IF_NO_OPENMP} ? 1 : 0;
51              
52             # The install-time build needs Inline::C at make time and a Makefile rule
53             # syntax (env assignment prefixing the command) that nmake doesn't grok;
54             # without it the module simply keeps its historic behaviour of compiling
55             # at first load when Inline::C is present then.
56             my $prebuilt = (
57             !$ENV{IF_NO_C}
58             && $^O ne 'MSWin32'
59             && eval { require Inline; Inline->VERSION('0.44'); require Inline::C; 1 }
60             ) ? 1 : 0;
61              
62             # Record the captured configuration where the module can read it at load
63             # time. Generated before WriteMakefile so ExtUtils::MakeMaker's lib/ scan
64             # picks it up for blib and install. Not in MANIFEST: it is per-install
65             # state, never shipped.
66             my $bf_path = 'lib/Algorithm/Classifier/IsolationForest/BuildFlags.pm';
67             open my $bf_fh, '>', $bf_path
68             or die "Makefile.PL: can't write $bf_path: $!";
69             print $bf_fh <<"BUILDFLAGS";
70             package Algorithm::Classifier::IsolationForest::BuildFlags;
71              
72             # AUTOGENERATED by Makefile.PL -- do not edit and do not add to MANIFEST.
73             # Records per-install C build configuration; regenerate by re-running
74             # `perl Makefile.PL` (with IF_* environment variables as desired).
75              
76             use strict;
77             use warnings;
78              
79             =head1 NAME
80              
81             Algorithm::Classifier::IsolationForest::BuildFlags - C build flags captured at configure time
82              
83             =head1 DESCRIPTION
84              
85             Autogenerated by Makefile.PL. Records the IF_* environment values that
86             were active when the distribution was configured, and whether a prebuilt
87             Inline::C object was scheduled for installation. Read once by
88             Algorithm::Classifier::IsolationForest at load time; see "NATIVE
89             ACCELERATION" in that module's documentation.
90              
91             =head1 FUNCTIONS
92              
93             =head2 flags
94              
95             Returns a hashref with the keys C, C, C, and
96             C.
97              
98             =cut
99              
100             sub flags {
101             return {
102             opt => '$if_opt',
103             arch => '$if_arch',
104             no_openmp => $if_no_openmp,
105             prebuilt => $prebuilt,
106             };
107             }
108              
109             1;
110             BUILDFLAGS
111             close $bf_fh or die "Makefile.PL: closing $bf_path failed: $!";
112              
113             # Appended to the Makefile when the install-time build is on. Modelled on
114             # what Inline::MakeMaker generates, with two differences: only the one
115             # module that actually embeds C gets a rule (Inline::MakeMaker emits one
116             # per .pm in lib/), and install mode is signalled to the module via
117             # IF_INSTALL_BUILD=1 in the rule's environment instead of a global
118             # -MInline=_INSTALL_ import, so the module can pass Inline's _INSTALL_
119             # config itself alongside NAME/VERSION. Inline's install mode reads the
120             # version and blib/arch destination from @ARGV. The trailing -e writes a
121             # stub .inl file satisfying the make dependency (also what
122             # Inline::MakeMaker does); the compiled object itself lands under
123             # blib/arch/auto/ and is picked up by `make install`.
124             sub MY::postamble {
125             return '' unless $prebuilt;
126             return <<'POSTAMBLE';
127             # --- Inline::C install-time build (generated by Makefile.PL):
128              
129             Algorithm-Classifier-IsolationForest.inl : pm_to_blib
130             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)
131              
132             dynamic :: Algorithm-Classifier-IsolationForest.inl
133              
134             POSTAMBLE
135             }
136              
137             my %WriteMakefileArgs = (
138             NAME => 'Algorithm::Classifier::IsolationForest',
139             AUTHOR => q{Zane C. Bowers-Hadley },
140             VERSION_FROM => 'lib/Algorithm/Classifier/IsolationForest.pm',
141             ABSTRACT_FROM => 'lib/Algorithm/Classifier/IsolationForest.pm',
142             LICENSE => 'lgpl_2_1',
143             MIN_PERL_VERSION => '5.006',
144             INST_SCRIPT => 'bin',
145             EXE_FILES => ['src_bin/iforest'],
146             CONFIGURE_REQUIRES => {
147             'ExtUtils::MakeMaker' => '0',
148             },
149             TEST_REQUIRES => {
150             'Test::More' => '0',
151             'File::Temp' => '0',
152             'JSON::PP' => '0',
153             'List::Util' => '0',
154             },
155             PREREQ_PM => {
156             'App::Cmd' => '0',
157             'Carp' => '0',
158             'Config' => '0',
159             'File::Slurp' => '0',
160             'File::Spec' => '0',
161             'File::Temp' => '0',
162             'JSON::PP' => '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             },
187             },
188             resources => {
189             repository => {
190             type => 'git',
191             url => 'git@github.com:LilithSec/Algorithm-Classifier-IsolationForest.git',
192             web => 'https://github.com/LilithSec/Algorithm-Classifier-IsolationForest',
193             },
194             },
195             }
196             );
197              
198             # Compatibility with old versions of ExtUtils::MakeMaker
199             unless ( eval { ExtUtils::MakeMaker->VERSION('6.64'); 1 } ) {
200             my $test_requires = delete $WriteMakefileArgs{TEST_REQUIRES} || {};
201             @{ $WriteMakefileArgs{PREREQ_PM} }{ keys %$test_requires } = values %$test_requires;
202             }
203              
204             unless ( eval { ExtUtils::MakeMaker->VERSION('6.55_03'); 1 } ) {
205             my $build_requires = delete $WriteMakefileArgs{BUILD_REQUIRES} || {};
206             @{ $WriteMakefileArgs{PREREQ_PM} }{ keys %$build_requires } = values %$build_requires;
207             }
208              
209             delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
210             unless eval { ExtUtils::MakeMaker->VERSION('6.52'); 1 };
211             delete $WriteMakefileArgs{MIN_PERL_VERSION}
212             unless eval { ExtUtils::MakeMaker->VERSION('6.48'); 1 };
213             delete $WriteMakefileArgs{LICENSE}
214             unless eval { ExtUtils::MakeMaker->VERSION('6.31'); 1 };
215              
216             WriteMakefile(%WriteMakefileArgs);