Algorithm-Classifier-IsolationForest

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

# Install-time C build support.
#
# When Inline::C is usable at configure time (and IF_NO_C isn't set), the
# generated Makefile gains a rule that compiles the Inline::C backend once
# during `make` and installs the shared object with the distribution, so
# users never pay the first-load compile and need neither a C compiler nor
# the Inline modules at run time.
#
# The IF_* environment variables (IF_OPT, IF_ARCH, IF_NATIVE, IF_NO_OPENMP)
# are captured *now* -- set them when running `perl Makefile.PL`, not
# `make` -- and recorded in the generated
# Algorithm::Classifier::IsolationForest::BuildFlags module.  At run time
# those recorded values are the defaults: a process requesting the same
# flags loads the prebuilt object via XSLoader; one requesting different
# flags (or setting IF_RUNTIME_BUILD=1) falls back to the classic runtime
# Inline::C build under _Inline/.  Validation mirrors the module's own,
# since these values reach a compiler command line.
# ---------------------------------------------------------------------------
my $if_opt = '-O3';
if ( defined $ENV{IF_OPT} ) {
	if ( $ENV{IF_OPT} =~ /\A-O[0123sgz]\z/ ) {
		$if_opt = $ENV{IF_OPT};
	} else {
		warn "Makefile.PL: ignoring invalid IF_OPT value '$ENV{IF_OPT}' "
			. "(expected one of -O0 -O1 -O2 -O3 -Os -Og -Oz); using $if_opt\n";
	}
}
my $if_arch = '';
if ( defined $ENV{IF_ARCH} ) {
	if ( $ENV{IF_ARCH} eq '' or $ENV{IF_ARCH} eq 'none' ) {
		$if_arch = '';    # explicit opt-out, same as the module's handling
	} elsif ( $ENV{IF_ARCH} =~ /\A[A-Za-z0-9_.+=-]+\z/ ) {
		$if_arch = $ENV{IF_ARCH};
	} else {
		warn "Makefile.PL: ignoring invalid IF_ARCH value '$ENV{IF_ARCH}'\n";
	}
} elsif ( $ENV{IF_NATIVE} ) {
	$if_arch = 'native';
}
my $if_no_openmp = $ENV{IF_NO_OPENMP} ? 1 : 0;

# The install-time build needs Inline::C at make time and a Makefile rule
# syntax (env assignment prefixing the command) that nmake doesn't grok;
# without it the module simply keeps its historic behaviour of compiling
# at first load when Inline::C is present then.
my $prebuilt
	= ( !$ENV{IF_NO_C} && $^O ne 'MSWin32' && eval { require Inline; Inline->VERSION('0.44'); require Inline::C; 1 } )
	? 1
	: 0;

# Record the captured configuration where the module can read it at load
# time.  Generated before WriteMakefile so ExtUtils::MakeMaker's lib/ scan
# picks it up for blib and install.  Not in MANIFEST: it is per-install
# state, never shipped.
my $bf_path = 'lib/Algorithm/Classifier/IsolationForest/BuildFlags.pm';
open my $bf_fh, '>', $bf_path
	or die "Makefile.PL: can't write $bf_path: $!";
print $bf_fh <<"BUILDFLAGS";
package Algorithm::Classifier::IsolationForest::BuildFlags;

# AUTOGENERATED by Makefile.PL -- do not edit and do not add to MANIFEST.
# Records per-install C build configuration; regenerate by re-running
# `perl Makefile.PL` (with IF_* environment variables as desired).

use strict;
use warnings;

=head1 NAME

Algorithm::Classifier::IsolationForest::BuildFlags - C build flags captured at configure time

=head1 DESCRIPTION

Autogenerated by Makefile.PL.  Records the IF_* environment values that
were active when the distribution was configured, and whether a prebuilt
Inline::C object was scheduled for installation.  Read once by
Algorithm::Classifier::IsolationForest at load time; see "NATIVE
ACCELERATION" in that module's documentation.

=head1 FUNCTIONS

=head2 flags

Returns a hashref with the keys C<opt>, C<arch>, C<no_openmp>, and
C<prebuilt>.

=cut

sub flags {
	return {
		opt       => '$if_opt',
		arch      => '$if_arch',
		no_openmp => $if_no_openmp,
		prebuilt  => $prebuilt,
	};
}

1;
BUILDFLAGS
close $bf_fh or die "Makefile.PL: closing $bf_path failed: $!";

# Appended to the Makefile when the install-time build is on.  Modelled on
# what Inline::MakeMaker generates, with two differences: only the one
# module that actually embeds C gets a rule (Inline::MakeMaker emits one
# per .pm in lib/), and install mode is signalled to the module via
# IF_INSTALL_BUILD=1 in the rule's environment instead of a global
# -MInline=_INSTALL_ import, so the module can pass Inline's _INSTALL_
# config itself alongside NAME/VERSION.  Inline's install mode reads the
# version and blib/arch destination from @ARGV.  The trailing -e writes a
# stub .inl file satisfying the make dependency (also what
# Inline::MakeMaker does); the compiled object itself lands under
# blib/arch/auto/ and is picked up by `make install`.
sub MY::postamble {
	return '' unless $prebuilt;
	return <<'POSTAMBLE';
# --- Inline::C install-time build (generated by Makefile.PL):

Algorithm-Classifier-IsolationForest.inl : pm_to_blib
	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::s...

dynamic :: Algorithm-Classifier-IsolationForest.inl



( run in 0.511 second using v1.01-cache-2.11-cpan-995e09ba956 )