Skip to content

Commit cbfa631

Browse files
Eric WheelerKJ7NLL
Eric Wheeler
authored andcommitted
Added auto-detection of LAPACK/BLAS library names
Added find_libs() to the root Makefile.PL to find libraries in Debian, Ubuntu, CentOS 7/8, SUSE. See PDLPorters#15 Signed-off-by: Eric Wheeler <perl-pdl@z.ewheeler.org>
1 parent 3c32c5b commit cbfa631

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Makefile.PL

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ my @pkgs = qw(lapack blas);
1010
our $libs0 = (
1111
eval {require PkgConfig; join ' ', map PkgConfig->find($_)->get_ldflags, @pkgs} ||
1212
eval {require ExtUtils::PkgConfig; join ' ', map ExtUtils::PkgConfig->libs($_), @pkgs} ||
13+
find_libs() ||
1314
`pkg-config @pkgs --libs` ||
1415
'-L/usr/lib/atlas -llapack -lblas -latlas'
1516
) . ' ' . ExtUtils::F77->runtime;
@@ -74,3 +75,30 @@ WriteMakefile(
7475
dist => { PREOP=>'$(PERL) -MPDL::Core::Dev -e pdlpp_mkgen $(DISTVNAME)' }, # GENERATED subdir in dist tarball
7576
clean => { FILES => '*~' },
7677
);
78+
79+
80+
sub find_libs {
81+
return if $^O !~ /linux/i;
82+
83+
# in performance order based on libraries I've used
84+
# for xnec2c in Ubuntu, Debian, SuSE, CentOS, etc.
85+
# See comments here for detail:
86+
# https://github.com/KJ7LNW/xnec2c/blob/master/src/mathlib.c#L29
87+
my @libs = qw/
88+
openblaso
89+
openblas_openmp
90+
tatlas
91+
lapack_atlas
92+
openblasp
93+
openblas_pthreads
94+
openblas
95+
openblas_serial
96+
satlas
97+
mkl_rt/;
98+
99+
for my $l (@libs) {
100+
return "-l$l" if (check_lib(lib => $l));
101+
}
102+
103+
return;
104+
}

0 commit comments

Comments
 (0)