File: Makefile.PL

package info (click to toggle)
libpdl-linearalgebra-perl 0.433-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,496 kB
  • sloc: perl: 2,421; ansic: 168; makefile: 6
file content (127 lines) | stat: -rw-r--r-- 4,255 bytes parent folder | download | duplicates (2)
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
use ExtUtils::MakeMaker;
use Config;
use Devel::CheckLib qw(check_lib check_lib_or_exit);
use ExtUtils::F77;
use PDL::Core::Dev;

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;
our $inc = '-DF77_USCORE='. (ExtUtils::F77->trail_ ? '_' : '');
{
  # work around Devel::CheckLib not doing Text::ParseWords::shellwords
  use Text::ParseWords qw(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);
  my $f77_uscore = (ExtUtils::F77->trail_ ? '_' : '');
  check_lib_or_exit(
    ldflags => $libs0,
    header => [($^O =~ /MSWin/ ? 'float.h' : ()), qw(stdio.h math.h)],
    function => <<EOF,

#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 */
EOF
  );
}

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',
  META_MERGE => {
    "meta-spec" => { version => 2 },
    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.096',
    "Devel::CheckLib" => 0,
    "ExtUtils::F77" => '1.26',
  },
  PREREQ_PM => {
    "PDL" => '2.096', # lib/*.pd
  },
  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|;
}