require
5.006;
$| = 1;
our
%args
=
map
{
split
/\s*=\s*/ }
@ARGV
;
our
$LIBS
=
$args
{ LIBS } ||
"-lgmp"
;
our
$INC
=
$args
{ INC };
our
$DEFS
=
''
;
print
"\nThis module requires gmp-4.2.0 (or later)\n\n"
;
my
$use_64_bit_int
= 0;
my
$use_long_double
= 0;
my
$use_quadmath
= 0;
my
$defines
= $] < 5.008 ?
"-DOLDPERL"
:
"-DNEWPERL"
;
unless
(
$Config
{ivsize} < 8 ||
$Config
{ivtype} eq
'long'
) {
$defines
.=
" -DMATH_GMPF_NEED_LONG_LONG_INT"
;
}
if
(
$Config::Config
{nvsize} > 8 ) {
if
(
$Config
{nvtype} eq
'__float128'
) {
$use_quadmath
= 1}
else
{
$use_long_double
= 1}
}
$defines
=~ /-DMATH_GMPF_NEED_LONG_LONG_INT/ ?
print
"Building with 64-bit'long long' support\n"
:
print
"Building without 64-bit 'long long' support\n"
;
$use_long_double
== 1 ?
print
"Building with 'long double' support\n"
:
print
"Building without 'long double' support\n"
;
$use_quadmath
== 1 ?
print
"Building with '__float128' support\n"
:
print
"Building without '__float128' support\n"
;
if
($] < 5.035010) {
my
%flags
;
{
no
strict
'refs'
;
for
my
$flag
(
qw(
SVf_IOK
SVf_NOK
SVf_POK
SVp_IOK
SVp_NOK
SVp_POK
)
) {
if
(
defined
&{
'B::'
.
$flag
}) {
$flags
{
$flag
} = &{
'B::'
.
$flag
};
}
}
}
sub
flags {
my
$flags
= B::svref_2object(\(
$_
[0]))->FLAGS;
join
' '
,
sort
grep
$flags
&
$flags
{
$_
},
keys
%flags
;
}
my
$pv_nv_bug
= 0;
my
$test_nv
= 1.3;
my
$buggery
=
"$test_nv"
;
my
$f
= flags(
$test_nv
);
if
(
$f
=~ /SVf_POK/) {
print
"Dealing with unhelpful setting of POK flag\n"
;
$pv_nv_bug
= 1;
}
if
(
$pv_nv_bug
) {
print
"\n Defining GMPF_PV_NV_BUG\n\n"
;
$defines
.=
" -DGMPF_PV_NV_BUG"
;
$DEFS
.=
" -DGMPF_PV_NV_BUG"
;
}
else
{
print
"\n Not defining GMPF_PV_NV_BUG\n\n"
;
}
}
else
{
print
"Not defining GMPF_PV_NV_BUG as perl version >= 5.035010\n\n"
}
if
($^O =~ /MSWin32/i && $] < 5.022) {
$defines
.=
" -D_WIN32_BIZARRE_INFNAN"
}
my
$libopts
=
'-lgmp'
;
$libopts
=
'-lquadmath -lgmp'
if
($^O eq
'cygwin'
&&
$use_quadmath
);
my
%options
= (
NAME
=>
'Math::GMPf'
,
AUTHOR
=>
'Sisyphus (sisyphus at (@) cpan dot (.) org)'
,
ABSTRACT
=>
'Perl interface to the GMP floating point functions'
,
DEFINE
=>
$defines
,
LIBS
=> [
$libopts
],
LICENSE
=>
'perl'
,
VERSION_FROM
=>
'GMPf.pm'
,
PREREQ_PM
=> {
'Exporter'
=>
'5.58'
,
'Test::More'
=>
'0.88'
},
clean
=> {
FILES
=>
'out1.txt out2.txt out3.txt out4.txt out5.txt out6.txt out7.txt out21.txt out22.txt'
},
META_MERGE
=> {
'meta-spec'
=> {
version
=> 2 },
resources
=> {
repository
=> {
type
=>
'git'
,
},
},
},
);
WriteMakefile(
%options
);