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