Fixed the pod path in archive
[sdlgit/SDL_perl.git] / make / lib / SDL / Utility.pm
CommitLineData
9632eafc 1package SDL::Utility;
2use strict;
3use warnings;
4use Carp;
5
6
7BEGIN{
8 require Exporter;
9 our @ISA = qw(Exporter);
10 our @EXPORT_OK = qw(sdl_con_found sdl_libs sdl_c_flags);
11}
12 my $arch = SDL::Build->get_arch( $^O );
13
14use lib '../';
15use SDL::Build;
2a668066 16use File::Spec;
9632eafc 17
18#checks to see if sdl-config is availabe
19#
20sub sdl_con_found
21{
2a668066 22 my $devnull = File::Spec->devnull();
23 `sdl-config --libs 2>$devnull`;
24 return 1 unless ($? >> 8) and return 0;
9632eafc 25}
26
27#This should check if the folder actually has the SDL files
28sub check_sdl_dir
29{
30 return 0 unless $ENV{SDL_INST_DIR} and return $ENV{SDL_INST_DIR};
31}
32
2a668066 33sub not_installed_message
34{
35 print STDERR <<MSG;
36********************************* !!!ERROR!!! *********************************
37SDL library not found.
381) If you do not have SDL, you can download it from see http://www.libsdl.org/
392) If you have already installed SDL, you can specify the location of your SDL
40 installation by setting the enviroment variable SDL_INST_DIR.
41*******************************************************************************
42MSG
43}
44
45
9632eafc 46sub sdl_libs
47{
48 if(sdl_con_found)
49 {
2a668066 50 my $devnull = File::Spec->devnull();
51 local $_ = `sdl-config --libs 2>$devnull`;
841f9cc5 52 chomp($_);
53 return $_;
9632eafc 54 }
55 elsif( check_sdl_dir() )
56 {
57 return $arch->alt_link_flags( check_sdl_dir() ) ;
58 }
59 else
60 {
61 #ask to download
2a668066 62 not_installed_message;
9632eafc 63 croak 'SDL not installed';
64 return 0;
65 }
66}
67
68sub sdl_c_flags
69{
70 if(sdl_con_found)
71 {
2a668066 72 my $devnull = File::Spec->devnull();
73 local $_ = `sdl-config --cflags 2>$devnull`;
74 chomp($_);
841f9cc5 75 return $_;
9632eafc 76 }
77 elsif ( check_sdl_dir() )
78 {
79 return $arch->alt_compile_flags( check_sdl_dir() );
80}
81 else
82 {
83 #ask to download
2a668066 84 not_installed_message ;
9632eafc 85 croak 'SDL not installed';
86 }
87}
88
891;