Skip to content

Commit

Permalink
math.pd to pass build info back via Core::Dev::EXTRA
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 17, 2024
1 parent 8d8b832 commit 553b06d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
33 changes: 2 additions & 31 deletions Basic/Math/Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,39 +1,10 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;

# Files for each routine (.c assumed)
my %source = qw(
j0 j0
j1 j1
jn jn
y0 j0
y1 j1
yn yn
);
my @keys = sort keys %source;

my $libs = get_maths_libs();
# Test for presence of besfuncs
my $include = qq{#include "mconf.h"};
$source{$_} = 'system' for grep trylink('', $include, "$_(1.);", $libs), qw(j0 j1 y0 y1);
$source{$_} = 'system' for grep trylink('', $include, "$_(1,1.);", $libs), qw(jn yn);

my @pack = (["math.pd", qw(Math PDL::Math)]);
my %hash = pdlpp_stdargs_int(@pack);

my %seen; # Build object file list
foreach my $func (@keys) {
my $file = $source{$func};
next if $file eq 'system';
die "File for function $func not found\n" if $file eq '';
$hash{OBJECT} .= " $file\$(OBJ_EXT)" unless $seen{$file}++;
}

# Add support routines
$hash{OBJECT} .= join '', map " $_\$(OBJ_EXT)", qw(const mtherr polevl cpoly ndtri);

$hash{LIBS}[0] .= " $libs";
$hash{OBJECT} .= $PDL::Core::Dev::EXTRAS{'math.pd'}{OBJECT};
$hash{LIBS}[0] .= " " . PDL::Core::Dev::get_maths_libs();

undef &MY::postamble; # suppress warning
*MY::postamble = sub {
Expand Down
27 changes: 27 additions & 0 deletions Basic/Math/math.pd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ use Config;
use PDL::Types qw(ppdefs ppdefs_complex types);
require PDL::Core::Dev;

{ # pass info back to Makefile.PL
# Files for each routine (.c assumed)
my %source = qw(
j0 j0
j1 j1
jn jn
y0 j0
y1 j1
yn yn
);
my @keys = sort keys %source;
my $libs = PDL::Core::Dev::get_maths_libs();
# Test for presence of besfuncs
my $include = qq{#include "mconf.h"};
$source{$_} = 'system' for grep PDL::Core::Dev::trylink('', $include, "$_(1.);", $libs), qw(j0 j1 y0 y1);
$source{$_} = 'system' for grep PDL::Core::Dev::trylink('', $include, "$_(1,1.);", $libs), qw(jn yn);
my %seen; # Build object file list
foreach my $func (@keys) {
my $file = $source{$func};
next if $file eq 'system';
die "File for function $func not found\n" if $file eq '';
$PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= " $file\$(OBJ_EXT)" unless $seen{$file}++;
}
# Add support routines
$PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= join '', map " $_\$(OBJ_EXT)", qw(const mtherr polevl cpoly ndtri);
}

my $R = [ppdefs()];
my $F = [map $_->ppsym, grep $_->real && !$_->integer, types()];
my $C = [ppdefs_complex()];
Expand Down
3 changes: 2 additions & 1 deletion Basic/lib/PDL/PP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ sub list_functions {
local *PDL::PP::pp_def = sub { push @funcs, (_pp_parsename($_[0]))[0]};
undef &PDL::PP::pp_done;
local *PDL::PP::pp_done = sub {};
$_ = '' for $::PDLMOD, $::CALLPACK, $::PDLOBJ; # stop warnings
$::PDLMOD = $file;
$_ ||= '' for $::CALLPACK, $::PDLOBJ; # stop warnings
require File::Spec::Functions;
do ''.File::Spec::Functions::rel2abs($file);
die $@ if $@;
Expand Down

0 comments on commit 553b06d

Please sign in to comment.