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;
41 croak "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE};
43 return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} );
48 for my $key (qw( LIBS PATH ))
50 carp "Environment variable $key is empty\n" unless $ENV{$key};
51 carp "This will probably fail the compile \nSet $key manually or try building anyway\n" unless $ENV{$key};
54 my ( $self, $header, $includes ) = @_;
55 ( my $dll = $header ) =~ s/\.h/\.dll/;
59 for my $inc_dir ( keys %$includes )
61 next unless -e catfile( $inc_dir, $header );
62 $include_dir = $inc_dir;
65 return unless $include_dir;
67 for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) }
70 return ( $include_dir, $header ) if -e catfile( $lib_path, $dll );
87 my $subsystems = $self->SUPER::subsystems();
88 my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems';
90 $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method();
97 my $libraries = $self->SUPER::libraries();
98 my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries';
100 $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method();
106 my ( $self, $vendor ) = @_;
108 return 'ms_gl' unless defined $vendor;
110 return 'mesa_gl' if $vendor eq 'MESA';
111 return 'ms_gl' if $vendor eq 'MS';
113 croak "Unrecognized GL vendor '$vendor'\n";
118 return [qw( OpenGL GLU )];
121 sub mesa_gl_subsystems
123 return [qw( mesagl mesaglu osmesa )];
128 define => 'OPENGL_VENDOR_MS';
131 sub mesa_gl_libraries
133 define => 'OPENGL_VENDOR_MESA';
139 my ( $blib, $rib ) = @_;
141 # until ExtUtils::ParseXS is patched, avoid warnings from cl.exe
144 $rib =~ s{^src[\\/]}{};
145 $rib =~ s{[\\/]}{::}g;
147 local $self->{properties}{module_name} = $rib;
148 $self->SUPER::link_c( @_ );