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