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