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