#!perl -w
sub
names {
my
(
$module
) =
@_
;
my
$pdname
=
'lib/'
.(
$module
=~ s
my
$dir
=
$module
=~ s
return
(
$module
,
$pdname
,
$dir
);
}
sub
pdtmpl {
my
(
$module
) =
@_
;
<<EOF;
# template auto generated by pptemplate
# uncomment commands, copy and fill in as needed
# see also the PDL::PP manpage
use strict;
use warnings;
our \$VERSION = '0.001';
pp_setversion(\$VERSION);
{ no warnings 'once'; # pass info back to Makefile.PL
#\$PDL::Core::Dev::EXTRAS{\$::PDLMOD}{OBJECT} .= join '', map " \$::PDLBASE/\$_\\$(OBJ_EXT)", qw(fftn);
#\$PDL::Core::Dev::EXTRAS{\$::PDLMOD}{DEFINE} .= qq{ -DFFT_FLOAT -DFFT_DOUBLE -DFFT_LDOUBLE};
#\$PDL::Core::Dev::EXTRAS{\$::PDLMOD}{INC} .= qq{ "-I\$::PDLBASE"};
}
# pp_bless(''); # package namespace of pp_def'ed functions
# defaults to 'PDL'
# pp_add_boot(''); # code to add to the XS boot section
# pp_addhdr(''); # add C code to the section preceding
# the first MODULE keyword
pp_addpm({At=>'Top'}, <<'EOPM');
use strict;
use warnings;
=head1 NAME
$module - new PDL module to clutter up CPAN
=head1 SYNOPSIS
use $module;
# FILL THIS IN
=head1 DESCRIPTION
This will change the world.
=cut
EOPM
# pp_add_exported(''); # add the list of functions
# to the list of exported functions
# pp_addxs(''); # add plain XS code to the XS section
# pp_add_isa(qw//); # inheritance business: add arglist to modules \@ISA
pp_def('myinc',
Pars => 'a(); [o]b()',
Code => '\$b() = \$a() + 1;',
);
pp_done(); # you will need this to finish pp processing
EOF
}
sub
pdMakefile {
my
(
$module
,
$pdname
) =
@_
;
return
<<EOM;
use strict;
use warnings;
use ExtUtils::MakeMaker;
use PDL::Core::Dev;
WriteMakefile(
NAME => '$module',
AUTHOR => 'A.U.Thor <author\@example.com>',
VERSION_FROM => '$pdname',
MIN_PERL_VERSION => '5.016',
LICENSE=> 'perl',
PREREQ_PM => {
'PDL::Basic' => '2.096', # deep mode
},
CONFIGURE_REQUIRES => {
'PDL::Basic' => '2.096',
},
BUILD_REQUIRES => {
'PDL::Basic' => '2.096',
},
TEST_REQUIRES => {
'Test::More' => '0.88', # done_testing
'Test::PDL' => '0.21',
},
);
{
my \@pd_srcs;
package MY; # so that "SUPER" works right
sub init_PM {
my (\$self) = \@_;
\$self->SUPER::init_PM;
\@pd_srcs = ::pdlpp_eumm_update_deep(\$self);
}
sub postamble { ::pdlpp_postamble(\@pd_srcs) }
}
EOM
}
sub
usage {
die
"usage: @{[File::Basename::basename $0]} modulename\n"
;
}
usage
if
!
@ARGV
;
my
(
$module
,
$pdname
,
$dir
) = names
$ARGV
[0];
die
"$dir already exists; move out of the way if you want to proceed"
if
-d
$dir
;
mkdir
$dir
or
die
"$dir: $!"
;
chdir
$dir
or
die
"$dir: $!"
;
my
$pd_dir
= dirname
$pdname
;
make_path
$pd_dir
;
die
"$pd_dir not created"
if
!-d
$pd_dir
;
open
my
$pdfl
,
">"
,
$pdname
or
die
"$pdname: $!"
;
print
$pdfl
pdtmpl(
$module
);
close
$pdfl
;
open
my
$mkfl
,
">"
,
'Makefile.PL'
or
die
"Makefile.PL: $!"
;
print
$mkfl
pdMakefile(
$module
,
$pdname
);
close
$mkfl
;
mkdir
't'
or
die
"t: $!"
;
open
my
$tfl
,
'>'
,
't/basic.t'
or
die
"t/basic.t: $!"
;
print
$tfl
<<EOF;
use strict;
use warnings;
use PDL::LiteF;
use Test::More;
use Test::PDL;
use $module;
is_pdl pdl(3,5)->myinc, pdl(4,6);
done_testing;
EOF
close
$tfl
;