From: Kartik Thakore Date: Sun, 9 Aug 2009 01:38:16 +0000 (-0400) Subject: Made sure that Build knows if sdl-config exists X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=33710f4eb4f0879b258b707799e1f267a6ab4bfa;p=sdlgit%2FSDL_perl.git Made sure that Build knows if sdl-config exists --- diff --git a/Build.PL b/Build.PL index cc80c12..a32db79 100644 --- a/Build.PL +++ b/Build.PL @@ -13,19 +13,10 @@ use Data::Dumper; use SDL::Build; use YAML; use YAML::Node; +use inc::Utility qw(sdl_libs sdl_c_flags); -my $sdl_compile_flags = `sdl-config --cflags`; -my $sdl_link_flags = `sdl-config --libs`; - -if ($? >> 8) -{ - croak "SDL doesn't appear to be installed.\n" . - "Please check that sdl-config is in your path and try again.\n"; -} - -chomp( $sdl_compile_flags ); -chomp( $sdl_link_flags ); - +my $sdl_compile_flags = sdl_c_flags(); +my $sdl_link_flags = sdl_libs(); # subsystem to build # file # location of source file => location of build file to get name right diff --git a/inc/Utility.pm b/inc/Utility.pm new file mode 100644 index 0000000..8247e18 --- /dev/null +++ b/inc/Utility.pm @@ -0,0 +1,47 @@ +package inc::Utility; +use strict; +use warnings; +use Carp; + +BEGIN{ + require Exporter; + our @ISA = qw(Exporter); + our @EXPORT_OK = qw(sdl_con_found sdl_libs sdl_c_flags); +} + +#checks to see if sdl-config is availabe +# +sub sdl_con_found +{ + `sdl-config --libs`; + return 0 if ($? >> 8); + return 1; +} + +sub sdl_libs +{ + if(sdl_con_found) + { + local $_ = `sdl-config --libs`; + return chomp($_); + } + else + { + return undef; + } +} + +sub sdl_c_flags +{ + if(sdl_con_found) + { + local $_ = `sdl-config --cflags`; + return chomp($_); + } + else + { + return undef; + } +} + +1; diff --git a/lib/SDL/Config.pm b/lib/SDL/Config.pm index 241e3ba..8ca726b 100644 --- a/lib/SDL/Config.pm +++ b/lib/SDL/Config.pm @@ -4,61 +4,64 @@ my $sdl_config; $sdl_config = { 'OpenGL' => { 'GL' => [ - '/System/Library/Frameworks/OpenGL.framework/Headers', - '/System/Library/Frameworks/OpenGL.framework/Libraries' + '/usr/include/GL', + '/usr/lib' ], 'SDL' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ], 'GLU' => [ - '/System/Library/Frameworks/OpenGL.framework/Headers', - '/System/Library/Frameworks/OpenGL.framework/Libraries' + '/usr/include/GL', + '/usr/lib' ] }, 'SDL' => { 'png' => [ - '/opt/local/include', - '/opt/local/lib' + '/usr/include', + '/usr/lib' ], 'SDL' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ], 'SDL_ttf' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ], 'SDL_net' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ], 'SDL_image' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ], 'SDL_gfx' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ], 'jpeg' => [ - '/opt/local/include', - '/opt/local/lib' + '/usr/include', + '/usr/lib' ], - 'smpeg' => 0, + 'smpeg' => [ + '/usr/include/smpeg', + '/usr/lib' + ], 'SDL_mixer' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ] }, 'SFont' => { 'SDL_image' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ], 'SDL' => [ - '/opt/local/include/SDL', - '/opt/local/lib' + '/usr/include/SDL', + '/usr/lib' ] } };