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 => { |
47 | from => 'src/Rect.xs', |
48 | to => 'lib/SDL/Rect.xs', |
49 | }, |
50 | libraries => [qw( SDL )], |
51 | }, |
52 | |
8fde61e3 |
53 | OpenGL => { |
54 | file => { |
55 | from => 'src/OpenGL.xs', |
2a668066 |
56 | to => 'lib/SDL/OpenGL.xs', |
8fde61e3 |
57 | }, |
58 | libraries => [qw( SDL GL GLU )], |
59 | }, |
60 | SFont => { |
61 | file => { |
62 | from => 'src/SFont.xs', |
2a668066 |
63 | to => 'lib/SDL/SFont.xs', |
8fde61e3 |
64 | }, |
65 | libraries => [qw( SDL SDL_image )], |
66 | }, |
67 | ); |
68 | |
69 | my %libraries = ( |
70 | SDL => { |
71 | define => 'HAVE_SDL', |
72 | header => 'SDL.h', |
73 | }, |
74 | SDL_image => { |
75 | define => 'HAVE_SDL_IMAGE', |
76 | header => 'SDL_image.h' |
77 | }, |
78 | SDL_mixer => { |
79 | define => 'HAVE_SDL_MIXER', |
80 | header => 'SDL_mixer.h' |
81 | }, |
82 | SDL_net => { |
83 | define => 'HAVE_SDL_NET', |
84 | header => 'SDL_net.h' |
85 | }, |
86 | SDL_ttf => { |
87 | define => 'HAVE_SDL_TTF', |
88 | header => 'SDL_ttf.h' |
89 | }, |
90 | SDL_gfx => { |
91 | define => 'HAVE_SDL_GFX', |
92 | header => 'SDL_gfxPrimitives.h' |
93 | }, |
94 | png => { |
95 | define => 'HAVE_PNG', |
96 | header => 'png.h', |
97 | }, |
98 | jpeg => { |
99 | define => 'HAVE_JPEG', |
100 | header => 'jpeglib.h', |
101 | }, |
102 | smpeg => { |
103 | define => 'HAVE_SMPEG', |
104 | header => 'smpeg.h', |
105 | }, |
106 | GL => { |
107 | define => 'HAVE_GL', |
108 | header => 'gl.h' |
109 | }, |
110 | GLU => { |
111 | define => 'HAVE_GLU', |
112 | header => 'glu.h' |
113 | }, |
114 | ); |
115 | |
116 | # need the platform-specific module to find include paths correctly |
117 | # see build/lib/SDL/Build/*pm |
118 | my $arch = SDL::Build->get_arch( $^O ); |
119 | |
120 | # see which subsystems can be built -- do we have headers for them? |
121 | my $build_systems = $arch->find_subsystems( \%subsystems, \%libraries ); |
122 | |
123 | # now write SDL::Config |
124 | $arch->write_sdl_config( $build_systems ); |
125 | |
126 | # and fetch all of the information needed to compile |
85fcc9ee |
127 | my $defines = $arch->build_defines( \%libraries, $build_systems ); |
128 | my $includes = $arch->build_includes( \%libraries, $build_systems ); |
129 | my $links = $arch->build_links( \%libraries, $build_systems ); |
8fde61e3 |
130 | |
131 | # mangle the compilable files into a format Module::Build can understand |
132 | my %xs = map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} } |
85fcc9ee |
133 | keys %subsystems; |
8fde61e3 |
134 | my $build = SDL::Build->new( |
85fcc9ee |
135 | module_name => 'SDL', |
8fde61e3 |
136 | dist_name => 'SDL_Perl', |
137 | license => 'lgpl', |
138 | dist_version_from => 'lib/SDL.pm', |
c4191b5a |
139 | configure_requires => |
8fde61e3 |
140 | { |
c4191b5a |
141 | 'YAML' => '0.68', |
142 | 'ExtUtils::CBuilder' => '0.260301', |
72a86b34 |
143 | 'Alien::SDL' => '0.7.1', |
c4191b5a |
144 | }, |
145 | build_requires => |
146 | { |
8fde61e3 |
147 | 'Test::Simple' => '0.47', |
630ffc1b |
148 | |
bf87e76a |
149 | }, |
8fde61e3 |
150 | build_recommends => |
151 | { |
eb33e5ff |
152 | 'Pod::ToDemo' => '0.20' |
8fde61e3 |
153 | }, |
85fcc9ee |
154 | c_source => 'src', |
8fde61e3 |
155 | xs_files => \%xs, |
fc3f64f4 |
156 | meta_add => |
157 | { |
57450fae |
158 | 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 |
159 | }, |
c4191b5a |
160 | dist_author => 'David J. Goehrig <DGOEHRIG@cpan.org>, Kartik Thakore <KTHAKORE@cpan.org>', |
8fde61e3 |
161 | ); |
162 | |
f4666242 |
163 | if($arch eq 'Darwin') |
164 | { |
165 | $build->{c_source} = $arch->build_c_source( \%libraries, $build_systems ); |
166 | $build->{c_sources} = $arch->build_c_sources( \%libraries, $build_systems ); |
167 | $build->{install_base} = $arch->build_install_base( \%libraries, $build_systems ); |
168 | |
169 | } |
eb33e5ff |
170 | |
85fcc9ee |
171 | # and here's where the real (and ugly) magic works... see SDL::Build |
8fde61e3 |
172 | $build->set_flags( |
173 | \%subsystems, |
174 | $build_systems, |
175 | $defines, |
176 | $includes, |
177 | $links, |
178 | $sdl_compile_flags, |
179 | $sdl_link_flags, |
180 | ); |
8fde61e3 |
181 | # now we're ready to go! |
182 | $build->create_build_script(); |