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
|
use ExtUtils::MakeMaker;
PDL::Core::Dev->import(); # for trylink
@subdirs = ("PGPLOT", "LUT", "IIS", "Karma", "PLplot", "Limits");
# we try and build unless WITH_3d == 0
$t = $PDL::Config{WITH_3D};
if( defined($t) and $t == 0 ) {
print "\n Not building TriD or OpenGL. Turn on WITH_3D if this is incorrect.\n\n";
} else {
print "\n Trying OpenGL configuration $PDL::Config{OPENGL_LIBS}\n\n";
$PDL::Config{OPENGL_LIBS} = guessogllibs($PDL::Config{OPENGL_LIBS});
if ( defined $PDL::Config{OPENGL_LIBS} ) {
unshift @subdirs,"TriD";
if ( $PDL::Config{OPENGL_LIBS} =~ /Mesa/ ) {
$PDL::Config{OPENGL_DEFINE} .= ' -DGL_GLEXT_LEGACY';
}
$PDL::Config{WITH_3D} = 1;
# hack for OS-X
if ($^O eq "darwin" and not defined $PDL::Config{OPENGL_INC}) {
$PDL::Config{OPENGL_INC} = "-I/usr/X11R6/include";
}
print "\n Success using $PDL::Config{OPENGL_LIBS} $PDL::Config{OPENGL_DEFINE}\n\n";
} else {
warn "\n COULD NOT link OpenGL \n".
" Not building OpenGL and TriD options!\n\n";
$PDL::Config{WITH_3D}=0;
}
}
#WriteMakefile(
# 'NAME' => 'PDL',
# VERSION_FROM => '../Basic/Core/Version.pm',
# DIR => [@subdirs]
#);
my @pm_names = qw (Graphics2D.pm State.pm);
my %pm = map { $h = '$(INST_LIBDIR)/';
$h .= 'PDL/' if $_ !~ /PDL.pm$/;
$h .= 'Graphics/' if $_ =~ /State.pm$/;
( $_, $h . $_ );
} ( @pm_names);
my %man3pods = map { $h = '$(INST_MAN3DIR)/';
$h .= 'PDL::' if $_ !~ /PDL.pm$/;
( $_, $h . substr($_,0,length($_)-3) . '.$(MAN3EXT)' );
} @pm_names;
WriteMakefile(
'NAME' => 'PDL',
VERSION_FROM => '../Basic/Core/Version.pm',
'PM' => \%pm,
'MAN3PODS' => \%man3pods,
DIR => [@subdirs],
# LIBS => ['-lm'], # corrected from LIB=>..., then commented out
);
sub guessogllibs{
my $libs=shift;
use Config;
my $have_GL;
my $mmpre = {MakeMaker => 1}; # preprocess by MakeMaker
if(defined $libs){
if (trylink $libs,
'', 'char glBegin(); glBegin();',
libs($libs), $mmpre) {
return $libs;
}else{
undef $libs;
warn " User specified OpenGL configuration $libs did not work"
."\n trying to guess...\n\n";
}
}
if (trylink( 'libGL',
'', 'char glBegin(); glBegin();',
libs('-lGL'), $mmpre)) {
$libs = '-lGLU -lGL';
} elsif (trylink ('libMesaGL',
'', 'char glBegin(); glBegin();',
libs('-lMesaGL'), $mmpre)) {
$libs = '-lMesaGLU -lMesaGL';
} elsif (trylink ('libMesaGL with pthread',
'', 'char glBegin(); glBegin();',
libs('-lMesaGL -lpthread'), $mmpre)) {
$libs = '-lMesaGLU -lMesaGL -lpthread';
}
# Add -lm to libs (Seems to be needed on Linux and Solaris, and shouldn't hurt for others)
# [only do if we've actually found anything]
$libs .= ' -lm' if defined $libs and $libs !~ /\-lm\b/;
return $libs;
}
sub libs ($) {
require ExtUtils::MakeMaker;
require ExtUtils::Liblist;
my ($libs) = @_;
my $lpath = '-L/usr/X11R6/lib -L/usr/lib/mesa';
my $extra = '-lXext -lX11 -lm';
return "$lpath $libs $extra";
}
|