Patched kmx's patch from here http://rt.cpan.org/Ticket/Display.html?id=49000
[sdlgit/SDL_perl.git] / make / lib / SDL / Utility.pm
index a3e3272..94f5a82 100644 (file)
@@ -13,16 +13,15 @@ BEGIN{
 
 use lib '../';
 use SDL::Build;
+use File::Spec;
 
 #checks to see if sdl-config is availabe
 #
 sub sdl_con_found
 {
-       return 0 if($^O eq 'MSWin32');
-
-       `sdl-config --libs`;
-       return 1 unless ($? >> 8) and return 0;
-       
+       my $devnull = File::Spec->devnull();    
+       `sdl-config --libs 2>$devnull`;
+       return 1 unless ($? >> 8) and return 0;
 }
 
 #This should check if the folder actually has the SDL files
@@ -31,11 +30,25 @@ sub check_sdl_dir
        return 0 unless $ENV{SDL_INST_DIR} and return $ENV{SDL_INST_DIR};
 }
 
+sub not_installed_message
+{
+       print STDERR <<MSG;
+********************************* !!!ERROR!!! ********************************* 
+SDL library not found.
+1) If you do not have SDL, you can download it from see http://www.libsdl.org/
+2) If you have already installed SDL, you can specify the location of your SDL
+   installation by setting the enviroment variable SDL_INST_DIR.  
+*******************************************************************************
+MSG
+}
+
+
 sub sdl_libs
 {
        if(sdl_con_found)
        {
-               local $_ = `sdl-config --libs`;
+               my $devnull = File::Spec->devnull();
+               local $_ = `sdl-config --libs 2>$devnull`; 
                chomp($_);
                return $_;
        }       
@@ -46,6 +59,7 @@ sub sdl_libs
        else
        {
                #ask to download
+               not_installed_message;
                croak 'SDL not installed';
                return 0;
        }
@@ -55,8 +69,9 @@ sub sdl_c_flags
 {
         if(sdl_con_found)
         {
-                       local $_  = `sdl-config --cflags`;
-               chomp($_);
+               my $devnull = File::Spec->devnull();
+               local $_  = `sdl-config --cflags 2>$devnull`;    
+               chomp($_);
                return $_;
         }
        elsif ( check_sdl_dir() )
@@ -66,6 +81,7 @@ sub sdl_c_flags
        else
        {
                #ask to download
+               not_installed_message ;
                croak 'SDL not installed';
        }
 }