Add hack for windows building on mingw
[sdlgit/SDL_perl.git] / make / lib / SDL / Build.pm
index 3ffc43c..bcc03a5 100644 (file)
@@ -31,6 +31,8 @@
 package SDL::Build;
 
 use strict;
+use warnings;
+use Carp;
 use base 'Module::Build';
 
 use File::Spec;
@@ -61,7 +63,7 @@ sub get_arch
                'SDL', 'Build', ucfirst( $os ) . '.pm' );
        my $module        = 'SDL::Build::' . ucfirst( $os );
 
-       require $modpath or die "No module for $os platform\n";
+       require $modpath or croak "No module for $os platform\n";
 
        return $module;
 }
@@ -78,7 +80,7 @@ sub find_subsystems
                for my $library (@{ $subsystem->{libraries} })
                {
                        my $lib = $libraries->{$library}
-                               or die "Unknown library '$library' for '$name'\n";
+                               or croak "Unknown library '$library' for '$name'\n";
 
                        my ($inc_dir, $link_dir)   =
                                $self->find_header( $lib->{header}, \%includes_libs );
@@ -156,27 +158,24 @@ sub set_flags
 {
        my ($self, $subsystems, $build, $defines, $includes, $links,
            $sdl_compile, $sdl_link) = @_;
-
        my %file_flags;
-
        while (my ($subsystem, $buildable) = each %$build)
        {
                my $sub_file     = $subsystems->{$subsystem}{file}{to};
                my $sub_includes = join(' ', @{ $includes->{$subsystem} } );
-
                $file_flags{ $sub_file } = 
                {
                        extra_compiler_flags =>
                        [
                                @{ $includes->{$subsystem} },
-                               split(' ',$sdl_compile),
+                               (split(' ',$sdl_compile)),
                                @{ $defines->{$subsystem} },
                                ( defined $Config{usethreads} ? ('-DUSE_THREADS', '-fPIC') : ('-fPIC' )),
                        ],
                        extra_linker_flags => 
                        [
                                @{ $links->{$subsystem}{paths} },
-                               split(' ',$sdl_link),
+                               (split(' ',$sdl_link)),
                                @{ $links->{$subsystem}{libs} },
                        ],
                },
@@ -220,10 +219,12 @@ sub write_sdl_config
 
        $text =~ s/^\t//gm;
 
-       open my $file, '>', $path or die "Cannot write to '$path': $!\n";
+       open my $file, '>', $path or croak "Cannot write to '$path': $!\n";
        print $file $text;
 }
 
+
+
 # Subclass  Darwin to build Objective-C addons
 
 sub filter_support {
@@ -249,10 +250,30 @@ sub process_support_files {
        }
 }
 
+# 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 build_bundle
+sub ACTION_bundle
 {
-       return;
+       my ($self) = @_;
+       $self->depends_on('build');
+       $self->get_arch($^O)->build_bundle();
 }
 
 # Override Install method for darwin
@@ -260,7 +281,6 @@ sub ACTION_install {
   my ($self) = @_;
   require ExtUtils::Install;
   $self->depends_on('build');
-  $self->get_arch($^O)->build_bundle();
   ExtUtils::Install::install($self->install_map, 1, 0, $self->{args}{uninst}||0);
 }