Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'experimental' of github.com:PerlGameDev/Alien-SDL into …

…experimental
  • Loading branch information...
commit 988afa5ae3cdddd9f948ade7e91df1e103ad72d9 2 parents 6bbf9d3 + 9e6b3c0
@kthakore kthakore authored
View
19 Build.PL
@@ -101,6 +101,7 @@ my $build = $package->new(
);
my $choice;
+my %have_libs = ();
if (defined $sdl_config) {
# handle --with-sdl-config (without params)
@@ -156,10 +157,13 @@ else {
# sdl-config script
push @candidates, $rv if $rv = check_config_script("sdl-config");
- my %have_libs = ();
if( $build->can_build_binaries_from_sources || scalar(@candidates) ) {
- for(qw(pthread SDL z jpeg tiff png SDL_image ogg vorbis SDL_mixer SDL_ttf SDL_gfx
- pangoft2 pango gobject gmodule glib fontconfig freetype expat SDL_Pango)) {
+ for(qw(pthread SDL
+ z jpeg tiff png SDL_image
+ ogg vorbis vorbisfile SDL_mixer
+ freetype SDL_ttf
+ SDL_gfx
+ pangoft2 pango gobject gmodule glib fontconfig expat SDL_Pango)) {
$have_libs{$_} = check_prereqs_libs($_);
}
}
@@ -171,11 +175,11 @@ else {
for my $p ( @$source_packs ) {
$rv = { title => $p->{title}, members => [], buildtype => 'build_from_sources' };
for my $m (@{ $p->{members} }) {
- next if $m->{pack} !~ /^SDL/ && $have_libs{ $m->{pack} };
+ next if $m->{pack} !~ /^SDL/ && $have_libs{ $m->{pack} }[0];
my $good = 1;
- $good &= $have_libs{$_} ? 1 : 0 for @{ $m->{prereqs}->{libs} };
+ $good &= $have_libs{$_} && $have_libs{$_}[0] ? 1 : 0 for @{ $m->{prereqs}->{libs} };
if( $good ) {
- $have_libs{ $m->{pack} } ||= 1;
+ $have_libs{ $m->{pack} }[0] ||= 1;
push @{ $rv->{members} }, $m;
$rv->{title} .= "$m->{pack}(v$m->{version}) ";
}
@@ -196,7 +200,7 @@ else {
if( $c->{buildtype} eq 'use_config_script' ) {
$c->{title} .= "\n ";
for(qw(SDL SDL_image SDL_mixer SDL_ttf SDL_gfx SDL_Pango)) {
- $c->{title} .= "$_(v$have_libs{$_}) " if $have_libs{$_};
+ $c->{title} .= "$_(v$have_libs{$_}->[0]) " if $have_libs{$_}[0];
}
}
@@ -218,6 +222,7 @@ if($choice) {
$build->notes('build_params', $choice);
$build->notes('env_include', $ENV{INCLUDE}) if $ENV{INCLUDE};
$build->notes('env_lib', $ENV{LIB}) if $ENV{LIB};
+ $build->notes('have_libs', \%have_libs);
$build->create_build_script();
#### clean build_done stamp; force rebuild when running 'Build'
View
15 Changes
@@ -2,6 +2,21 @@ Revision history for Perl module Alien::SDL
Versioning rule: public releases are even numbers, dev releases are odd. (same like perl dist)
+TODO
+ - check for available libs when using --with-sdl-config option
+
+1.436 Tue Jun 19 2012
+ - reapplied openbsd-rldflags patch, it got lost during update to SDL-1.2.15 [FROGGS]
+ - fixed SDL dirname during Build when applying patches (was SDL-1.2.14, is SDL-1.2) [FROGGS]
+ - removed cl from cc_re for gcc binary sets, made new binary set for ActivePerl instead [FROGGS]
+ - checking environment on windows when compiler is cl [FROGGS]
+ - using vcvars32.bat to set up env on windows [FROGGS]
+ - cl compiler prints to stdout instead of stderr, displaying these messages [FROGGS]
+ - added libs like ogg to shlib_map, needed for loading these libs at runtime to help msvc [FROGGS]
+ - added patches/SDL_config_win32.h for msvc, because it has no configure [FROGGS]
+ - setting ld_shlib_map for 'already installed'-option too [FROGGS]
+ - msvc binary package contains patched SDL_rwops.h [FROGGS]
+
1.434 Thu May 31 2012
- added compiler checks [FROGGS]
View
2  MANIFEST
@@ -11,6 +11,8 @@ MANIFEST.SKIP
META.json
META.yml
patches/jpeg-8a_cygwin.patch
+patches/libvorbis-1.3.3-configure.patch
+patches/SDL-1.2-openbsd-rldflags.patch
patches/SDL_config_win32.h
patches/SDL_image-1.2.11-libpng-flags.patch
patches/SDL_mixer-1.2.12-native-midi-win32.patch
View
2  README
@@ -2,7 +2,7 @@ NAME
Alien::SDL - building, finding and using SDL binaries
VERSION
- Version 1.434
+ Version 1.436
SYNOPSIS
Alien::SDL tries (in given order) during its installation:
View
69 inc/My/Builder.pm
@@ -91,6 +91,7 @@ sub ACTION_code {
if($bp->{buildtype} eq 'use_config_script') {
$self->config_data('script', $bp->{script});
# include path trick - adding couple of addititonal locations
+ $self->set_ld_config($build_out);
$self->config_data('additional_cflags', '-I' . $self->get_path($bp->{prefix} . '/include/smpeg') . ' '.
'-I' . $self->get_path($bp->{prefix} . '/include') . ' ' .
$self->get_additional_cflags);
@@ -102,6 +103,7 @@ sub ACTION_code {
$self->clean_dir($build_out);
$self->extract_binaries($download, $build_out);
$self->set_config_data($build_out);
+ $self->set_ld_config($build_out);
}
elsif($bp->{buildtype} eq 'build_from_sources' ) {
# all the following functions die on error, no need to test ret values
@@ -110,6 +112,7 @@ sub ACTION_code {
$self->clean_dir($build_out);
$self->build_binaries($build_out, $build_src);
$self->set_config_data($build_out);
+ $self->set_ld_config($build_out);
}
# mark sucessfully finished build
@@ -241,19 +244,19 @@ sub set_config_data {
my $L = $My::Utility::cc eq 'cl'
? '/LIBPATH:'
: '-L';
- my $cfg = {
- # defaults
- version => $version,
- prefix => '@PrEfIx@',
- libs => $L . $self->get_path('@PrEfIx@/lib') . ' -lSDLmain -lSDL',
- cflags => '-I' . $self->get_path('@PrEfIx@/include/SDL') . ' -D_GNU_SOURCE=1 -Dmain=SDL_main',
- shared_libs => [ ],
- };
+ my $cfg = $self->config_data('config') || {};
+
+ # defaults
+ $cfg->{version} = $version;
+ $cfg->{prefix} = '@PrEfIx@';
+ $cfg->{libs} = $L . $self->get_path('@PrEfIx@/lib') . ' -lSDLmain -lSDL';
+ $cfg->{cflags} = '-I' . $self->get_path('@PrEfIx@/include/SDL') . ' -D_GNU_SOURCE=1 -Dmain=SDL_main';
+ $cfg->{ld_shared_libs} = [ ];
# overwrite values available via sdl-config
- my $bp = $self->config_data('build_prefix') || $prefix;
+ my $bp = $self->config_data('build_prefix') || $prefix;
my $devnull = File::Spec->devnull();
- my $script = rel2abs("$prefix/bin/sdl-config");
+ my $script = $self->escape_path( rel2abs("$prefix/bin/sdl-config") );
foreach my $p (qw(version prefix libs cflags)) {
my $o=`$script --$p 2>$devnull`;
if ($o) {
@@ -263,11 +266,22 @@ sub set_config_data {
}
}
+ # write config
+ $self->config_data('additional_cflags', '-I' . $self->get_path('@PrEfIx@/include') . ' ' .
+ '-I' . $self->get_path('@PrEfIx@/include/smpeg') . ' ' .
+ $self->get_additional_cflags);
+ $self->config_data('additional_libs', $self->get_additional_libs);
+ $self->config_data('config', $cfg);
+}
+
+sub set_ld_config {
+ my( $self, $build_out ) = @_;
+ my ($version, $prefix, $incdir, $libdir) = find_SDL_dir(rel2abs($build_out));
+ my $cfg = $self->config_data('config') || {};
my $dlext = get_dlext();
# find ld_shared_libs and create symlinks if necessary
my $symlink_exists = eval { symlink("",""); 1 };
- if($symlink_exists)
- {
+ if($symlink_exists) {
my @shlibs_ = find_file($build_out, qr/\.$dlext[\d\.]+$/);
foreach my $full (@shlibs_){
$full =~ qr/(.*\.$dlext)[\d\.]+$/;
@@ -278,9 +292,8 @@ sub set_config_data {
# find and set ld_shared_libs
my @shlibs = find_file($build_out, qr/\.$dlext$/);
- my $p = rel2abs($prefix);
- $_ =~ s/^\Q$prefix\E/\@PrEfIx\@/ foreach (@shlibs);
- $cfg->{ld_shared_libs} = [ @shlibs ];
+# my $p = rel2abs($prefix);
+ $_ =~ s/^\Q$prefix\E/\@PrEfIx\@/ foreach (@shlibs);
# set ld_paths and ld_shlib_map
my %tmp = ();
@@ -307,14 +320,20 @@ sub set_config_data {
$shlib_map{SDL} = $full unless $shlib_map{SDL};
}
};
- $cfg->{ld_paths} = [ keys %tmp ];
- $cfg->{ld_shlib_map} = \%shlib_map;
- # write config
- $self->config_data('additional_cflags', '-I' . $self->get_path('@PrEfIx@/include') . ' ' .
- '-I' . $self->get_path('@PrEfIx@/include/smpeg') . ' ' .
- $self->get_additional_cflags);
- $self->config_data('additional_libs', $self->get_additional_libs);
+ $cfg->{ld_shared_libs} = [ @shlibs ];
+ $cfg->{ld_paths} = [ keys %tmp ];
+ $cfg->{ld_shlib_map} = \%shlib_map;
+
+ my $have_libs = $self->notes('have_libs');
+ for(qw(pthread z jpeg tiff png ogg vorbis vorbisfile freetype
+ pangoft2 pango gobject gmodule glib fontconfig expat )) {
+ if( !$shlib_map{$_} && $have_libs->{$_}->[0] ) {
+ push @{ $cfg->{ld_shared_libs} }, $have_libs->{$_}->[1];
+ $shlib_map{$_} = $have_libs->{$_}->[1];
+ }
+ }
+
$self->config_data('config', $cfg);
}
@@ -356,6 +375,12 @@ sub clean_dir {
}
}
+sub escape_path {
+ # this needs to be overriden in My::Builder::<platform>
+ my( $self, $path ) = @_;
+ return $path;
+}
+
sub check_build_done_marker {
my $self = shift;
return (-e 'build_done');
View
36 inc/My/Builder/Unix.pm
@@ -31,7 +31,10 @@ sub get_additional_libs {
my %rv; # putting detected dir into hash to avoid duplicates
for (keys %$inc_lib_candidates) {
my $ld = $inc_lib_candidates->{$_};
- $rv{"-L$ld"} = 1 if ((-d $_) && (-d $ld));
+ if( -d $_ && -d $ld ) {
+ $rv{"-L$ld"} = 1;
+ $rv{"-Wl,-rpath,$ld"} = 1 if $^O =~ /^linux|dragonfly|.+bsd$/;
+ }
}
push @list, (keys %rv);
push @list, '-lpthread' if ($^O eq 'openbsd');
@@ -47,7 +50,7 @@ sub build_binaries {
my( $self, $build_out, $build_src ) = @_;
my $bp = $self->notes('build_params');
foreach my $pack (@{$bp->{members}}) {
- if($pack->{pack} =~ m/^png|ogg|vorbis|z$/ && check_prereqs_libs($pack->{pack})) {
+ if($pack->{pack} =~ m/^png|ogg|vorbis|z$/ && check_prereqs_libs($pack->{pack})->[0]) {
print "SKIPPING package '" . $pack->{dirname} . "' (already installed)...\n";
}
elsif($pack->{pack} =~ m/^(SDL_mixer)$/ && !$self->_is_gnu_make($self->_get_make)) {
@@ -119,8 +122,9 @@ sub build_binaries {
sub _get_configure_cmd {
my ($self, $pack, $prefixdir) = @_;
my $extra = '';
- my $extra_cflags = "-I$prefixdir/include";
- my $extra_ldflags = "-L$prefixdir/lib";
+ my $escaped_prefixdir = $self->escape_path( $prefixdir );
+ my $extra_cflags = "-I$escaped_prefixdir/include " . $self->get_additional_cflags();
+ my $extra_ldflags = "-L$escaped_prefixdir/lib " . $self->get_additional_libs();
my $extra_PATH = "";
my $uname = $Config{archname};
my $stdout = '';
@@ -162,12 +166,7 @@ sub _get_configure_cmd {
}
if($pack =~ /^SDL_/) {
- $extra .= " --with-sdl-prefix=$prefixdir";
- }
-
- if($pack =~ /^SDL/ && -d '/usr/X11R6/lib' && -d '/usr/X11R6/include') {
- $extra_cflags .= ' -I/usr/X11R6/include';
- $extra_ldflags .= ' -L/usr/X11R6/lib';
+ $extra .= " --with-sdl-prefix=$escaped_prefixdir";
}
if($^O eq 'cygwin') {
@@ -205,19 +204,19 @@ sub _get_configure_cmd {
if($pack eq 'z') {
# does not support params CFLAGS=...
- $cmd = "./configure --prefix=$prefixdir";
+ $cmd = "./configure --prefix=$escaped_prefixdir";
}
else {
- $cmd = "./configure --prefix=$prefixdir --enable-static=yes --enable-shared=yes $extra" .
+ $cmd = "./configure --prefix=$escaped_prefixdir --enable-static=yes --enable-shared=yes $extra" .
" CFLAGS=\"$extra_cflags\" LDFLAGS=\"$extra_ldflags\"";
}
- if($pack ne 'SDL' && $^O =~ /^openbsd|gnukfreebsd$/) {
- $cmd = "LD_LIBRARY_PATH=\"$prefixdir/lib:\$LD_LIBRARY_PATH\" $cmd";
+ if($pack ne 'SDL' && $^O =~ /bsd$/) {
+ $cmd = "LD_LIBRARY_PATH=\"$escaped_prefixdir/lib:\$LD_LIBRARY_PATH\" $cmd";
}
if($pack eq 'vorbis') {
- $cmd = "PKG_CONFIG_PATH=\"$prefixdir/lib/pkgconfig:\$PKG_CONFIG_PATH\" $cmd";
+ $cmd = "PKG_CONFIG_PATH=\"$escaped_prefixdir/lib/pkgconfig:\$PKG_CONFIG_PATH\" $cmd";
}
return $cmd;
@@ -252,4 +251,11 @@ sub _is_gnu_make {
return 0;
}
+sub escape_path {
+ my( $self, $path ) = @_;
+ my $_path = $path;
+ $_path =~ s/([^\\]) /$1\\ /g;
+ return $_path;
+}
+
1;
View
14 inc/My/Builder/Windows.pm
@@ -47,13 +47,21 @@ sub get_additional_libs {
my $libs = '';
my $inc = $_;
for( @libs ) {
- my $_lib = eval { require Win32; Win32::GetShortPathName($_); };
- $_lib ||= $_;
- $libs .= "/LIBPATH:\"$_lib\" " ;
+ my $_lib = $self->escape_path( $_ );
+ $libs .= "/LIBPATH:$_lib " ;
}
return $libs;
}
return '';
}
+sub escape_path {
+ my( $self, $path ) = @_;
+ my $_path = eval { require Win32; Win32::GetShortPathName($path); };
+ $_path ||= $path;
+ $_path = qq("$_path") if $_path =~ / /;
+
+ return $_path;
+}
+
1;
View
20 inc/My/Utility.pm
@@ -18,12 +18,14 @@ our $inc_lib_candidates = {
'/usr/local/include' => '/usr/local/lib',
'/usr/include' => '/usr/lib',
'/usr/X11R6/include' => '/usr/X11R6/lib',
- '/usr/pkg/include' => '/usr/pkg/lib',
'/usr/local/include/smpeg' => '/usr/local/lib',
};
$inc_lib_candidates->{'/usr/pkg/include/smpeg'} = '/usr/local/lib' if -f '/usr/pkg/include/smpeg/smpeg.h';
$inc_lib_candidates->{'/usr/include/smpeg'} = '/usr/lib' if -f '/usr/include/smpeg/smpeg.h';
$inc_lib_candidates->{'/usr/X11R6/include'} = '/usr/X11R6/lib' if -f '/usr/X11R6/include/GL/gl.h';
+$inc_lib_candidates->{'/usr/X11R7/include'} = '/usr/X11R7/lib' if -f '/usr/X11R7/include/GL/gl.h';
+$inc_lib_candidates->{'/usr/X11R7/include'} = '/usr/X11R7/lib' if -f '/usr/X11R7/include/freetype2/freetype/freetype.h';
+$inc_lib_candidates->{'/usr/X11R7/include'} = '/usr/X11R7/lib' if -f '/usr/X11R7/include/fontconfig/fontconfig.h';
$inc_lib_candidates->{'/usr/include/ogg'} = '/usr/lib/x86_64-linux-gnu' if -f '/usr/lib/x86_64-linux-gnu/libogg.so';
$inc_lib_candidates->{'/usr/include/vorbis'} = '/usr/lib/x86_64-linux-gnu' if -f '/usr/lib/x86_64-linux-gnu/libvorbis.so';
$inc_lib_candidates->{'/usr/include'} = '/usr/lib64' if -e '/usr/lib64' && $Config{'myarchname'} =~ /64/;
@@ -86,10 +88,10 @@ my $prebuilt_binaries = [
gccversion_re => qr/^4\.(4\.[5-9]|[5-9]\.[0-9])$/,
},
{
- title => "Binaries Win/32bit SDL-1.2.15 (20120610)\n" .
+ title => "Binaries Win/32bit SDL-1.2.15 (20120612)\n" .
"\t(gfx, image, mixer, smpeg, ttf)",
url => [
- 'http://froggs.de/libsdl/Win32_SDL-1.2.15-20120610.zip',
+ 'http://froggs.de/libsdl/Win32_SDL-1.2.15-20120612.zip',
],
sha1sum => '22c531c1d0cc5a363c05045760870b2f45e9d0da',
arch_re => qr/^MSWin32/,
@@ -185,6 +187,7 @@ our $source_packs = [
sha1sum => 'ec9841377403e8d1bcfd76626434be64d11f59f0',
patches => [
'test1.patch',
+ 'SDL-1.2-openbsd-rldflags.patch',
],
prereqs => {
libs => [
@@ -230,7 +233,9 @@ our $source_packs = [
'http://froggs.de/libsdl/libvorbis-1.3.3.tar.gz',
],
sha1sum => '8dae60349292ed76db0e490dc5ee51088a84518b',
- patches => [ ],
+ patches => [
+ 'libvorbis-1.3.3-configure.patch',
+ ],
prereqs => {
libs => [ ]
}
@@ -363,6 +368,7 @@ sub check_prereqs_libs {
foreach my $lib (@libs) {
print "checking for $lib... ";
+ my $found_dll = '';
my $found_lib = '';
my $found_inc = '';
my $header_map = {
@@ -378,6 +384,8 @@ sub check_prereqs_libs {
foreach (keys %$inc_lib_candidates) {
my $ld = $inc_lib_candidates->{$_};
next unless -d $_ && -d $ld;
+ ($found_dll) = find_file($ld, qr/[\/\\]lib\Q$lib\E[\-\d\.]*\.($dlext[\d\.]*|so|dll)$/);
+ $found_dll = $1 if $found_dll && $found_dll =~/^(.+($dlext|so|dll))/ && -e $1;
($found_lib) = find_file($ld, qr/[\/\\]lib\Q$lib\E[\-\d\.]*\.($dlext[\d\.]*|a|dll.a)$/);
($found_inc) = find_file($_, qr/[\/\\]\Q$header\E[\-\d\.]*\.h$/);
last if $found_lib && $found_inc;
@@ -394,8 +402,8 @@ sub check_prereqs_libs {
if( scalar(@libs) == 1 ) {
return $ret
- ? (get_header_version($found_inc) || 'found')
- : 0;
+ ? [(get_header_version($found_inc) || 'found'), $found_dll]
+ : [0, undef];
}
}
View
4 lib/Alien/SDL.pm
@@ -16,11 +16,11 @@ Alien::SDL - building, finding and using SDL binaries
=head1 VERSION
-Version 1.434
+Version 1.436
=cut
-our $VERSION = '1.434';
+our $VERSION = '1.436';
$VERSION = eval $VERSION;
=head1 SYNOPSIS
View
11 patches/SDL-1.2-openbsd-rldflags.patch
@@ -0,0 +1,11 @@
+--- SDL-1.2/configure 2012-01-19 07:30:12.000000000 +0100
++++ SDL-1.2/configure 2012-06-12 00:41:50.000000000 +0200
+@@ -30242,7 +30242,7 @@
+ # Set runtime shared library paths as needed
+
+ if test "x$enable_rpath" = "xyes"; then
+- if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
++ if test $ARCH = bsdi -o $ARCH = openbsd -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
+ SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
+ fi
+ if test $ARCH = solaris; then
View
13 patches/libvorbis-1.3.3-configure.patch
@@ -0,0 +1,13 @@
+--- libvorbis-1.3.3/configure 2012-02-03 23:01:11.000000000 +0100
++++ libvorbis-1.3.3/configure 2012-06-17 21:15:11.000000000 +0200
+@@ -12221,8 +12221,8 @@
+ CFLAGS="-O20 -Wall -W -ffast-math -D_REENTRANT -fsigned-char"
+ PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char";;
+ *)
+- DEBUG="-g -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char"
+- CFLAGS="-O20 -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char"
++ DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char"
++ CFLAGS="-O20 -Wall -D__NO_MATH_INLINES -fsigned-char"
+ PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
+ esac
+
View
9 t/002_config.t
@@ -1,6 +1,6 @@
# t/002_config.t - test config() functionality
-use Test::More tests => 5;
+use Test::More tests => 6;
use Alien::SDL;
### test some config strings
@@ -19,6 +19,13 @@ foreach (@{Alien::SDL->config('ld_shared_libs')}) {
}
is( $l_result, 1, "Testing 'ld_shared_libs'" );
+### check if list of ld_shlib_map contains existing files
+my $m_result = 1;
+foreach (values %{Alien::SDL->config('ld_shlib_map')}) {
+ $m_result = 0 unless (-e $_);
+}
+is( $m_result, 1, "Testing 'ld_shlib_map'" );
+
### check if list of ld_paths contains existing directories
my $p_result = 1;
foreach (@{Alien::SDL->config('ld_paths')}) {
Please sign in to comment.
Something went wrong with that request. Please try again.