First commit of SDL_Perl-2.1.3
[sdlgit/SDL_perl.git] / make / lib / SDL / Build / MSWin32.pm
CommitLineData
8fde61e3 1package SDL::Build::MSWin32;
2
3use strict;
4
5use base 'SDL::Build';
6use File::Spec::Functions;
7
8sub fetch_includes
9{
10 die "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE};
11
12 return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} );
13}
14
15sub find_header
16{
17 for my $key (qw( LIBS PATH ))
18 {
19 die "Environment variable $key is empty\n" unless $ENV{$key};
20 }
21
22 my ( $self, $header, $includes ) = @_;
23 ( my $dll = $header ) =~ s/\.h/\.dll/;
24
25 my $include_dir;
26
27 for my $inc_dir ( keys %$includes )
28 {
29 next unless -e catfile( $inc_dir, $header );
30 $include_dir = $inc_dir;
31 }
32
33 return unless $include_dir;
34
35 for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) }
36 qw( LIB LIBS PATH ) )
37 {
38 return ( $include_dir, $header ) if -e catfile( $lib_path, $dll );
39 }
40}
41
42sub link_flags
43{
44 return 'SDL.lib';
45}
46
47sub compile_flags
48{
49 return;
50}
51
52sub subsystems
53{
54 my $self = shift;
55 my $subsystems = $self->SUPER::subsystems();
56 my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems';
57
58 $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method();
59 return $subsystems;
60}
61
62sub libraries
63{
64 my $self = shift;
65 my $libraries = $self->SUPER::libraries();
66 my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries';
67
68 $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method();
69 return $libraries;
70}
71
72sub gl_vendor
73{
74 my ( $self, $vendor ) = @_;
75
76 return 'ms_gl' unless defined $vendor;
77
78 return 'mesa_gl' if $vendor eq 'MESA';
79 return 'ms_gl' if $vendor eq 'MS';
80
81 die "Unrecognized GL vendor '$vendor'\n";
82}
83
84sub ms_gl_subsystems
85{
86 return [qw( OpenGL GLU )];
87}
88
89sub mesa_gl_subsystems
90{
91 return [qw( mesagl mesaglu osmesa )];
92}
93
94sub ms_gl_libraries
95{
96 define => 'OPENGL_VENDOR_MS';
97}
98
99sub mesa_gl_libraries
100{
101 define => 'OPENGL_VENDOR_MESA';
102}
103
104sub link_c
105{
106 my $self = shift;
107 my ( $blib, $rib ) = @_;
108
109 # until ExtUtils::ParseXS is patched, avoid warnings from cl.exe
110 $_[-1] =~ s{\\}{/}g;
111
112 $rib =~ s{^src[\\/]}{};
113 $rib =~ s{[\\/]}{::}g;
114
115 local $self->{properties}{module_name} = $rib;
116 $self->SUPER::link_c( @_ );
117}
118
1191;