# This Makefile.PL for Stats-LikeR 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.010;
use ExtUtils::MakeMaker 6.48;

use Config;
use File::Temp ();
use File::Spec ();
# LikeR.xs needs C99: // comments, declarations inside blocks and for(),
# <stdint.h>, and `restrict` where the compiler has a spelling for it.
# The flag that asks for C99 is per-vendor, and it cannot be guessed from
# $Config{cc}: that is plain "cc" for Oracle Studio on Solaris and for aCC
# on HP-UX, both of which used to match this file's old /\b(?:g?cc|clang)\b/
# test, get handed -std=gnu99, and fail the build on an illegal option.
# So each candidate is trial-compiled and the first one that actually works
# wins: -std=gnu99/-std=c99 for gcc and clang (all BSDs included),
# -xc99=all for Studio, -qlanglvl=extc99 for AIX xlc, -AC99 for HP-UX, and
# finally '' for a compiler whose default mode is already C99. MSVC is
# skipped outright -- it needs no flag for any of the above and merely warns
# on switches it does not know, which would make the probe pick a no-op.
my $std = '';
unless ($Config{cc} =~ /(?:^|[\/\\])cl(?:\.exe)?$/i) {
my $c99 = "#include <stdint.h>\n"
. "int main(void) { uint64_t u = 0; // C99 comment\n"
. "for (int i = 0; i < 3; i++) { u += (uint64_t)i; }\n"
. "return (int)(u - 3); }\n";
my $dir = File::Temp::tempdir(CLEANUP => 1);
my $src = File::Spec->catfile($dir, 'c99probe.c');
my $obj = File::Spec->catfile($dir, 'c99probe.o');
if (open my $probe_fh, '>', $src) {
print {$probe_fh} $c99;
close $probe_fh;
my $quiet = File::Spec->devnull;
for my $flag ('-std=gnu99', '-std=c99', '-xc99=all', '-qlanglvl=extc99', '-AC99', '') {
next if system("$Config{cc} $flag -c $src -o $obj > $quiet 2> $quiet") != 0;
$std = $flag eq '' ? '' : " $flag";
last;
}
}
}
# On a long-double perl, LikeR.xs wants the `l` suffixed libm functions so that
# an NV is not silently computed at double precision. They are C99, but some
# libms (the thinner BSD ones especially) do not ship the whole set, so the set
# is link-tested as a unit: all of it, or the module falls back to the double
# functions exactly as it did before. __float128 needs no probe -- quadmath.h
# and -lquadmath come with the quadmath perl itself.
my $define = '';
if ($Config{nvtype} eq 'long double') {
my $ld = "#include <math.h>\n"
. "int main(void) { int e; long double x = 1.0L;\n"
. "  volatile long double r = lgammal(x) + sqrtl(x) + logl(x) + log1pl(x)\n"
. "    + log2l(x) + log10l(x) + expl(x) + powl(x, x) + floorl(x) + ceill(x) + roundl(x)\n"
. "    + rintl(x) + truncl(x) + fmaxl(x, x) + erfcl(x) + asinl(x) + sinhl(x) + coshl(x)\n"
. "    + tanhl(x) + fabsl(x) + ldexpl(x, 2) + frexpl(x, &e)\n"
. "    + acosl(x) + cosl(x) + sinl(x);\n"
. "  return (int)r * 0; }\n";
my $dir = File::Temp::tempdir(CLEANUP => 1);
my $src = File::Spec->catfile($dir, 'ldmath.c');
my $bin = File::Spec->catfile($dir, 'ldmath');
if (open my $ld_fh, '>', $src) {
print {$ld_fh} $ld;
close $ld_fh;
my $quiet = File::Spec->devnull;
$define = '-DLIKER_HAVE_LONG_DOUBLE_MATH'
if system("$Config{cc}$std -o $bin $src -lm > $quiet 2> $quiet") == 0;
}
warn "Stats::LikeR: this libm is missing some long double math functions;\n"
. "  falling back to double precision internals.\n" unless $define;
}
{
package MY;
sub libscan {
my ($self, $path) = @_;
return '' if $path =~ /\.pl\z/ && $path !~ m{/};
return $self->SUPER::libscan($path);
}
}

my %WriteMakefileArgs = (
  "ABSTRACT" => "Get basic statistical functions, like in R, but with Perl using XS for performance",
  "AUTHOR" => "David E. Condon <dec986\@gmail.com>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => "6.48"
  },
  "DISTNAME" => "Stats-LikeR",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010",
  "NAME" => "Stats::LikeR",
  "PREREQ_PM" => {
    "Cwd" => 0,
    "Scalar::Util" => "1.22",
    "Test::Exception" => 0,
    "Test::LeakTrace" => 0,
    "Test::More" => 0,
    "autodie" => 0
  },
  "VERSION" => "0.31",
  "test" => {
    "TESTS" => "t/*.t"
  }
);

%WriteMakefileArgs = (
    %WriteMakefileArgs,
    CCFLAGS => $Config::Config{ccflags} . $std,
    DEFINE => $define,
    LIBS => ['-lm'],
    PL_FILES => {},
);

my %FallbackPrereqs = (
  "Cwd" => 0,
  "Scalar::Util" => "1.22",
  "Test::Exception" => 0,
  "Test::LeakTrace" => 0,
  "Test::More" => 0,
  "autodie" => 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) };

WriteMakefile(%WriteMakefileArgs);
