use Data::Dumper;
use SDL::Build;
+use SDL::Utility;
use YAML;
use YAML::Node;
-use inc::Utility qw(sdl_libs sdl_c_flags);
-my $sdl_compile_flags = sdl_c_flags();
-my $sdl_link_flags = sdl_libs();
+my $sdl_compile_flags = SDL::Utility->sdl_c_flags();
+my $sdl_link_flags = SDL::Utility->sdl_libs();
# subsystem to build
# file
# location of source file => location of build file to get name right
+++ /dev/null
-package inc::Utility;
-use strict;
-use warnings;
-use Carp;
-
-BEGIN{
- require Exporter;
- our @ISA = qw(Exporter);
- our @EXPORT_OK = qw(sdl_con_found sdl_libs sdl_c_flags);
-}
-
-#checks to see if sdl-config is availabe
-#
-sub sdl_con_found
-{
- `sdl-config --libs`;
- return 0 if ($? >> 8);
- return 1;
-}
-
-sub sdl_libs
-{
- if(sdl_con_found)
- {
- local $_ = `sdl-config --libs`;
- return chomp($_);
- }
- else
- {
- return undef;
- }
-}
-
-sub sdl_c_flags
-{
- if(sdl_con_found)
- {
- local $_ = `sdl-config --cflags`;
- return chomp($_);
- }
- else
- {
- return undef;
- }
-}
-
-1;
print $file $text;
}
+
+
# Subclass Darwin to build Objective-C addons
sub filter_support {
}
}
+# get link flags with a given a sdl_dir
+sub alt_link_flags
+{
+ my($self) = @_;
+ my $sdl_dir = shift;
+
+ return '-L"'.$sdl_dir.'\lib"';
+}
+
+# get compile flags with a given a sdl_dir
+sub alt_compile_flags
+{
+ my($self) = @_;
+ my $sdl_dir = shift;
+
+ return '-L"'.$sdl_dir.'\include\SDL"';
+}
+
# Override to create a MacOS Bundle
sub ACTION_bundle
{
use File::Spec::Functions;
sub fetch_includes
-{
- croak "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE};
+{
+ warn "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE}
+ and
return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} );
+ return '-I.';
}
sub find_header
$self->SUPER::link_c( @_ );
}
+sub sdl_libs
+{
+ my $self = shift;
+ my $sdl_inst_dir = shift;
+
+
+}
+
+sub alt_link_flags
+{
+ my $self = shift;
+ my $sdl_dir = shift;
+
+ return $self->SUPER::alt_link_flags($sdl_dir).' -lmingw32 -mwindows -lSDLmain -lSDL.dll';
+}
+
+sub alt_compile_flags
+{
+ my $self = shift;
+ my $sdl_dir = shift;
+
+ return $self->SUPER::alt_compile_flages($sdl_dir).' -D_GNU_SOURCE=1 -Dmain=SDL_main';
+}
+
1;
--- /dev/null
+package SDL::Utility;
+use strict;
+use warnings;
+use Carp;
+
+
+BEGIN{
+ require Exporter;
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(sdl_con_found sdl_libs sdl_c_flags);
+}
+ my $arch = SDL::Build->get_arch( $^O );
+
+use lib '../';
+use SDL::Build;
+
+#checks to see if sdl-config is availabe
+#
+sub sdl_con_found
+{
+ `sdl-config --libs`;
+ return 0 if ($? >> 8);
+ return 1;
+}
+
+#This should check if the folder actually has the SDL files
+sub check_sdl_dir
+{
+ return 0 unless $ENV{SDL_INST_DIR} and return $ENV{SDL_INST_DIR};
+}
+
+sub sdl_libs
+{
+ if(sdl_con_found)
+ {
+ local $_ = `sdl-config --libs`;
+ return chomp($_);
+ }
+ elsif( check_sdl_dir() )
+ {
+ return $arch->alt_link_flags( check_sdl_dir() ) ;
+ }
+ else
+ {
+ #ask to download
+ croak 'SDL not installed';
+ return 0;
+ }
+}
+
+sub sdl_c_flags
+{
+ if(sdl_con_found)
+ {
+ local $_ = `sdl-config --cflags`;
+ return chomp($_);
+ }
+ elsif ( check_sdl_dir() )
+ {
+ return $arch->alt_compile_flags( check_sdl_dir() );
+}
+ else
+ {
+ #ask to download
+ croak 'SDL not installed';
+ }
+}
+
+1;