Added update_rects
[sdlgit/SDL_perl.git] / Build.PL
CommitLineData
85fcc9ee 1#! perl -w
8fde61e3 2#
85fcc9ee 3# Copyright (C) 2003 chromatic
4# Copyright (C) 2004 David J. Goehrig
5# Copyright (C) 2009 Kartik Thakore
8fde61e3 6
7use strict;
084b921f 8use warnings;
9use Carp;
8fde61e3 10use lib 'make/lib';
11
0cdd4aa7 12use Data::Dumper;
8fde61e3 13use SDL::Build;
9632eafc 14use SDL::Utility;
8fde61e3 15use YAML;
85fcc9ee 16use YAML::Node;
8fde61e3 17
2a668066 18print STDERR <<BROKENWIN if ($^O =~ /MSWin.*|cygwin/ );
6fc151b2 19*************************** !!!WARNING!!! *****************************
20Windows support is currently experimental - you can continue, but
21you've been warned! If you are interested in helping please contact us
22at sdl-devel\@perl.org, or join us on #sdl in irc.perl.org
23***********************************************************************
2a668066 24BROKENWIN
49ee715f 25
9632eafc 26my $sdl_compile_flags = SDL::Utility->sdl_c_flags();
27my $sdl_link_flags = SDL::Utility->sdl_libs();
8fde61e3 28# subsystem to build
29# file
30# location of source file => location of build file to get name right
31# libraries
32# name of shared library (soname)
33# preprocessor definition
34# name of header file
35my %subsystems =
36(
37 SDL => {
38 file => {
39 from => 'src/SDL.xs',
2a668066 40 to => 'lib/SDL_perl.xs',
8fde61e3 41 },
85fcc9ee 42 libraries => [qw( SDL SDL_image SDL_mixer SDL_net SDL_ttf SDL_gfx
43 png jpeg smpeg )],
8fde61e3 44 },
95f5be30 45 Video => {
46 file => {
47 from => 'src/Core/Video.xs',
48 to => 'lib/SDL/Video.xs',
49 },
50 libraries => [qw( SDL )],
51 },
e4ab5b2e 52 Rect => {
53 file => {
f9be87f4 54 from => 'src/Core/objects/Rect.xs',
e4ab5b2e 55 to => 'lib/SDL/Rect.xs',
56 },
9346cc6b 57 libraries => [qw( SDL )],
e4ab5b2e 58 },
3e3f41ee 59 Color => {
60 file => {
f9be87f4 61 from => 'src/Core/objects/Color.xs',
3e3f41ee 62 to => 'lib/SDL/Color.xs',
63 },
64 libraries => [qw( SDL )],
65 },
88a46efc 66 Surface => {
67 file => {
f32a5342 68 from => 'src/Core/objects/Surface.xs',
88a46efc 69 to => 'lib/SDL/Surface.xs',
70 },
9346cc6b 71 libraries => [qw( SDL )],
72 },
73 Overlay => {
74 file => {
75 from => 'src/Core/objects/Overlay.xs',
76 to => 'lib/SDL/Overlay.xs',
77 },
78 libraries => [qw( SDL )],
88a46efc 79 },
50d9130a 80 PixelFormat => {
81 file => {
82 from => 'src/Core/objects/PixelFormat.xs',
83 to => 'lib/SDL/PixelFormat.xs',
84 },
9346cc6b 85 libraries => [qw( SDL )],
50d9130a 86 },
f1ad86be 87 VideoInfo => {
88 file => {
89 from => 'src/Core/objects/VideoInfo.xs',
90 to => 'lib/SDL/VideoInfo.xs',
91 },
92 libraries => [qw( SDL )],
93 },
94
b41abbd6 95 TTF_Font => {
96 file => {
97 from => 'src/TTF/objects/TTF_Font.xs',
98 to => 'lib/SDL/TTF_Font.xs',
99 },
100 libraries => [qw( SDL SDL_ttf )],
101 },
8fde61e3 102 OpenGL => {
103 file => {
104 from => 'src/OpenGL.xs',
2a668066 105 to => 'lib/SDL/OpenGL.xs',
8fde61e3 106 },
107 libraries => [qw( SDL GL GLU )],
108 },
109 SFont => {
110 file => {
111 from => 'src/SFont.xs',
2a668066 112 to => 'lib/SDL/SFont.xs',
8fde61e3 113 },
9346cc6b 114 libraries => [qw( SDL SDL_ttf )],
8fde61e3 115 },
116);
117
118my %libraries = (
119 SDL => {
120 define => 'HAVE_SDL',
121 header => 'SDL.h',
122 },
123 SDL_image => {
124 define => 'HAVE_SDL_IMAGE',
125 header => 'SDL_image.h'
126 },
127 SDL_mixer => {
128 define => 'HAVE_SDL_MIXER',
129 header => 'SDL_mixer.h'
130 },
131 SDL_net => {
132 define => 'HAVE_SDL_NET',
133 header => 'SDL_net.h'
134 },
135 SDL_ttf => {
136 define => 'HAVE_SDL_TTF',
137 header => 'SDL_ttf.h'
138 },
139 SDL_gfx => {
140 define => 'HAVE_SDL_GFX',
141 header => 'SDL_gfxPrimitives.h'
142 },
143 png => {
144 define => 'HAVE_PNG',
145 header => 'png.h',
146 },
147 jpeg => {
148 define => 'HAVE_JPEG',
149 header => 'jpeglib.h',
150 },
151 smpeg => {
152 define => 'HAVE_SMPEG',
153 header => 'smpeg.h',
154 },
155 GL => {
156 define => 'HAVE_GL',
157 header => 'gl.h'
158 },
159 GLU => {
160 define => 'HAVE_GLU',
161 header => 'glu.h'
162 },
163);
164
165# need the platform-specific module to find include paths correctly
166# see build/lib/SDL/Build/*pm
167my $arch = SDL::Build->get_arch( $^O );
168
169# see which subsystems can be built -- do we have headers for them?
170my $build_systems = $arch->find_subsystems( \%subsystems, \%libraries );
171
172# now write SDL::Config
173$arch->write_sdl_config( $build_systems );
174
175# and fetch all of the information needed to compile
85fcc9ee 176my $defines = $arch->build_defines( \%libraries, $build_systems );
177my $includes = $arch->build_includes( \%libraries, $build_systems );
178my $links = $arch->build_links( \%libraries, $build_systems );
8fde61e3 179
180# mangle the compilable files into a format Module::Build can understand
181my %xs = map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} }
85fcc9ee 182 keys %subsystems;
8fde61e3 183my $build = SDL::Build->new(
85fcc9ee 184 module_name => 'SDL',
8fde61e3 185 dist_name => 'SDL_Perl',
186 license => 'lgpl',
187 dist_version_from => 'lib/SDL.pm',
c4191b5a 188 configure_requires =>
8fde61e3 189 {
c4191b5a 190 'YAML' => '0.68',
191 'ExtUtils::CBuilder' => '0.260301',
72a86b34 192 'Alien::SDL' => '0.7.1',
c4191b5a 193 },
194 build_requires =>
195 {
8fde61e3 196 'Test::Simple' => '0.47',
630ffc1b 197
bf87e76a 198 },
8fde61e3 199 build_recommends =>
200 {
eb33e5ff 201 'Pod::ToDemo' => '0.20'
8fde61e3 202 },
85fcc9ee 203 c_source => 'src',
8fde61e3 204 xs_files => \%xs,
fc3f64f4 205 meta_add =>
206 {
57450fae 207 no_index => { file => [ <make/lib/SDL/*.pm>, <make/lib/SDL/Build/*.pm>, <make/lib/ExtUtils/CBuilder/*>, <make/lib/ExtUtils/*>, <make/lib/ExtUtils/CBuilder/Platform/Windows.pm> ] },
fc3f64f4 208 },
c4191b5a 209 dist_author => 'David J. Goehrig <DGOEHRIG@cpan.org>, Kartik Thakore <KTHAKORE@cpan.org>',
8fde61e3 210);
211
f4666242 212if($arch eq 'Darwin')
213{
214 $build->{c_source} = $arch->build_c_source( \%libraries, $build_systems );
215 $build->{c_sources} = $arch->build_c_sources( \%libraries, $build_systems );
216 $build->{install_base} = $arch->build_install_base( \%libraries, $build_systems );
217
218}
eb33e5ff 219
85fcc9ee 220# and here's where the real (and ugly) magic works... see SDL::Build
8fde61e3 221$build->set_flags(
222 \%subsystems,
223 $build_systems,
224 $defines,
225 $includes,
226 $links,
227 $sdl_compile_flags,
228 $sdl_link_flags,
229);
8fde61e3 230# now we're ready to go!
231$build->create_build_script();