Removed ~~ for 5.8.x support
[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;
16
17#checks to see if sdl-config is availabe
18#
19sub sdl_con_found
20{
21 `sdl-config --libs`;
841f9cc5 22 return 1 unless ($? >> 8) and return 0;
23
9632eafc 24}
25
26#This should check if the folder actually has the SDL files
27sub check_sdl_dir
28{
29 return 0 unless $ENV{SDL_INST_DIR} and return $ENV{SDL_INST_DIR};
30}
31
32sub sdl_libs
33{
34 if(sdl_con_found)
35 {
36 local $_ = `sdl-config --libs`;
841f9cc5 37 chomp($_);
38 return $_;
9632eafc 39 }
40 elsif( check_sdl_dir() )
41 {
42 return $arch->alt_link_flags( check_sdl_dir() ) ;
43 }
44 else
45 {
46 #ask to download
47 croak 'SDL not installed';
48 return 0;
49 }
50}
51
52sub sdl_c_flags
53{
54 if(sdl_con_found)
55 {
56 local $_ = `sdl-config --cflags`;
841f9cc5 57 chomp($_);
58 return $_;
9632eafc 59 }
60 elsif ( check_sdl_dir() )
61 {
62 return $arch->alt_compile_flags( check_sdl_dir() );
63}
64 else
65 {
66 #ask to download
67 croak 'SDL not installed';
68 }
69}
70
711;