Math-Cephes
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
my $is_s390 = ($arch =~ /^s390x?-/i);
my $is_m68k = ($arch =~ /^m68k-/i);
my $is_ppc = ($arch =~ /^powerpc(64)?-/i);
my $is_parisc = ($arch =~ /^hppa-/i);
my $is_sol = ($arch =~ /sun4-solaris|sparc/i);
my $is_dar = ($arch =~ /darwin/i);
my $is_cyg = ($arch =~ /cygwin/i || ($arch =~ /MSWin32/i && !$is_win32));
my $is_vms = ($arch =~ /vms/i);
my $dmake = ($Config{make} eq 'dmake');
######################################
# for dmake, fool WriteMakefile into thinking there's a libmd lib
if ($dmake) {
my $lib = 'libmd' . $Config{lib_ext};
my $dummy = catfile $libmd, $lib;
open(my $dummy_fh, '>',$dummy) or die "Cannot create $dummy: $!";
close $dummy_fh;
}
######################################
my @clean = qw(libmd/setprec.c libmd/mconf.h libmd/sqrt.c);
my %opts = (
NAME => 'Math::Cephes',
MYEXTLIB => "$libmd/libmd\$(LIB_EXT)",
VERSION_FROM => 'lib/Math/Cephes.pm',
OBJECT => 'Cephes_wrap.o arrays.o',
INC => "-I$libmd",
EXE_FILES => [ 'pmath' ],
META_MERGE => {
resources => {
repository => 'https://github.com/shlomif/Math-Cephes',
},
},
dist => {
SUFFIX => 'gz',
COMPRESS => 'gzip -9f',
},
clean => { FILES => "@clean"},
);
my $eu_version = $ExtUtils::MakeMaker::VERSION;
if ($eu_version >= 5.43) {
$opts{ABSTRACT} = 'Perl interface to the math cephes library';
# $opts{AUTHOR} = 'Randy Kobes <r.kobes@uwinnipeg.ca>';
$opts{AUTHOR} = 'Shlomi Fish <shlomif@cpan.org>';
$opts{CAPI} = 'TRUE' if $arch =~ /-object\b/i;
}
if ($eu_version >= 6.31) {
$opts{LICENSE} = 'perl';
}
if ($eu_version >= 6.48) {
$opts{MIN_PERL_VERSION} = '5.008';
}
my $mconf = catfile $libmd, 'mconf.h';
my %defs = (HAVE_LONG_DOUBLE => 'd_longdbl',
SIZEOF_INT => 'intsize',
RETSIGTYPE => 'd_voidsig',
HAVE_MALLOC_H => 'i_malloc',
HAVE_STRING_H => 'i_string',
VOLATILE => 'd_volatile',
);
my $vals = {RETSIGTYPE => {define => 'void', undef => 'int'},
VOLATILE => {define => 'volatile', undef => ''},
};
if ($is_win32 or $is_387 or $is_cyg) {
$defs{IBMPC} = 1;
}
elsif ($is_sol or $is_s390 or $is_m68k or $is_ppc or $is_parisc) {
$defs{WORDS_BIGENDIAN} = 1;
$defs{FLOAT_WORDS_BIGENDIAN} = 1;
$defs{UNK} = 1;
}
elsif ($is_dar) {
require POSIX;
my $machine = (POSIX::uname())[4];
if ($machine eq 'i386' or $machine eq 'x86_64') {
$defs{IBMPC} = 1;
}
else {
$defs{WORDS_BIGENDIAN} = 1;
$defs{FLOAT_WORDS_BIGENDIAN} = 1;
$defs{MIEEE} = 1;
}
}
elsif ($is_vms) {
$defs{DEC} = 1;
}
else {
$defs{UNK} = 1;
}
my $match = join '|', keys %defs;
open(my $mconf_fh, '>', $mconf) or die "Cannot open $mconf: $!";
while (my $line = <DATA>) {
if ($line =~ /\#define\s+($match)/) {
my $def = $1;
print {$mconf_fh} fix_mconf($def, $defs{$def});
}
elsif ($line =~ /^\#define XPD/) {
my $lds = $Config{longdblsize};
my $xpd = ($is_387 and $lds and $lds == 12) ? '0,' : '';
print {$mconf_fh} qq{\#define XPD $xpd\n};
}
else {
print {$mconf_fh} $line;
}
}
close $mconf_fh;
WriteMakefile(%opts);
my $message;
if ($is_sol or $is_dar or $is_win32 or $is_387) {
$message = <<"END";
( run in 0.863 second using v1.01-cache-2.11-cpan-71847e10f99 )