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