-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile.PL
More file actions
138 lines (132 loc) · 4.9 KB
/
Copy pathMakefile.PL
File metadata and controls
138 lines (132 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
use ExtUtils::MakeMaker;
use strict;
use warnings;
use Config;
use Devel::CheckLib qw(check_lib check_lib_or_exit);
use ExtUtils::F77;
use PDL::Core::Dev;
use Text::ParseWords qw(shellwords);
my $f77_uscore = (ExtUtils::F77->trail_ ? '_' : '');
our $inc = "-DF77_USCORE=$f77_uscore";
my $fortran_checklib = <<EOF;
/* The first line must not be a preprocessor macro or Devel::CheckLib will fail
because Devel::Checklib places this code on one line: main() { <code> } */
#define F77_USCORE $f77_uscore
#define CONCAT_(A, B) A ## B
#define CONCAT(A, B) CONCAT_(A, B)
#define FORTRAN(name) CONCAT(name, F77_USCORE)
long c_zero = 0;
long c_nine = 9;
extern long FORTRAN(ilaenv)(long *ispec, char *name__, char *opts, long *n1,
long *n2, long *n3, long *n4, long name_len, long opts_len);
long i = FORTRAN(ilaenv)(&c_nine, "SGESDD", " ", &c_zero, &c_zero, &c_zero, &c_zero, 6, 1);
if (argc > 2) printf("%ld", i); /* try to stop optimiser eliminating */
extern void FORTRAN(dgebal)(char job, int n, double *a, int lda, int ilo, int ihi, double *scale, int info);
if (argc > 2) FORTRAN(dgebal)(0, 0, NULL, 0, 0, 0, NULL, 0);
extern void FORTRAN(dgesdd)(char job, int m, int n, double *a, int lda, double *s, double *u, int ldu, double *vt, int ldvt, double *work, int lwork, int *iwork, int info);
if (argc > 2) FORTRAN(dgesdd)(0, 0, 0, NULL, 0, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0);
return 0;
EOF
our %ldloadlibs = ($^O =~ /MSWin/ && $Config{cc} eq 'cl')
? (LDLOADLIBS => 'oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib ../lapack/libacml.lib "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\msvcrt.lib" ')
: ();
my @pkgs = qw(lapack blas);
our $libs0 = (
eval {require PkgConfig; join ' ', map PkgConfig->find($_)->get_ldflags, @pkgs} ||
eval {require ExtUtils::PkgConfig; join ' ', map ExtUtils::PkgConfig->libs($_), @pkgs} ||
find_macos_libs() ||
find_libs() ||
`pkg-config @pkgs --libs` ||
'-L/usr/lib/atlas -llapack -lblas -latlas'
) . ' ' . ExtUtils::F77->runtime;
{
# work around Devel::CheckLib not doing Text::ParseWords::shellwords
my @libpath = grep -d, map {my $r=$_;$r=~s/^-L//?$r:()} my @sw = shellwords $libs0;
my @lib = grep check_lib(lib=>$_), map {my $r=$_;$r=~s/^-l//?$r:()} @sw;
$libs0 = join ' ', (map qq{-L"$_"}, @libpath), (map "-l$_", @lib);
check_lib_or_exit(
ldflags => $libs0,
header => [($^O =~ /MSWin/ ? 'float.h' : ()), qw(stdio.h math.h)],
function => $fortran_checklib,
);
}
my $preop = '$(PERLRUNINST) -MPDL::Core::Dev -e pdlpp_mkgen $(DISTVNAME)';
my $package_name = "PDL::LinearAlgebra";
(my $repo = $package_name) =~ s#::#-#g;
$repo = "PDLPorters/$repo";
WriteMakefile(
NAME => 'PDL::LinearAlgebra',
ABSTRACT => 'PDL bindings to some BLAS and LAPACK library routines',
AUTHOR => [ 'Grégory Vanuxem <ellipse@cpan.org>' ],
VERSION_FROM => 'lib/PDL/LinearAlgebra.pm',
LICENSE => 'artistic_2',
MIN_PERL_VERSION => '5.016',
META_MERGE => {
"meta-spec" => { version => 2 },
dynamic_config => 0,
resources => {
homepage => 'http://pdl.perl.org/',
bugtracker => {web=>"https://github.com/$repo/issues"},
repository => {
url => "git://github.com/$repo.git",
type => 'git',
web => "https://github.com/$repo",
},
x_IRC => 'irc://irc.perl.org/#pdl',
},
},
CONFIGURE_REQUIRES => {
"PDL" => '2.104',
"Devel::CheckLib" => '1.16', # argc is not supplied in 1.05, but 1.16 works.
"ExtUtils::F77" => '1.26',
},
PREREQ_PM => {
"PDL" => '2.104', # tritosym moved over
},
TEST_REQUIRES => {
"Test::More" => '0.88', # done_testing
},
INC => $inc,
LIBS => [$libs0],
dist => { COMPRESS => 'gzip', SUFFIX => 'gz', PREOP => $preop },
clean => { FILES => '*~' },
);
sub find_libs {
return if $^O !~ /linux/i;
# in performance order based on libraries I've used
# for xnec2c in Ubuntu, Debian, SuSE, CentOS, etc.
# See comments here for detail:
# https://github.com/KJ7LNW/xnec2c/blob/master/src/mathlib.c#L29
my @libs = qw/
openblaso
openblas_openmp
openblasp
openblas_pthreads
openblas
openblas_serial
mkl_rt/;
for my $l (@libs) {
return "-l$l" if (check_lib(lib => $l));
}
return;
}
sub find_macos_libs {
return if $^O ne 'darwin';
my $pref = `brew --prefix lapack`;
return if !$pref;
chomp $pref;
qq{-L"$pref/lib" -llapack -lblas};
}
my @pd_srcs;
sub MY::init_PM {
package MY; # so that "SUPER" works right
my ($self) = @_;
$self->SUPER::init_PM;
delete $self->{PM}{'pp_defc.pl'};
@pd_srcs = ::pdlpp_eumm_update_deep($self);
}
sub MY::postamble {
my $oneliner = PDL::Core::Dev::_oneliner(qq{exit if \$ENV{DESTDIR}; use PDL::Doc; eval { PDL::Doc::add_module(shift); }});
pdlpp_postamble(@pd_srcs) .
qq|\ninstall :: pure_install\n\t$oneliner \$(NAME)\n|;
}