[c4e320]: Makefile.PL  Maximize  Restore  History

Download this file

289 lines (250 with data), 8.7 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# Makefile.PL for a package defined by PP code.
use ExtUtils::MakeMaker;
use Config;
# comment this block out for PDL internal version
eval {
require PDL::Core::Dev; # needed for stand-alone version of package.
# Need to comment out
# for package included in PDL distro.
PDL::Core::Dev->import;
};
my $pdl_installed = ($@) ? 0 : 1; # make always == 1 for install from PDL distro.
print "PDL ", ($pdl_installed ? 'is' : 'is not'), " installed\n";
# end comment this block out for PDL internal version
#my $pdl_installed = 1; # uncomment for PDL-internal version
if (!$pdl_installed) {
# write dummy makefile if PDL not installed
WriteMakefile(
'NAME' => 'PDL::Graphics::PLplot',
'PREREQ_PM' => { PDL => 0 },
);
exit;
}
use vars qw /$plplotvers/; # version of plplot used
#
## Search for plplot library and include file
#
print "\nChecking PDL::Graphics::PLplot...\n";
unlink ("OPTIONS!"); # remove file uses to communicate with plplot.pd
# on OS-X the library is called libplplotd.dylib, so we
# use $Config{"so"} to get the extension name
#
my $libname = "libplplotd." . $Config{"so"};
my $libname_static = "libplplotd.a";
my $incname = "plplot.h";
# require bad value support. D. Hunt 10/20/2008
unless ($PDL::Config{WITH_BADVAL}) {
buildDummy ("Bad value support required! (Turn on WITH_BADVAL in perldl.conf)");
return if (caller); exit;
}
foreach my $libdir (
$ENV{PLPLOT_LIBDIR},
$PDL::Config{WHERE_PLPLOT_LIBS},
'/usr/local/plplot/lib64',
'/usr/local/plplot/lib',
'/usr/local/lib64',
'/usr/local/lib',
'/opt/local/lib',
'/usr/lib64',
'/usr/lib',
'/opt/lib64',
'/opt/lib',
'/ops/tools/lib',
'/sw/lib/', # default FINK installation
# Add new library paths here!!
) {
if (-e "$libdir/$libname") {
$plplot_lib_path = $libdir;
$ENV{LD_LIBRARY_PATH} .= ":$libdir";
last;
} elsif (-e "$libdir/$libname_static") {
$plplot_lib_path = $libdir;
$ENV{LD_LIBRARY_PATH} .= ":$libdir";
$libname = $libname_static;
last;
}
}
unless (defined ($plplot_lib_path)) {
buildDummy ("Cannot find plplot library ($libname), skipping PDL::Graphics::PLplot\n");
return if (caller); exit;
}
foreach my $incdir (
$ENV{PLPLOT_INCDIR},
$PDL::Config{WHERE_PLPLOT_INCLUDE},
'/usr/local/plplot/include',
'/usr/local/plplot/include/plplot',
'/usr/local/include/plplot',
'/usr/local/include',
'/opt/local/include',
'/usr/include',
'/usr/include/plplot',
'/opt/include',
'/ops/tools/include/plplot',
'/ops/tools/include',
'/sw/include/plplot/', # default FINK installation
# Add new header paths here!!
) {
if (-e "$incdir/$incname") {
$plplot_include_path = "-I$incdir";
if ($incdir =~ m|/plplot$|) {
$inc2 = $incdir;
$inc2 =~ s|/plplot$||;
$plplot_include_path .= " -I$inc2";
}
last;
}
}
unless (defined ($plplot_include_path)) {
buildDummy ("Cannot find plplot header file ($incname), skipping PDL::Graphics::PLplot\n");
return if (caller); exit;
}
# Test that PLplot was compiled --with-double (IE, a PLFLT is a double)
my $size = compileAndRun ("$plplot_include_path", 1, <<'EOC');
#include <plplot.h>
main () { printf ("%d", sizeof (PLFLT)); }
EOC
unless ($size == 8) {
print " Sizeof(PLFLT) must be 8. PLplot must be compiled --with-double (IE ./configure --with-double)\n";
buildDummy ("Cannot find good set of libraries for linking PLplot, try fiddling perldl.conf\n");
return if (caller); exit;
}
# Try linking with library. New if blocks should be added if necessary
my $libs;
foreach my $l (
"-L$plplot_lib_path -lplplotd -lX11",
"-L$plplot_lib_path -lplplotd",
# New lib combinations should be added here!
) {
if (trylink( '', '#include <plplot.h>', 'plinit();', "$l $plplot_include_path")) {
$libs = $l;
print "\tSucceeded linking PLplot with $libs\n";
last;
}
}
unless (defined($libs)) {
buildDummy ("Cannot find good set of libraries for linking PLplot, try fiddling perldl.conf\n");
return if (caller); exit;
}
# Test if PLplot has plsmem, for in memory plotting
eval { compileAndRun ("$plplot_include_path -L$plplot_lib_path -lplplotd", 0, <<'EOC');
#include <plplot.h>
main () { plsmem (0, 0, NULL); }
EOC
};
if ($@) {
print "\tplsmem function not available, no in-memory plotting available!\n";
open (OPT, ">>OPTIONS!");
print OPT "NOMEM!\n";
close OPT;
} else {
print "\tplsmem function found, in-memory plotting available!\n";
}
# Test if PLplot has plsvect, for in vector plotting
eval { compileAndRun ("$plplot_include_path -L$plplot_lib_path -lplplotd", 0, <<'EOC');
#include <plplot.h>
main () { plsvect (NULL, NULL, 0, 0); }
EOC
};
if ($@) {
print "\tplsvect function not found, no vector plotting available!\n";
open (OPT, ">>OPTIONS!");
print OPT "NOVECT!\n";
close OPT;
} else {
print "\tplsvect function found, vector plotting available!\n";
}
# Test if PLplot has support for alpha transparency, found in versions 5.9.0 and higher
eval { compileAndRun ("$plplot_include_path -L$plplot_lib_path -lplplotd",0,<<'EOC');
#include <plplot.h>
main () { c_plgcol0a(0, 0, 0, 0, NULL);}
EOC
};
if ($@){
print "\tc_plgcol0a function not found, no alpha transparency available (need PLplot 5.9.0 or higher)!\n";
open (OPT,">>OPTIONS!");
print OPT "NOALPHA!\n";
close OPT;
} else {
print "\tc_plgcol0a function found, alpha transparency available!\n";
}
# Test if PLplot has 5 argument plpoly3 (5.1.1 and earlier) or 6 argument (5.2.0 and later)
eval { compileAndRun ("$plplot_include_path -L$plplot_lib_path -lplplotd", 0, <<'EOC');
#include <plplot.h>
main () { plpoly3 (0, NULL, NULL, NULL, NULL); }
EOC
};
if ($@) {
print "\tplpoly3 needs 6 arguments => version 5.2.0 or later!\n";
open (OPT, ">>OPTIONS!");
print OPT "PLPOLY3 = 6\n";
close OPT;
} else {
print "\tplpoly3 needs 5 arguments => version 5.1.1 or earlier!\n";
open (OPT, ">>OPTIONS!");
print OPT "PLPOLY3 = 5\n";
close OPT;
}
# Test if PLplot has the routine plseed, found only in plplot 5.9 svn and later
eval { compileAndRun ("$plplot_include_path -L$plplot_lib_path -lplplotd",0,<<'EOC');
#include <plplot.h>
main () { c_plseed(0);}
EOC
};
if ($@){
print "\tc_plseed function not found, plplot versionn 5.9 or earlier!\n";
open (OPT,">>OPTIONS!");
print OPT "NOPLSEED!\n";
close OPT;
} else {
print "\tc_plseed function found, version 5.9 SVN or later!\n";
}
$PDL::Config{WITH_PLPLOT} = 1;
#
## new way to get writemakefile args...
#
@pack = (["plplot.pd",PLplot,PDL::Graphics::PLplot]);
#%hash = pdlpp_stdargs_int(@::pack); # use this for module inside PDL source
%hash = pdlpp_stdargs(@::pack); # use this for separate module
$hash{'PREREQ_PM'} = { PDL => 0 };
$hash{'OPTIMIZE'} = '-g'; # If you want to debug, uncomment this.
$hash{'VERSION_FROM'} = 'plplot.pd';
$hash{'LIBS'} = [$libs];
# add this to allow one to use the /ops/tools/lib plplot libs even when
# another plplot is installed in /usr/local/lib. D. Hunt 6/4/2004
$hash{'LDDLFLAGS'} = " -shared -L$plplot_lib_path -L/usr/local/lib ";
$hash{'INC'} .= " $plplot_include_path";
$hash{'clean'} = {'FILES' =>
'PLplot.pm PLplot.xs PLplot.o PLplot.c PLplot.bs *.xfig temp* OPTIONS! Makefile.old'};
my $postamble = pdlpp_postamble(@::pack); # use for external module
#my $postamble = pdlpp_postamble_int(@::pack); # use for install inside PDL distro
WriteMakefile(%hash);
# Add genpp rule
sub MY::postamble { $postamble };
sub compileAndRun {
my $flags = shift;
my $run = shift;
my $code = shift;
open (OUT, ">temp.c");
print OUT $code;
close OUT;
unlink './temp'; # since we work out whether the compile succeeds by presence of this
unlink './temp.exe'; # since we work out whether the compile succeeds by presence of this
my $cc = $Config{cc};
my $ccflags = $Config{ccflags};
# print "Trying: $cc $ccflags $flags temp.c -o temp\n";
system "$cc $ccflags $flags temp.c $flags -o temp > /dev/null 2>&1";
unlink('./temp.c');
die "Cannot compile test program: $code" unless (-e 'temp' or -e 'temp.exe');
return unless ($run);
my $res = `./temp`;
unlink ('./temp');
return $res;
}
sub buildDummy {
my $msg = shift;
$msg .= "\n Not building PDL::Graphics::PLplot\n";
warn $msg . "\n";
$msg =~ s/\n//g;
write_dummy_make( $msg );
$PDL::Config{WITH_PLPLOT} = 0;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks