OpenGL
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
$interface_lib eq 'FREEGLUT' && $IS_STRAWBERRY ? '-lglut' :
'-LFreeGLUT -lfreeglut'
)
if $IS_W32API || $^O eq 'MSWin32';
my $libs = join '', map " $_", grep $_, sort(values %$found_libs), '-lm';
$libs = "@$ldirs $libs";
return $libs if $NO_LGCC || $Config{cc} eq 'gcc' || $Config{gccversion};
# Handle obfuscated gcc
# This may be a gcc compiler in disguise.
my $gccout = `gcc -v 2>&1`;
return $libs if $gccout !~ /specs from (.*)/;
(my $gcclibdir = $1) =~ s,\bspecs\s*$,,;
print STDERR <<'EOF';
#
### Non-gcc compiler, and gcc is present.
### Adding -lgcc as a dependency: your OpenGL libraries may be gcc-compiled.
### Use NO_LGCC command-line option to disable this.
#
EOF
$libs . " -L$gcclibdir -lgcc";
}
# Find OpenGL-related Libs
sub get_found_libs {
my ($ldirs, @glx_libs) = @_;
my $found = {};
my $libs;
# Mac OS X
if ($^O eq 'darwin' && -d '/System/Library/Frameworks/OpenGL.framework') {
$found->{GL} = '-framework OpenGL';
$found->{GLU} = '';
$found->{GLUT} = '-framework GLUT';
for (@$ldirs) {
(my $dir = $_) =~ s/^-L//;
next if !-e "$dir/libglut.3.dylib";
$found->{FREEGLUT} = '-lglut';
last;
}
return $found;
}
# Win32
if ($IS_STRAWBERRY) {
# libs for strawberry perl go here
$found->{FREEGLUT} = '-lglut';
$found->{GL} = $found->{OPENGL32} = '-lopengl32';
$found->{GLU} = $found->{GLU32} = '-lglu32';
} elsif (($^O eq 'MSWin32') || $IS_W32API) {
my $paths = $ENV{PATH};
$paths =~ s|\\|/|g;
my $sep = $IS_W32API ? ':' : ';';
my @paths = split($sep.'\s*',$paths);
unshift @paths, "$ENV{SYSTEMROOT}/system32" if $ENV{SYSTEMROOT};
$libs = {OPENGL32=>'opengl32.dll',GLU32=>'glu32.dll',GLUT32=>'glut32.dll',FREEGLUT32=>'freeglut.dll'};
foreach my $key (sort keys %$libs) {
foreach my $path (@paths) {
$path =~ s|/$||;
my $lib = $libs->{$key};
next if (!-e "$path/$lib");
$lib =~ s/\.dll$//i;
if ( $lib eq "freeglut" ) {
my @p = split m@[/\\]@, $Config{installsitebin};
next if $path eq join "/", @p or $path eq join "\\", @p;
}
# print " $key: $lib\n";
$found->{$key} = "-l$lib";
last;
}
}
# Install FreeGLUT if not found
if (!$found->{FREEGLUT32} and !$IS_STRAWBERRY) {
my $dll_dir = "utils";
my $exec;
if ($IS_W32API) {
$dll_dir = '/usr/local/bin' if ($dll_dir eq '/usr/bin');
$exec = "cp FreeGLUT/freeglut.dll $dll_dir";
} else {
$exec = "copy FreeGLUT\\freeglut.dll $dll_dir";
}
`$exec`;
if (! -x "$dll_dir/freeglut.dll") {
my $mode = (stat("$dll_dir/freeglut.dll"))[2];
my $perm = $mode & 07777;
print "freeglut.dll not executable (perms=%4o), changing permissions...\n";
chmod $perm|0755, "$dll_dir/freeglut.dll" or warn "Error changing freeglut.dll perms: $!";
}
if (-e "$dll_dir/freeglut.dll") {
print "Installed freeglut.dll at $dll_dir\n";
$found->{FREEGLUT32} = '-lfreeglut'
} else {
print "Unable to install freeglut.dll to $dll_dir\n";
print "Try manually copying FreeGLUT/freeglut.dll to a folder in your PATH.\n";
}
}
delete @$found{qw(GLX MESA)};
$found->{GL} = $found->{OPENGL32};
$found->{GLU} = $found->{GLU32};
$found->{FREEGLUT} = $found->{FREEGLUT32};
$found->{GLUT} = $found->{GLUT32};
return $found if (!$IS_W32API);
}
# Everyone else
($libs) = do {
local $SIG{__WARN__} = sub {
my ( $warning ) = @_;
return if $warning =~ /Warning \(mostly harmless\): No library found for/;
warn $warning;
};
ExtUtils::Liblist->ext(join(' ', @$ldirs, @glx_libs),0);
};
foreach my $lib (split(' ',$libs)) {
next if ($lib =~ m|^-L|);
$lib =~ s/^-l//;
#print " $lib\n";
if ($lib =~ m|([\w]*freeglut[\w]*)|i) {
$found->{FREEGLUT} = "-l$1";
} elsif ($lib =~ m|([\w]*glut[\w]*)$|i) {
$found->{GLUT} = "-l$1";
} elsif ($lib =~ m|([\w]*glu[\w]*)$|i) {
$found->{GLU} = "-l$1";
} elsif ($lib =~ m|([\w-]*glx)$|i) {
$found->{GLX} = "-l$1";
( run in 1.306 second using v1.01-cache-2.11-cpan-71847e10f99 )