5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
31 package SDL::Build::MSWin32;
36 use base 'SDL::Build';
37 use File::Spec::Functions;
42 warn "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE}
44 return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} );
50 for my $key (qw( LIBS PATH ))
52 #this needs to be carp because some users will have SDL libs in same folder
53 carp "Environment variable $key is empty\n" unless $ENV{$key};
54 carp "This will probably fail the compile \nSet $key manually or try building anyway\n" unless $ENV{$key};
57 my ( $self, $header, $includes ) = @_;
58 ( my $dll = $header ) =~ s/\.h/\.dll/;
62 for my $inc_dir ( keys %$includes )
64 next unless -e catfile( $inc_dir, $header );
65 $include_dir = $inc_dir;
68 return unless $include_dir;
70 for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) }
73 return ( $include_dir, $header ) if -e catfile( $lib_path, $dll );
90 my $subsystems = $self->SUPER::subsystems();
91 my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems';
93 $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method();
100 my $libraries = $self->SUPER::libraries();
101 my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries';
103 $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method();
109 my ( $self, $vendor ) = @_;
111 return 'ms_gl' unless defined $vendor;
112 return 'mesa_gl' if $vendor eq 'MESA';
113 return 'ms_gl' if $vendor eq 'MS';
114 croak "Unrecognized GL vendor '$vendor'\n";
120 return [qw( OpenGL GLU )];
123 sub mesa_gl_subsystems
125 return [qw( mesagl mesaglu osmesa )];
130 define => 'OPENGL_VENDOR_MS';
133 sub mesa_gl_libraries
135 define => 'OPENGL_VENDOR_MESA';
141 my ( $blib, $rib ) = @_;
143 # until ExtUtils::ParseXS is patched, avoid warnings from cl.exe
146 $rib =~ s{^src[\\/]}{};
147 $rib =~ s{[\\/]}{::}g;
149 local $self->{properties}{module_name} = $rib;
150 $self->SUPER::link_c( @_ );
156 my $sdl_inst_dir = shift;
166 return $self->SUPER::alt_link_flags($sdl_dir).' -lmingw32 -mwindows -lSDLmain -lSDL.dll';
169 sub alt_compile_flags
174 return $self->SUPER::alt_compile_flages($sdl_dir).' -D_GNU_SOURCE=1 -Dmain=SDL_main';