quick opt for FAIL:
[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 croak 'Windows support is currently broken. If you are interested in helping please contact us at sdl-devel\@perl.org.' if ($^O =~ /MSWin*|cygwin/ );
19
20 my $sdl_compile_flags = SDL::Utility->sdl_c_flags();
21 my $sdl_link_flags    = SDL::Utility->sdl_libs();
22 # subsystem to build
23 #       file
24 #               location of source file => location of build file to get name right
25 #       libraries
26 #               name of shared library (soname)
27 #                       preprocessor definition
28 #                       name of header file
29 my %subsystems =
30 (
31         SDL => {
32                 file      => {
33                         from  => 'src/SDL.xs',
34                         to    => './SDL_perl.xs',
35                 },
36                 libraries => [qw( SDL SDL_image SDL_mixer SDL_net SDL_ttf SDL_gfx
37                                   png jpeg smpeg )],
38         },
39         OpenGL => {
40                 file      => {
41                         from => 'src/OpenGL.xs',
42                         to   => 'SDL/OpenGL.xs', 
43                 },
44                 libraries => [qw( SDL GL GLU )],
45         },
46         SFont => {
47                 file    => {
48                         from => 'src/SFont.xs',
49                         to   => 'SDL/SFont.xs',
50                 },
51                 libraries => [qw( SDL SDL_image )],
52         },      
53 );
54
55 my %libraries = (
56         SDL         => {
57                 define => 'HAVE_SDL', 
58                 header => 'SDL.h',
59         },
60         SDL_image   => {
61                 define => 'HAVE_SDL_IMAGE',   
62                 header => 'SDL_image.h'
63         },
64         SDL_mixer   => {
65                 define => 'HAVE_SDL_MIXER',   
66                 header => 'SDL_mixer.h'
67         },
68         SDL_net     => {
69                 define => 'HAVE_SDL_NET',     
70                 header => 'SDL_net.h'
71         },
72         SDL_ttf     => {
73                 define => 'HAVE_SDL_TTF',     
74                 header => 'SDL_ttf.h'
75         },
76         SDL_gfx     => {
77                 define => 'HAVE_SDL_GFX',     
78                 header => 'SDL_gfxPrimitives.h'
79         },
80         png         => {
81                 define    => 'HAVE_PNG',
82                 header    => 'png.h',
83         },
84         jpeg        => {        
85                 define    => 'HAVE_JPEG',
86                 header    => 'jpeglib.h',
87         },
88         smpeg       => {
89                 define    => 'HAVE_SMPEG',
90                 header    => 'smpeg.h',
91         },
92         GL          => {
93                 define => 'HAVE_GL',  
94                 header => 'gl.h'
95         },
96         GLU         => {
97                 define => 'HAVE_GLU', 
98                 header => 'glu.h'
99         },
100 );
101
102 # need the platform-specific module to find include paths correctly
103 # see build/lib/SDL/Build/*pm
104 my $arch          = SDL::Build->get_arch( $^O );
105
106 # see which subsystems can be built -- do we have headers for them?
107 my $build_systems = $arch->find_subsystems( \%subsystems, \%libraries );
108
109 # now write SDL::Config
110 $arch->write_sdl_config( $build_systems );
111
112 # and fetch all of the information needed to compile
113 my $defines       = $arch->build_defines( \%libraries, $build_systems );
114 my $includes      = $arch->build_includes( \%libraries, $build_systems );
115 my $links         = $arch->build_links( \%libraries, $build_systems );
116
117 # mangle the compilable files into a format Module::Build can understand
118 my %xs = map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} }
119              keys %subsystems;
120 my $build   = SDL::Build->new(
121         module_name          => 'SDL',
122         dist_name            => 'SDL_Perl', 
123         license              => 'lgpl',
124         dist_version_from    => 'lib/SDL.pm',
125         build_requires       =>
126         {
127                 'Test::Simple' => '0.47',
128                 'Module::Build' => '0.22',
129                 'YAML'  => '0.68'
130         },
131         build_recommends     =>
132         {
133                 'Pod::ToDemo'  => '0.20',
134         },
135         c_source             => 'src',
136         xs_files             => \%xs,
137         meta_add             =>      
138         {
139                 no_index =>  { file => [ <make/lib/SDL/*.pm>, <make/lib/SDL/Build/*.pm> ] },
140         },
141         dist_author          => 'David J. Goehrig <DGOEHRIG@cpan.org>',
142 );
143
144 # and here's where the real (and ugly) magic works... see SDL::Build
145 $build->set_flags(
146         \%subsystems,
147         $build_systems,
148         $defines,
149         $includes,
150         $links,
151         $sdl_compile_flags,
152         $sdl_link_flags,
153 );
154 # now we're ready to go!
155 $build->create_build_script();