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};
43 return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} ) if $ENV{INCLUDE};
49 for my $key (qw( LIBS PATH ))
51 #this needs to be carp because some users will have SDL libs in same folder
52 carp "Environment variable $key is empty\n" unless $ENV{$key};
53 carp "This will probably fail the compile \nSet $key manually or try building anyway\n" unless $ENV{$key};
56 my ( $self, $header, $includes ) = @_;
57 ( my $dll = $header ) =~ s/\.h/\.dll/;
61 for my $inc_dir ( keys %$includes )
63 next unless -e catfile( $inc_dir, $header );
64 $include_dir = $inc_dir;
67 return unless $include_dir;
69 for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) }
72 return ( $include_dir, $header ) if -e catfile( $lib_path, $dll );
89 my $subsystems = $self->SUPER::subsystems();
90 my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems';
92 $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method();
99 my $libraries = $self->SUPER::libraries();
100 my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries';
102 $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method();
108 my ( $self, $vendor ) = @_;
110 return 'ms_gl' unless defined $vendor;
111 return 'mesa_gl' if $vendor eq 'MESA';
112 return 'ms_gl' if $vendor eq 'MS';
113 croak "Unrecognized GL vendor '$vendor'\n";
119 return [qw( OpenGL GLU )];
122 sub mesa_gl_subsystems
124 return [qw( mesagl mesaglu osmesa )];
129 define => 'OPENGL_VENDOR_MS';
132 sub mesa_gl_libraries
134 define => 'OPENGL_VENDOR_MESA';
140 my ( $blib, $rib ) = @_;
142 # until ExtUtils::ParseXS is patched, avoid warnings from cl.exe
145 $rib =~ s{^src[\\/]}{};
146 $rib =~ s{[\\/]}{::}g;
148 local $self->{properties}{module_name} = $rib;
149 $self->SUPER::link_c( @_ );
155 my $sdl_inst_dir = shift;
165 return $self->SUPER::alt_link_flags($sdl_dir).' -lmingw32 -mwindows -lSDLmain -lSDL.dll';
168 sub alt_compile_flags
173 return $self->SUPER::alt_compile_flags($sdl_dir).' -D_GNU_SOURCE=1 -Dmain=SDL_main';