kmx
2015-01-05 23:20:34 UTC
Hi,
I have a suggestion for improved ExtUtils::MakeMaker support in PDL.
It basically means patching PDL::Core::Dev like this (just a proof of
concept - working, but not much tested):
https://gist.github.com/kmx/5d740bc6f959c014516f
The patch:
1/ Introduces a new function pdlpp_eumm(%args) which is kind of a
replacement for pdlpp_stdargs - the added value is that pdlpp_eumm does
some kind of automatic merging (see the patch).
2/ Uses a trick that we do not need to write "sub MY::postamble" - stolen
from Inline::Module.
See sample Makefile.PL below.
The new-style Makefile.PL looks definitely simpler and easier to read/write
but I am not sure if the gain is worth changing the established traditional
way of writing PDL's Makefiles.
--
kmx
################ Makefile.PL - current-style
use ExtUtils::MakeMaker;
use PDL::Core::Dev;
my $libs = `ta-lib-config --libs`;
my $cflags = `ta-lib-config --cflags`;
unless ($libs && $cflags) {
warn "ta-lib not found";
exit 0;
}
my $package = [qw/TA.pd TA PDL::Finance::TA/];
my %eumm_args = pdlpp_stdargs($package);
$eumm_args{INC} .= " $cflags";
$eumm_args{LIBS} ->[0] .= " $libs";
WriteMakefile(
%eumm_args,
VERSION_FROM => 'TA.pd',
AUTHOR => 'KMX <***@cpan.org>',
ABSTRACT => 'PDL interface to ta-lib library',
LICENSE => 'perl',
PREREQ_PM => {
'PDL' => 0,
},
BUILD_REQUIRES => {
'PDL' => 0,
'Test::More' => 0,
'Test::Number::Delta' => 0,
},
CONFIGURE_REQUIRES => {
'PDL' => 0,
},
META_MERGE => {
resources => {
repository => 'https://github.com/kmx/pdl-finance-ta',
},
},
);
sub MY::postamble {
pdlpp_postamble($package);
}
################ end of current-style
################ Makefile.PL - new-style
use ExtUtils::MakeMaker;
use PDL::Core::Dev;
my $libs = `ta-lib-config --libs`;
my $cflags = `ta-lib-config --cflags`;
unless ($libs && $cflags) {
warn "ta-lib not found";
exit 0;
}
WriteMakefile(pdlpp_eumm(
PDL_PD => { TA.pd => PDL::Finance::TA },
VERSION_FROM => 'TA.pd',
AUTHOR => 'KMX <***@cpan.org>',
ABSTRACT => 'PDL interface to ta-lib library',
LICENSE => 'perl',
INC => $cflags,
LIBS => $libs,
BUILD_REQUIRES => {
'Test::More' => 0,
'Test::Number::Delta' => 0,
},
META_MERGE => {
resources => {
repository => 'https://github.com/kmx/pdl-finance-ta',
},
},
));
################ end of new-style
I have a suggestion for improved ExtUtils::MakeMaker support in PDL.
It basically means patching PDL::Core::Dev like this (just a proof of
concept - working, but not much tested):
https://gist.github.com/kmx/5d740bc6f959c014516f
The patch:
1/ Introduces a new function pdlpp_eumm(%args) which is kind of a
replacement for pdlpp_stdargs - the added value is that pdlpp_eumm does
some kind of automatic merging (see the patch).
2/ Uses a trick that we do not need to write "sub MY::postamble" - stolen
from Inline::Module.
See sample Makefile.PL below.
The new-style Makefile.PL looks definitely simpler and easier to read/write
but I am not sure if the gain is worth changing the established traditional
way of writing PDL's Makefiles.
--
kmx
################ Makefile.PL - current-style
use ExtUtils::MakeMaker;
use PDL::Core::Dev;
my $libs = `ta-lib-config --libs`;
my $cflags = `ta-lib-config --cflags`;
unless ($libs && $cflags) {
warn "ta-lib not found";
exit 0;
}
my $package = [qw/TA.pd TA PDL::Finance::TA/];
my %eumm_args = pdlpp_stdargs($package);
$eumm_args{INC} .= " $cflags";
$eumm_args{LIBS} ->[0] .= " $libs";
WriteMakefile(
%eumm_args,
VERSION_FROM => 'TA.pd',
AUTHOR => 'KMX <***@cpan.org>',
ABSTRACT => 'PDL interface to ta-lib library',
LICENSE => 'perl',
PREREQ_PM => {
'PDL' => 0,
},
BUILD_REQUIRES => {
'PDL' => 0,
'Test::More' => 0,
'Test::Number::Delta' => 0,
},
CONFIGURE_REQUIRES => {
'PDL' => 0,
},
META_MERGE => {
resources => {
repository => 'https://github.com/kmx/pdl-finance-ta',
},
},
);
sub MY::postamble {
pdlpp_postamble($package);
}
################ end of current-style
################ Makefile.PL - new-style
use ExtUtils::MakeMaker;
use PDL::Core::Dev;
my $libs = `ta-lib-config --libs`;
my $cflags = `ta-lib-config --cflags`;
unless ($libs && $cflags) {
warn "ta-lib not found";
exit 0;
}
WriteMakefile(pdlpp_eumm(
PDL_PD => { TA.pd => PDL::Finance::TA },
VERSION_FROM => 'TA.pd',
AUTHOR => 'KMX <***@cpan.org>',
ABSTRACT => 'PDL interface to ta-lib library',
LICENSE => 'perl',
INC => $cflags,
LIBS => $libs,
BUILD_REQUIRES => {
'Test::More' => 0,
'Test::Number::Delta' => 0,
},
META_MERGE => {
resources => {
repository => 'https://github.com/kmx/pdl-finance-ta',
},
},
));
################ end of new-style