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