From 537a0583b314f85d44f36cabdf44ce70a23fa358 Mon Sep 17 00:00:00 2001 From: Ed J Date: Sun, 17 Nov 2024 22:33:27 +0000 Subject: [PATCH] math.pd to pass build info back via Core::Dev::EXTRA --- Basic/Math/Makefile.PL | 33 ++------------------------------- Basic/Math/math.pd | 28 ++++++++++++++++++++++++++++ Basic/lib/PDL/Core/Dev.pm | 9 ++------- Basic/lib/PDL/PP.pm | 3 ++- 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/Basic/Math/Makefile.PL b/Basic/Math/Makefile.PL index c19b29a0e..e15dada15 100644 --- a/Basic/Math/Makefile.PL +++ b/Basic/Math/Makefile.PL @@ -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 { diff --git a/Basic/Math/math.pd b/Basic/Math/math.pd index 6949fcbf5..4ae5e0150 100644 --- a/Basic/Math/math.pd +++ b/Basic/Math/math.pd @@ -4,6 +4,34 @@ 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 +require File::Spec::Functions; +my $include = qq{#include "}.File::Spec::Functions::rel2abs('mconf.h').qq{"}; +$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()]; diff --git a/Basic/lib/PDL/Core/Dev.pm b/Basic/lib/PDL/Core/Dev.pm index 259e3c04c..c1fab9610 100644 --- a/Basic/lib/PDL/Core/Dev.pm +++ b/Basic/lib/PDL/Core/Dev.pm @@ -109,7 +109,6 @@ perl's C<%Config> array. # big/little endian? sub isbigendian { - use Config; my $byteorder = $Config{byteorder} || die "ERROR: Unable to find 'byteorder' in perl's Config\n"; return 1 if $byteorder eq "4321"; @@ -446,11 +445,7 @@ sub trylink { my $opt = ref $_[$#_] eq 'HASH' ? pop : {}; my ($txt,$inc,$body,$libs,$cflags) = @_; $cflags ||= ''; - require File::Spec; require File::Temp; - my $cdir = sub { return File::Spec->catdir(@_)}; - my $cfile = sub { return File::Spec->catfile(@_)}; - use Config; # check if MakeMaker should be used to preprocess the libs for my $key(keys %$opt) {$opt->{lc $key} = $opt->{$key}} my $mmprocess = exists $opt->{makemaker} && $opt->{makemaker}; @@ -464,11 +459,11 @@ sub trylink { print "processed LIBS: $libs[0]\n" unless $hide; $libs = $libs[0]; # replace by preprocessed libs } - print " Trying $txt...\n " unless $txt =~ /^\s*$/; + print " Trying $txt...\n " if $txt =~ /\S/; my $HIDE = !$hide ? '' : '>/dev/null 2>&1'; if($^O =~ /mswin32/i) {$HIDE = '>NUL 2>&1'} my $tempd = File::Temp::tempdir(CLEANUP=>1) || die "trylink: could not make temp dir"; - my ($tc,$te) = map {&$cfile($tempd,"testfile$_")} ('.c',''); + my ($tc,$te) = map catfile($tempd,"testfile$_"), ('.c',''); open FILE,">$tc" or die "trylink: couldn't open testfile `$tc' for writing, $!"; my $prog = <<"EOF"; $inc diff --git a/Basic/lib/PDL/PP.pm b/Basic/lib/PDL/PP.pm index 42ec9484c..d1212a1f0 100644 --- a/Basic/lib/PDL/PP.pm +++ b/Basic/lib/PDL/PP.pm @@ -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 $@;