Debian Codegraph @

Makefile.PL

raw symbols SCIP
1 use ExtUtils::MakeMaker;
2 use strict;
3 use warnings;
4 use Config;
5 use Devel::CheckLib qw(check_lib check_lib_or_exit);
6 use ExtUtils::F77;
7 use PDL::Core::Dev;
8 use Text::ParseWords qw(shellwords);
9
10 my $f77_uscore = (ExtUtils::F77->trail_ ? '_' : '');
11 our $inc = "-DF77_USCORE=$f77_uscore";
12 my $fortran_checklib = <<EOF;
13 /* The first line must not be a preprocessor macro or Devel::CheckLib will fail
14 because Devel::Checklib places this code on one line: main() { <code> } */
15 #define F77_USCORE $f77_uscore
16 #define CONCAT_(A, B) A ## B
17 #define CONCAT(A, B) CONCAT_(A, B)
18 #define FORTRAN(name) CONCAT(name, F77_USCORE)
19
20 /* dggsvd3 is LAPACK 3.7+ which in 2026 is not supported on macOS native */
21 extern void FORTRAN(dggsvd3)(
22 char *jobu, char *jobv, char *jobq, long *m, long *n, long *p,
23 long *k, long *l, double *a, long *lda, double *b, long *ldb, double *alpha,
24 double *beta, double *u, long *ldu, double *v, long *ldv,
25 double *q, long *ldq, double *work, long *lwork, long *iwork, long *info);
26 char n = 'N';
27 long c_zero = 0, out_k=0, out_l=0, c_one = 1, c_m1 = -1, iwork[1], info;
28 double A[]={0}, B[]={0}, alpha[1], beta[1], U[1], Q[1], work[1];
29 /* argc is to try to stop optimiser eliminating */
30 if (argc < 2) FORTRAN(dggsvd3)(&n, &n, &n, &c_zero, &c_zero, &c_zero,
31 &out_k, &out_l, A, &c_one, B, &c_one, alpha,
32 beta, U, &c_one, NULL, &c_one,
33 NULL, &c_one, work, &c_m1, iwork, &info);
34 return 0;
35 EOF
36 our %ldloadlibs = ($^O =~ /MSWin/ && $Config{cc} eq 'cl')
37 ? (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" ')
38 : ();
39 my @pkgs = qw(lapack blas);
40 our $libs0 = (
41 eval {require PkgConfig; join ' ', map PkgConfig->find($_)->get_ldflags, @pkgs} ||
42 eval {require ExtUtils::PkgConfig; join ' ', map ExtUtils::PkgConfig->libs($_), @pkgs} ||
43 find_macos_libs() ||
44 find_libs() ||
45 `pkg-config @pkgs --libs` ||
46 '-L/usr/lib/atlas -llapack -lblas -latlas'
47 ) . ' ' . ExtUtils::F77->runtime;
48 {
49 # work around Devel::CheckLib not doing Text::ParseWords::shellwords
50 my @libpath = grep -d, map {my $r=$_;$r=~s/^-L//?$r:()} my @sw = shellwords $libs0;
51 my @lib = grep check_lib(lib=>$_), map {my $r=$_;$r=~s/^-l//?$r:()} @sw;
52 $libs0 = join ' ', (map qq{-L"$_"}, @libpath), (map "-l$_", @lib);
53 check_lib_or_exit(
54 ldflags => $libs0,
55 lib => 'm', # "dummy" because assert_lib wants a lib
56 header => [($^O =~ /MSWin/ ? 'float.h' : ()), qw(stdio.h math.h)],
57 function => $fortran_checklib,
58 );
59 }
60
61 my $preop = '$(PERLRUNINST) -MPDL::Core::Dev -e pdlpp_mkgen $(DISTVNAME)';
62 my $package_name = "PDL::LinearAlgebra";
63 (my $repo = $package_name) =~ s#::#-#g;
64 $repo = "PDLPorters/$repo";
65 WriteMakefile(
66 NAME => 'PDL::LinearAlgebra',
67 ABSTRACT => 'PDL bindings to some BLAS and LAPACK library routines',
68 AUTHOR => [ 'GrĂ©gory Vanuxem <[email protected]>' ],
69 VERSION_FROM => 'lib/PDL/LinearAlgebra.pm',
70 LICENSE => 'artistic_2',
71 MIN_PERL_VERSION => '5.016',
72 META_MERGE => {
73 "meta-spec" => { version => 2 },
74 dynamic_config => 0,
75 resources => {
76 homepage => 'http://pdl.perl.org/',
77 bugtracker => {web=>"https://github.com/$repo/issues"},
78 repository => {
79 url => "git://github.com/$repo.git",
80 type => 'git',
81 web => "https://github.com/$repo",
82 },
83 x_IRC => 'irc://irc.perl.org/#pdl',
84 },
85 },
86 CONFIGURE_REQUIRES => {
87 "PDL" => '2.105',
88 "Devel::CheckLib" => '1.16', # argc is not supplied in 1.05, but 1.16 works.
89 "ExtUtils::F77" => '1.26',
90 },
91 PREREQ_PM => {
92 "PDL" => '2.105', # pdldoc_add
93 },
94 TEST_REQUIRES => {
95 "Test::More" => '0.88', # done_testing
96 },
97 INC => $inc,
98 LIBS => [$libs0],
99 dist => { COMPRESS => 'gzip', SUFFIX => 'gz', PREOP => $preop },
100 clean => { FILES => '*~' },
101 );
102
103 sub find_libs {
104 return if $^O !~ /linux/i;
105 # in performance order based on libraries I've used
106 # for xnec2c in Ubuntu, Debian, SuSE, CentOS, etc.
107 # See comments here for detail:
108 # https://github.com/KJ7LNW/xnec2c/blob/master/src/mathlib.c#L29
109 my @libs = qw/
110 openblaso
111 openblas_openmp
112 openblasp
113 openblas_pthreads
114 openblas
115 openblas_serial
116 mkl_rt/;
117 for my $l (@libs) {
118 return "-l$l" if (check_lib(lib => $l));
119 }
120 return;
121 }
122
123 sub find_macos_libs {
124 return if $^O ne 'darwin';
125 for my $pkg (qw(openblas lapack)) {
126 my $pref = `brew --prefix $pkg`;
127 chomp $pref;
128 next if !$pref or !-d $pref; # --prefix is where is *or would be* installed
129 return qq{-L"$pref/lib" -llapack -lblas};
130 }
131 ();
132 }
133
134 my @pd_srcs;
135 sub MY::init_PM {
136 package MY; # so that "SUPER" works right
137 my ($self) = @_;
138 $self->SUPER::init_PM;
139 delete $self->{PM}{'pp_defc.pl'};
140 @pd_srcs = ::pdlpp_eumm_update_deep($self);
141 }
142 sub MY::postamble { pdlpp_postamble(@pd_srcs) . pdldoc_add() }