Made sure that Build knows if sdl-config exists
Kartik Thakore [Sun, 9 Aug 2009 01:38:16 +0000 (21:38 -0400)]
Build.PL
inc/Utility.pm [new file with mode: 0644]
lib/SDL/Config.pm

index cc80c12..a32db79 100644 (file)
--- 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 (file)
index 0000000..8247e18
--- /dev/null
@@ -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;
index 241e3ba..8ca726b 100644 (file)
@@ -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'
                                       ]
                            }
               };