Commit | Line | Data |
7b6a53a1 |
1 | #!/usr/bin/env perl |
2 | # |
3 | # MSWin32.pm |
4 | # |
5 | # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org> |
6 | # |
7 | # ------------------------------------------------------------------------------ |
8 | # |
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. |
13 | # |
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. |
18 | # |
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 |
22 | # |
23 | # ------------------------------------------------------------------------------ |
24 | # |
25 | # Please feel free to send questions, suggestions or improvements to: |
26 | # |
27 | # David J. Goehrig |
28 | # dgoehrig@cpan.org |
29 | # |
30 | |
8fde61e3 |
31 | package SDL::Build::MSWin32; |
32 | |
33 | use strict; |
084b921f |
34 | use warnings; |
35 | usr Carp; |
8fde61e3 |
36 | use base 'SDL::Build'; |
37 | use File::Spec::Functions; |
38 | |
39 | sub fetch_includes |
40 | { |
084b921f |
41 | croak "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE}; |
8fde61e3 |
42 | |
43 | return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} ); |
44 | } |
45 | |
46 | sub find_header |
47 | { |
48 | for my $key (qw( LIBS PATH )) |
49 | { |
084b921f |
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}; |
8fde61e3 |
52 | } |
53 | |
54 | my ( $self, $header, $includes ) = @_; |
55 | ( my $dll = $header ) =~ s/\.h/\.dll/; |
56 | |
57 | my $include_dir; |
58 | |
59 | for my $inc_dir ( keys %$includes ) |
60 | { |
61 | next unless -e catfile( $inc_dir, $header ); |
62 | $include_dir = $inc_dir; |
63 | } |
64 | |
65 | return unless $include_dir; |
66 | |
67 | for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) } |
68 | qw( LIB LIBS PATH ) ) |
69 | { |
70 | return ( $include_dir, $header ) if -e catfile( $lib_path, $dll ); |
71 | } |
72 | } |
73 | |
74 | sub link_flags |
75 | { |
76 | return 'SDL.lib'; |
77 | } |
78 | |
79 | sub compile_flags |
80 | { |
81 | return; |
82 | } |
83 | |
84 | sub subsystems |
85 | { |
86 | my $self = shift; |
87 | my $subsystems = $self->SUPER::subsystems(); |
88 | my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems'; |
89 | |
90 | $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method(); |
91 | return $subsystems; |
92 | } |
93 | |
94 | sub libraries |
95 | { |
96 | my $self = shift; |
97 | my $libraries = $self->SUPER::libraries(); |
98 | my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries'; |
99 | |
100 | $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method(); |
101 | return $libraries; |
102 | } |
103 | |
104 | sub gl_vendor |
105 | { |
106 | my ( $self, $vendor ) = @_; |
107 | |
108 | return 'ms_gl' unless defined $vendor; |
109 | |
110 | return 'mesa_gl' if $vendor eq 'MESA'; |
111 | return 'ms_gl' if $vendor eq 'MS'; |
112 | |
084b921f |
113 | croak "Unrecognized GL vendor '$vendor'\n"; |
8fde61e3 |
114 | } |
115 | |
116 | sub ms_gl_subsystems |
117 | { |
118 | return [qw( OpenGL GLU )]; |
119 | } |
120 | |
121 | sub mesa_gl_subsystems |
122 | { |
123 | return [qw( mesagl mesaglu osmesa )]; |
124 | } |
125 | |
126 | sub ms_gl_libraries |
127 | { |
128 | define => 'OPENGL_VENDOR_MS'; |
129 | } |
130 | |
131 | sub mesa_gl_libraries |
132 | { |
133 | define => 'OPENGL_VENDOR_MESA'; |
134 | } |
135 | |
136 | sub link_c |
137 | { |
138 | my $self = shift; |
139 | my ( $blib, $rib ) = @_; |
140 | |
141 | # until ExtUtils::ParseXS is patched, avoid warnings from cl.exe |
142 | $_[-1] =~ s{\\}{/}g; |
143 | |
144 | $rib =~ s{^src[\\/]}{}; |
145 | $rib =~ s{[\\/]}{::}g; |
146 | |
147 | local $self->{properties}{module_name} = $rib; |
148 | $self->SUPER::link_c( @_ ); |
149 | } |
150 | |
151 | 1; |