Fixed version
[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`;
22 return 0 if ($? >> 8);
23 return 1;
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`;
37 return chomp($_);
38 }
39 elsif( check_sdl_dir() )
40 {
41 return $arch->alt_link_flags( check_sdl_dir() ) ;
42 }
43 else
44 {
45 #ask to download
46 croak 'SDL not installed';
47 return 0;
48 }
49}
50
51sub sdl_c_flags
52{
53 if(sdl_con_found)
54 {
55 local $_ = `sdl-config --cflags`;
56 return chomp($_);
57 }
58 elsif ( check_sdl_dir() )
59 {
60 return $arch->alt_compile_flags( check_sdl_dir() );
61}
62 else
63 {
64 #ask to download
65 croak 'SDL not installed';
66 }
67}
68
691;