Clean up files that could mess up merge
[sdlgit/SDL_perl.git] / make / lib / SDL / Build / MSWin32.pm
CommitLineData
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
31package SDL::Build::MSWin32;
32
33use strict;
34
35use base 'SDL::Build';
36use File::Spec::Functions;
37
38sub fetch_includes
39{
40 die "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE};
41
42 return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} );
43}
44
45sub find_header
46{
47 for my $key (qw( LIBS PATH ))
48 {
49 die "Environment variable $key is empty\n" unless $ENV{$key};
50 }
51
52 my ( $self, $header, $includes ) = @_;
53 ( my $dll = $header ) =~ s/\.h/\.dll/;
54
55 my $include_dir;
56
57 for my $inc_dir ( keys %$includes )
58 {
59 next unless -e catfile( $inc_dir, $header );
60 $include_dir = $inc_dir;
61 }
62
63 return unless $include_dir;
64
65 for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) }
66 qw( LIB LIBS PATH ) )
67 {
68 return ( $include_dir, $header ) if -e catfile( $lib_path, $dll );
69 }
70}
71
72sub link_flags
73{
74 return 'SDL.lib';
75}
76
77sub compile_flags
78{
79 return;
80}
81
82sub subsystems
83{
84 my $self = shift;
85 my $subsystems = $self->SUPER::subsystems();
86 my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems';
87
88 $subsystems->{OpenGL}{libraries} = $self->$gl_ss_method();
89 return $subsystems;
90}
91
92sub libraries
93{
94 my $self = shift;
95 my $libraries = $self->SUPER::libraries();
96 my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries';
97
98 $libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method();
99 return $libraries;
100}
101
102sub gl_vendor
103{
104 my ( $self, $vendor ) = @_;
105
106 return 'ms_gl' unless defined $vendor;
107
108 return 'mesa_gl' if $vendor eq 'MESA';
109 return 'ms_gl' if $vendor eq 'MS';
110
111 die "Unrecognized GL vendor '$vendor'\n";
112}
113
114sub ms_gl_subsystems
115{
116 return [qw( OpenGL GLU )];
117}
118
119sub mesa_gl_subsystems
120{
121 return [qw( mesagl mesaglu osmesa )];
122}
123
124sub ms_gl_libraries
125{
126 define => 'OPENGL_VENDOR_MS';
127}
128
129sub mesa_gl_libraries
130{
131 define => 'OPENGL_VENDOR_MESA';
132}
133
134sub link_c
135{
136 my $self = shift;
137 my ( $blib, $rib ) = @_;
138
139 # until ExtUtils::ParseXS is patched, avoid warnings from cl.exe
140 $_[-1] =~ s{\\}{/}g;
141
142 $rib =~ s{^src[\\/]}{};
143 $rib =~ s{[\\/]}{::}g;
144
145 local $self->{properties}{module_name} = $rib;
146 $self->SUPER::link_c( @_ );
147}
148
1491;