Commit | Line | Data |
bfd90409 |
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 | |
31 | package SDL::Build::MSWin32; |
32 | |
33 | use strict; |
084b921f |
34 | use warnings; |
35 | usr Carp; |
bfd90409 |
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}; |
bfd90409 |
42 | |
43 | return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} ); |
44 | } |
45 | |
46 | sub find_header |
47 | { |
48 | for my $key (qw( LIBS PATH )) |
49 | { |
cc6d0c7c |
50 | #this needs to be carp because some users will have SDL libs in same folder |
084b921f |
51 | carp "Environment variable $key is empty\n" unless $ENV{$key}; |
52 | carp "This will probably fail the compile \nSet $key manually or try building anyway\n" unless $ENV{$key}; |
bfd90409 |
53 | } |
54 | |
55 | my ( $self, $header, $includes ) = @_; |
56 | ( my $dll = $header ) =~ s/\.h/\.dll/; |
57 | |
58 | my $include_dir; |
59 | |
60 | for my $inc_dir ( keys %$includes ) |
61 | { |
62 | next unless -e catfile( $inc_dir, $header ); |
63 | $include_dir = $inc_dir; |
64 | } |
65 | |
66 | return unless $include_dir; |
67 | |
68 | for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) } |
69 | qw( LIB LIBS PATH ) ) |
70 | { |
71 | return ( $include_dir, $header ) if -e catfile( $lib_path, $dll ); |
72 | } |
73 | } |
74 | |
75 | sub link_flags |
76 | { |
77 | return 'SDL.lib'; |
78 | } |
79 | |
80 | sub compile_flags |
81 | { |
82 | return; |
83 | } |
84 | |
85 | sub subsystems |
86 | { |
87 | my $self = shift; |
88 | my $subsystems = $self->SUPER::subsystems(); |
89 | my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems'; |
90 | |
91 | $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method(); |
92 | return $subsystems; |
93 | } |
94 | |
95 | sub libraries |
96 | { |
97 | my $self = shift; |
98 | my $libraries = $self->SUPER::libraries(); |
99 | my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries'; |
100 | |
101 | $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method(); |
102 | return $libraries; |
103 | } |
104 | |
105 | sub gl_vendor |
106 | { |
107 | my ( $self, $vendor ) = @_; |
108 | |
109 | return 'ms_gl' unless defined $vendor; |
bfd90409 |
110 | return 'mesa_gl' if $vendor eq 'MESA'; |
111 | return 'ms_gl' if $vendor eq 'MS'; |
084b921f |
112 | croak "Unrecognized GL vendor '$vendor'\n"; |
2c748062 |
113 | |
bfd90409 |
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; |