From: Kartik Thakore Date: Thu, 20 Aug 2009 00:56:13 +0000 (-0400) Subject: Windows super hack X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a10ede21cb16ec8302e351fa3963d623a28f5d1a;p=sdlgit%2FSDL_perl.git Windows super hack --- diff --git a/make/lib/SDL/Build/MSWin32.pm b/make/lib/SDL/Build/MSWin32.pm index 957d7e5..338cf02 100644 --- a/make/lib/SDL/Build/MSWin32.pm +++ b/make/lib/SDL/Build/MSWin32.pm @@ -29,140 +29,49 @@ # package SDL::Build::MSWin32; - -use strict; -use warnings; +use Data::Dumper; use Carp; use base 'SDL::Build'; -use File::Spec::Functions; - -sub fetch_includes -{ - - warn "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE}; - return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} ) if $ENV{INCLUDE}; - return '-I.'; -} - -sub find_header -{ - for my $key (qw( LIBS PATH )) - { - #this needs to be carp because some users will have SDL libs in same folder - carp "Environment variable $key is empty\n" unless $ENV{$key}; - carp "This will probably fail the compile \nSet $key manually or try building anyway\n" unless $ENV{$key}; - } - - my ( $self, $header, $includes ) = @_; - ( my $dll = $header ) =~ s/\.h/\.dll/; - - my $include_dir; - - for my $inc_dir ( keys %$includes ) - { - next unless -e catfile( $inc_dir, $header ); - $include_dir = $inc_dir; - } - - return unless $include_dir; - - for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) } - qw( LIB LIBS PATH ) ) - { - return ( $include_dir, $header ) if -e catfile( $lib_path, $dll ); - } -} - -sub link_flags -{ - return 'SDL.lib'; -} - -sub compile_flags -{ - return; -} - -sub subsystems -{ - my $self = shift; - my $subsystems = $self->SUPER::subsystems(); - my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems'; - - $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method(); - return $subsystems; -} - -sub libraries -{ - my $self = shift; - my $libraries = $self->SUPER::libraries(); - my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries'; - - $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method(); - return $libraries; -} - -sub gl_vendor -{ - my ( $self, $vendor ) = @_; - - return 'ms_gl' unless defined $vendor; - return 'mesa_gl' if $vendor eq 'MESA'; - return 'ms_gl' if $vendor eq 'MS'; - croak "Unrecognized GL vendor '$vendor'\n"; - -} - -sub ms_gl_subsystems -{ - return [qw( OpenGL GLU )]; -} - -sub mesa_gl_subsystems -{ - return [qw( mesagl mesaglu osmesa )]; -} - -sub ms_gl_libraries -{ - define => 'OPENGL_VENDOR_MS'; -} -sub mesa_gl_libraries +sub opengl_headers { - define => 'OPENGL_VENDOR_MESA'; + return GL => 'SDL_opengl.h'; } -sub link_c +sub fetch_includes { - my $self = shift; - my ( $blib, $rib ) = @_; - - # until ExtUtils::ParseXS is patched, avoid warnings from cl.exe - $_[-1] =~ s{\\}{/}g; - - $rib =~ s{^src[\\/]}{}; - $rib =~ s{[\\/]}{::}g; - - local $self->{properties}{module_name} = $rib; - $self->SUPER::link_c( @_ ); + return ( + + $ENV{SDL_INST_DIR}.'/include' => $ENV{SDL_INST_DIR}.'/lib', + $ENV{SDL_INST_DIR}.'/include/gl' => $ENV{SDL_INST_DIR}.'/lib', + $ENV{SDL_INST_DIR}.'/include/GL' => $ENV{SDL_INST_DIR}.'/lib', + $ENV{SDL_INST_DIR}.'/include/SDL' => $ENV{SDL_INST_DIR}.'/lib', + $ENV{SDL_INST_DIR}.'/include/smpeg' => $ENV{SDL_INST_DIR}.'/lib', + ); } -sub sdl_libs -{ - my $self = shift; - my $sdl_inst_dir = shift; +#Todo: his needs to be fixed hash references are a mess +#sub build_links +#{ + +# my $self = shift; +# my $links = $self->SUPER::build_links(@_); +# +# for my $subsystem (values %$links) +# { +# push @{ $subsystem{ libs } }, '-lpthreads'; +# } +# return \%links; +#} -} sub alt_link_flags { my $self = shift; my $sdl_dir = shift; - return $self->SUPER::alt_link_flags($sdl_dir).' -lmingw32 -mwindows -lSDLmain -lSDL.dll'; + return $self->SUPER::alt_link_flags($sdl_dir).' -mwindows -lSDLmain -lSDL.dll'; } sub alt_compile_flags diff --git a/make/lib/SDL/Utility.pm b/make/lib/SDL/Utility.pm index 9b4c8fe..a3e3272 100644 --- a/make/lib/SDL/Utility.pm +++ b/make/lib/SDL/Utility.pm @@ -18,6 +18,8 @@ use SDL::Build; # sub sdl_con_found { + return 0 if($^O eq 'MSWin32'); + `sdl-config --libs`; return 1 unless ($? >> 8) and return 0; diff --git a/src/SDL.xs b/src/SDL.xs index 657bfad..f6660fa 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -97,7 +97,27 @@ static int sdl_perl_use_smpeg_audio = 0; #define HAVE_TLS_CONTEXT #endif -#include "src/defines.h" +/* For windows */ +#ifndef SDL_PERL_DEFINES_H +#define SDL_PERL_DEFINES_H + +#ifdef HAVE_TLS_CONTEXT +PerlInterpreter *parent_perl = NULL; +extern PerlInterpreter *parent_perl; +#define GET_TLS_CONTEXT parent_perl = PERL_GET_CONTEXT; +#define ENTER_TLS_CONTEXT \ + PerlInterpreter *current_perl = PERL_GET_CONTEXT; \ + PERL_SET_CONTEXT(parent_perl); { \ + PerlInterpreter *my_perl = parent_perl; +#define LEAVE_TLS_CONTEXT \ + } PERL_SET_CONTEXT(current_perl); +#else +#define GET_TLS_CONTEXT /* TLS context not enabled */ +#define ENTER_TLS_CONTEXT /* TLS context not enabled */ +#define LEAVE_TLS_CONTEXT /* TLS context not enabled */ +#endif + +#endif Uint32 sdl_perl_timer_callback ( Uint32 interval, void* param )