From 77ee0f52bf05fc98c414bae0acaaac90149c13e4 Mon Sep 17 00:00:00 2001 From: Ed J Date: Sun, 17 Nov 2024 23:28:38 +0000 Subject: [PATCH] PDL::Math switch to new lib/*.pd scheme --- Basic/.gitignore | 3 ++ Basic/Makefile.PL | 6 ++-- Basic/Math/.gitignore | 3 -- Basic/Math/Makefile.PL | 14 ---------- Basic/lib/PDL/Core/Dev.pm | 9 ++++-- Basic/{Math/math.pd => lib/PDL/Math.pd} | 7 +++-- Basic/{ => lib/PDL}/Math/NOTES | 0 Basic/{ => lib/PDL}/Math/const.c | 0 Basic/{ => lib/PDL}/Math/cpoly.c | 0 Basic/{ => lib/PDL}/Math/cpoly.h | 0 Basic/{ => lib/PDL}/Math/j0.c | 0 Basic/{ => lib/PDL}/Math/j1.c | 0 Basic/{ => lib/PDL}/Math/jn.c | 0 Basic/{ => lib/PDL}/Math/mconf.h | 0 Basic/{ => lib/PDL}/Math/mtherr.c | 0 Basic/{ => lib/PDL}/Math/ndtri.c | 0 Basic/{ => lib/PDL}/Math/polevl.c | 0 Basic/{ => lib/PDL}/Math/protos.h | 0 Basic/{ => lib/PDL}/Math/yn.c | 0 MANIFEST | 37 ++++++++++++------------- MANIFEST.SKIP | 2 +- 21 files changed, 36 insertions(+), 45 deletions(-) delete mode 100644 Basic/Math/.gitignore delete mode 100644 Basic/Math/Makefile.PL rename Basic/{Math/math.pd => lib/PDL/Math.pd} (97%) rename Basic/{ => lib/PDL}/Math/NOTES (100%) rename Basic/{ => lib/PDL}/Math/const.c (100%) rename Basic/{ => lib/PDL}/Math/cpoly.c (100%) rename Basic/{ => lib/PDL}/Math/cpoly.h (100%) rename Basic/{ => lib/PDL}/Math/j0.c (100%) rename Basic/{ => lib/PDL}/Math/j1.c (100%) rename Basic/{ => lib/PDL}/Math/jn.c (100%) rename Basic/{ => lib/PDL}/Math/mconf.h (100%) rename Basic/{ => lib/PDL}/Math/mtherr.c (100%) rename Basic/{ => lib/PDL}/Math/ndtri.c (100%) rename Basic/{ => lib/PDL}/Math/polevl.c (100%) rename Basic/{ => lib/PDL}/Math/protos.h (100%) rename Basic/{ => lib/PDL}/Math/yn.c (100%) diff --git a/Basic/.gitignore b/Basic/.gitignore index c9dd8eb72..4b816bd3a 100644 --- a/Basic/.gitignore +++ b/Basic/.gitignore @@ -3,6 +3,9 @@ lib/PDL/Bad.pm lib/PDL/Bad.xs lib/PDL/Core.c lib/PDL/Core/pdl.h +lib/PDL/Math.c +lib/PDL/Math.pm +lib/PDL/Math.xs lib/PDL/Ops.c lib/PDL/Ops.pm lib/PDL/Ops.xs diff --git a/Basic/Makefile.PL b/Basic/Makefile.PL index b7e960f4c..34821fe13 100644 --- a/Basic/Makefile.PL +++ b/Basic/Makefile.PL @@ -56,7 +56,7 @@ if (!$pthread_library) { print "\t==> Enabling perl threads will not help!\n"; } my $pthread_define = $pthread_library ? ' -DPDL_PTHREAD ' : ''; -my $libs_string = "$pthread_library -lm"; +my $libs_string = "$pthread_library ".get_maths_libs(); my $hdeps = join ' ', map catfile(qw(lib PDL Core), $_), qw(pdl.h pdlperl.h pdlcore.h pdlbroadcast.h pdlmagic.h); my @cfiles = qw(pdlcore pdlapi pdlbroadcast pdlconv pdlmagic pdlaffine pdlutil); @@ -65,8 +65,8 @@ push @cleanup, $cobj; my $core_obj = catfile(qw(lib PDL), 'Core$(OBJ_EXT)'); # the modules in PDL::LiteF, used in t/core.t -my @BUILD_CORE = qw(Bad Core Ops Slices Ufunc); -my @DIRS_CORE = qw(Primitive Math MatrixOps); +my @BUILD_CORE = qw(Bad Core Math Ops Slices Ufunc); +my @DIRS_CORE = qw(Primitive MatrixOps); # the modules needed in "use PDL" my @DIRS_BASIC = qw(IO-Misc IO-Pnm Lib-Compression Lib-FFT Lib-ImageND Lib-ImageRGB); WriteMakefile( diff --git a/Basic/Math/.gitignore b/Basic/Math/.gitignore deleted file mode 100644 index 301019cb7..000000000 --- a/Basic/Math/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Math.c -Math.pm -Math.xs diff --git a/Basic/Math/Makefile.PL b/Basic/Math/Makefile.PL deleted file mode 100644 index e15dada15..000000000 --- a/Basic/Math/Makefile.PL +++ /dev/null @@ -1,14 +0,0 @@ -use strict; -use warnings; - -my @pack = (["math.pd", qw(Math PDL::Math)]); -my %hash = pdlpp_stdargs_int(@pack); -$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 { - pdlpp_postamble_int(@pack); -}; - -WriteMakefile(%hash); diff --git a/Basic/lib/PDL/Core/Dev.pm b/Basic/lib/PDL/Core/Dev.pm index c1fab9610..c3074c4ca 100644 --- a/Basic/lib/PDL/Core/Dev.pm +++ b/Basic/lib/PDL/Core/Dev.pm @@ -179,6 +179,7 @@ sub pdlpp_postamble { join '', map _postamble($w, 0, @$_), @_; } +our %EXTRAS; sub pdlpp_eumm_update_deep { my ($eumm) = @_; my $pm = $eumm->{PM}; @@ -197,6 +198,8 @@ sub pdlpp_eumm_update_deep { my @macro_vars = pdlpp_mod_vars(my $mod = join '::', split /\//, $nolib); @$macro{@macro_vars} = pdlpp_mod_values(1, $f, $base, 1, 1); $xsb->{$base}{OBJECT} = "\$($macro_vars[1])"; + $xsb->{$base}{OBJECT} .= $EXTRAS{$f}{OBJECT} if $EXTRAS{$f}{OBJECT}; + $eumm->{INC} .= " $EXTRAS{$f}{INC}" if $EXTRAS{$f}{INC}; # global my $mtime = (stat $f)[9] // die "$f: $!"; open my $fh, ">", $pmfile or die "$pmfile: $!"; # XSMULTI needs this print $fh "package $mod;\nour \$VER"."SION = '$global_version';\n1;\n"; # break is so cpanm doesn't try to parse as version @@ -204,12 +207,13 @@ sub pdlpp_eumm_update_deep { utime $mtime - 120, $mtime - 120, $pmfile; # so is out of date push @pd_srcs, [$f, $base, $mod, '', 1]; $eumm->{clean}{FILES} .= join ' ', '', $pmfile, map "\$($_)", @macro_vars; + $eumm->{clean}{FILES} .= $EXTRAS{$f}{OBJECT} if $EXTRAS{$f}{OBJECT}; } @pd_srcs; } sub pdlpp_list_functions { - my ($src, $internal) = @_; + my ($src, $internal, $base) = @_; my $abs_src = File::Spec::Functions::rel2abs($src); if (!$flist_cache{$abs_src}) { my $w = whereami_any(); @@ -219,6 +223,7 @@ sub pdlpp_list_functions { $INC{'PDL/Types.pm'} = 1; } require ''.catfile($w, qw(PP.pm)); + $::PDLBASE = $base; $flist_cache{$abs_src} = [ PDL::PP::list_functions($src) ]; } @{ $flist_cache{$abs_src} }; @@ -234,7 +239,7 @@ sub pdlpp_mod_values { my ($internal, $src, $base, $multi_c, $deep) = @_; return ("$base.xs", "$base\$(OBJ_EXT)") if !$multi_c; my $cfileprefix = $deep ? "$base-" : ''; - my @cbase = map $cfileprefix."pp-$_", pdlpp_list_functions($src, $internal); + my @cbase = map $cfileprefix."pp-$_", pdlpp_list_functions($src, $internal, $base); (join(' ', "$base.xs", map "$_.c", @cbase), join(' ', map "$_\$(OBJ_EXT)", $base, @cbase)); } diff --git a/Basic/Math/math.pd b/Basic/lib/PDL/Math.pd similarity index 97% rename from Basic/Math/math.pd rename to Basic/lib/PDL/Math.pd index 4ae5e0150..bad7ddea4 100644 --- a/Basic/Math/math.pd +++ b/Basic/lib/PDL/Math.pd @@ -18,7 +18,7 @@ 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{"}; +my $include = qq{#include "}.File::Spec::Functions::rel2abs("$::PDLBASE/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 @@ -26,10 +26,11 @@ 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}++; + $PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= " $::PDLBASE/$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); +$PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= join '', map " $::PDLBASE/$_\$(OBJ_EXT)", qw(const mtherr polevl cpoly ndtri); +$PDL::Core::Dev::EXTRAS{$::PDLMOD}{INC} .= qq{ "-I$::PDLBASE"}; } my $R = [ppdefs()]; diff --git a/Basic/Math/NOTES b/Basic/lib/PDL/Math/NOTES similarity index 100% rename from Basic/Math/NOTES rename to Basic/lib/PDL/Math/NOTES diff --git a/Basic/Math/const.c b/Basic/lib/PDL/Math/const.c similarity index 100% rename from Basic/Math/const.c rename to Basic/lib/PDL/Math/const.c diff --git a/Basic/Math/cpoly.c b/Basic/lib/PDL/Math/cpoly.c similarity index 100% rename from Basic/Math/cpoly.c rename to Basic/lib/PDL/Math/cpoly.c diff --git a/Basic/Math/cpoly.h b/Basic/lib/PDL/Math/cpoly.h similarity index 100% rename from Basic/Math/cpoly.h rename to Basic/lib/PDL/Math/cpoly.h diff --git a/Basic/Math/j0.c b/Basic/lib/PDL/Math/j0.c similarity index 100% rename from Basic/Math/j0.c rename to Basic/lib/PDL/Math/j0.c diff --git a/Basic/Math/j1.c b/Basic/lib/PDL/Math/j1.c similarity index 100% rename from Basic/Math/j1.c rename to Basic/lib/PDL/Math/j1.c diff --git a/Basic/Math/jn.c b/Basic/lib/PDL/Math/jn.c similarity index 100% rename from Basic/Math/jn.c rename to Basic/lib/PDL/Math/jn.c diff --git a/Basic/Math/mconf.h b/Basic/lib/PDL/Math/mconf.h similarity index 100% rename from Basic/Math/mconf.h rename to Basic/lib/PDL/Math/mconf.h diff --git a/Basic/Math/mtherr.c b/Basic/lib/PDL/Math/mtherr.c similarity index 100% rename from Basic/Math/mtherr.c rename to Basic/lib/PDL/Math/mtherr.c diff --git a/Basic/Math/ndtri.c b/Basic/lib/PDL/Math/ndtri.c similarity index 100% rename from Basic/Math/ndtri.c rename to Basic/lib/PDL/Math/ndtri.c diff --git a/Basic/Math/polevl.c b/Basic/lib/PDL/Math/polevl.c similarity index 100% rename from Basic/Math/polevl.c rename to Basic/lib/PDL/Math/polevl.c diff --git a/Basic/Math/protos.h b/Basic/lib/PDL/Math/protos.h similarity index 100% rename from Basic/Math/protos.h rename to Basic/lib/PDL/Math/protos.h diff --git a/Basic/Math/yn.c b/Basic/lib/PDL/Math/yn.c similarity index 100% rename from Basic/Math/yn.c rename to Basic/lib/PDL/Math/yn.c diff --git a/MANIFEST b/MANIFEST index 50fbcdcf0..c263d1cea 100644 --- a/MANIFEST +++ b/MANIFEST @@ -114,6 +114,20 @@ Basic/lib/PDL/IO/Storable.pm Basic/lib/PDL/Lite.pm Basic/lib/PDL/LiteF.pm Basic/lib/PDL/Lvalue.pm +Basic/lib/PDL/Math.pd +Basic/lib/PDL/Math/const.c +Basic/lib/PDL/Math/cpoly.c +Basic/lib/PDL/Math/cpoly.h +Basic/lib/PDL/Math/j0.c +Basic/lib/PDL/Math/j1.c +Basic/lib/PDL/Math/jn.c +Basic/lib/PDL/Math/mconf.h +Basic/lib/PDL/Math/mtherr.c +Basic/lib/PDL/Math/ndtri.c +Basic/lib/PDL/Math/NOTES +Basic/lib/PDL/Math/polevl.c +Basic/lib/PDL/Math/protos.h +Basic/lib/PDL/Math/yn.c Basic/lib/PDL/MATLAB.pod Basic/lib/PDL/Matrix.pm Basic/lib/PDL/Modules.pod @@ -142,26 +156,11 @@ Basic/lib/PDL/Slices.pd Basic/lib/PDL/Tips.pod Basic/lib/PDL/Tutorials.pod Basic/lib/PDL/Types.pm +Basic/lib/PDL/Ufunc.pd Basic/lib/PDLdb.pl Basic/lib/Test/Deep/PDL.pm Basic/lib/Test/PDL.pm -Basic/lib/PDL/Ufunc.pd Basic/Makefile.PL -Basic/Math/const.c -Basic/Math/cpoly.c -Basic/Math/cpoly.h -Basic/Math/j0.c -Basic/Math/j1.c -Basic/Math/jn.c -Basic/Math/Makefile.PL -Basic/Math/math.pd -Basic/Math/mconf.h -Basic/Math/mtherr.c -Basic/Math/ndtri.c -Basic/Math/NOTES -Basic/Math/polevl.c -Basic/Math/protos.h -Basic/Math/yn.c Basic/MatrixOps/eigen.c Basic/MatrixOps/eigen.h Basic/MatrixOps/eigens.c @@ -216,10 +215,8 @@ Basic/t/niceslice-utilcall.t Basic/t/niceslice.t Basic/t/ops-bitwise.t Basic/t/ops.t -Basic/t/pdl_from_string.t Basic/t/pdlchar.t -Basic/t/pp_croaking.t -Basic/t/pp_line_numbers.t +Basic/t/pdl_from_string.t Basic/t/ppt-01_ref_counting.t Basic/t/ppt-02_non_threaded.t Basic/t/ppt-03_name_munging.t @@ -227,6 +224,8 @@ Basic/t/ppt-10_physical_piddles.t Basic/t/ppt-11_memory_mapped.t Basic/t/ppt-20_simd.t Basic/t/ppt-30_sharing_from_threads.t +Basic/t/pp_croaking.t +Basic/t/pp_line_numbers.t Basic/t/primitive-append.t Basic/t/primitive-clip.t Basic/t/primitive-interpolate.t diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 57e45de0e..aa331c530 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -40,6 +40,7 @@ RCS /core$ \b_eumm/ ^Basic/lib/PDL/Bad(\.(pm|xs|c)$|-pp-) +^Basic/lib/PDL/Math(\.(pm|xs|c)$|-pp-) ^Basic/lib/PDL/Ops(\.(pm|xs|c)$|-pp-) ^Basic/lib/PDL/Slices(\.(pm|xs|c)$|-pp-) ^Basic/lib/PDL/Ufunc(\.(pm|xs|c)$|-pp-) @@ -53,7 +54,6 @@ RCS ^Basic/Lib-ImageND/ImageND\..* ^Basic/Lib-ImageRGB/ImageRGB\..* ^Basic/Lib-Transform/Transform\..* -^Basic/Math/Math\..* ^Basic/MatrixOps/MatrixOps\..* ^Basic/Primitive/Primitive\..* ^Basic/script/pdl$