Debian Codegraph @

Makefile.PL

raw symbols SCIP
1 use 5.006;
2 use strict;
3 use warnings;
4 use ExtUtils::MakeMaker;
5 use PDL::Core::Dev;
6 use Devel::CheckLib qw(check_lib);
7
8 # Makefile has targets 'cleanall' and 'distcleanall'.
9 # These do clean and distclean in both module distribution
10 # toplevel and in $matio_top_level.
11
12 my ($matio_top_level, $inc, $libs, %object) = ('./matio-1.5.30', '', '');
13
14 sub pkg_run {
15 my ($pkg, $flag) = @_;
16 return unless my $out = `pkg-config $pkg $flag`;
17 chomp $out;
18 $out;
19 }
20
21 if (check_lib(lib => 'hdf5')) {
22 $libs .= ' -lhdf5';
23 $inc .= ' -DHAVE_HDF5=1';
24 print "Found HDF5\n";
25 } else {
26 my $this_inc = (
27 eval {require PkgConfig; join ' ', PkgConfig->find('hdf5')->get_cflags} ||
28 eval {require ExtUtils::PkgConfig; ExtUtils::PkgConfig->cflags('hdf5')} ||
29 pkg_run(qw(hdf5 --cflags)) ||
30 ''
31 );
32 $inc .= ' '.$this_inc.' -DHAVE_HDF5=1' if $this_inc;
33 $libs .= ' '.(
34 eval {require PkgConfig; join ' ', PkgConfig->find('hdf5')->get_ldflags} ||
35 eval {require ExtUtils::PkgConfig; ExtUtils::PkgConfig->libs('hdf5')} ||
36 pkg_run(qw(hdf5 --libs)) ||
37 '-lhdf5'
38 );
39 print "Not found HDF5; got inc=($inc) libs=($libs)\n";
40 }
41
42 if (check_lib(lib => 'matio')) {
43 $libs .= ' -lmatio';
44 print "Found matio\n";
45 } elsif (
46 my $this_inc = (
47 eval {require PkgConfig; join ' ', PkgConfig->find('matio')->get_cflags} ||
48 eval {require ExtUtils::PkgConfig; ExtUtils::PkgConfig->cflags('matio')} ||
49 pkg_run(qw(matio --cflags)) ||
50 ''
51 )
52 ) {
53 $inc .= ' '.$this_inc;
54 $libs .= ' '.(
55 eval {require PkgConfig; join ' ', PkgConfig->find('matio')->get_ldflags} ||
56 eval {require ExtUtils::PkgConfig; ExtUtils::PkgConfig->libs('matio')} ||
57 pkg_run(qw(matio --libs)) ||
58 '-lmatio'
59 );
60 print "Found matio with pkg; got inc=($inc) libs=($libs)\n";
61 } else {
62 $inc .= " -DDISTRO_MATIO";
63 $libs .= ' -lmatio';
64 print "Not found matio; got inc=($inc) libs=($libs)\n";
65 %object = (OBJECT => ' Matlab$(OBJ_EXT) matio_obj$(OBJ_EXT) ');
66 if ( not -e "$matio_top_level/src/matio_pubconf.h" ) {
67 print "Makefile.PL: running configure in $matio_top_level\n";
68 system "cd $matio_top_level; ./configure";
69 }
70 }
71
72 my $matlab_package = ['matlab.pd', 'Matlab', 'PDL::IO::Matlab'];
73 my %hash = pdlpp_stdargs($matlab_package);
74
75 my %more_items = (
76 AUTHOR => q{John Lapeyre <[email protected]>},
77 ABSTRACT_FROM => 'matlab.pd',
78 %object,
79 LIBS => [ '-lz' ],
80 CONFIGURE_REQUIRES => {
81 'Devel::CheckLib' => '1.14',
82 'ExtUtils::MakeMaker' => '6.64', # TEST_REQUIRES
83 'PDL' => '2.043',
84 },
85 TEST_REQUIRES => {
86 'Test::More' => '0.88', # done_testing
87 'Test::PDL' => '0.21',
88 },
89 PREREQ_PM => {
90 'PDL' => '2.043',
91 },
92 # note the file below that matio Makefile fails to clean.
93 clean => { FILES => ' PDL-IO-Matlab-* Matlab.* tst.mat testf.mat ' .
94 $matio_top_level . '/test/atconfig' },
95 );
96 %hash = (%hash, %more_items);
97 $hash{INC} .= $inc;
98 $hash{LIBS}[0] .= $libs;
99
100 sub MY::postamble { qq{
101
102 matio_obj\$(OBJ_EXT):
103 cd $matio_top_level; \$(MAKE)
104 ld -r -o matio_obj\$(OBJ_EXT) $matio_top_level/src/.libs/*\$(OBJ_EXT)
105
106 cleanall: clean
107 cd $matio_top_level; \$(MAKE) clean
108
109 distcleanall: distclean
110 cd $matio_top_level; \$(MAKE) distclean
111
112 } . pdlpp_postamble($matlab_package)};
113
114 $hash{META_MERGE} = {
115 "meta-spec" => { version => 2 },
116 resources => {
117 bugtracker => {web=>'https://github.com/jlapeyre/PDL-IO-Matlab/issues'},
118 repository => {
119 url => 'git://github.com/jlapeyre/PDL-IO-Matlab.git',
120 type => 'git',
121 web => 'https://github.com/jlapeyre/PDL-IO-Matlab',
122 },
123 x_IRC => 'irc://irc.perl.org/#pdl',
124 },
125 };
126
127 WriteMakefile( %hash );
128
129 if (exists $ARGV[0] && $ARGV[0] eq 'README.pod') {
130 print STDERR "Writing README.pod\n";
131 open README, '>', 'README.pod' or die "Couldn't open README.pod";
132 foreach my $mod ('Matlab.pm') {
133 open MOD, $mod or die "Couldn't open main module";
134 while (<MOD>)
135 {
136 if (/^=/../^=cut/)
137 { print README; }
138 }
139 close(MOD);
140 }
141 close(README);
142 }