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 | |
31817c45 |
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/ ); |
49ee715f |
19 | |
9632eafc |
20 | my $sdl_compile_flags = SDL::Utility->sdl_c_flags(); |
21 | my $sdl_link_flags = SDL::Utility->sdl_libs(); |
8fde61e3 |
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', |
85fcc9ee |
34 | to => './SDL_perl.xs', |
8fde61e3 |
35 | }, |
85fcc9ee |
36 | libraries => [qw( SDL SDL_image SDL_mixer SDL_net SDL_ttf SDL_gfx |
37 | png jpeg smpeg )], |
8fde61e3 |
38 | }, |
39 | OpenGL => { |
40 | file => { |
41 | from => 'src/OpenGL.xs', |
85fcc9ee |
42 | to => 'SDL/OpenGL.xs', |
8fde61e3 |
43 | }, |
44 | libraries => [qw( SDL GL GLU )], |
45 | }, |
46 | SFont => { |
47 | file => { |
48 | from => 'src/SFont.xs', |
85fcc9ee |
49 | to => 'SDL/SFont.xs', |
8fde61e3 |
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 |
85fcc9ee |
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 ); |
8fde61e3 |
116 | |
117 | # mangle the compilable files into a format Module::Build can understand |
118 | my %xs = map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} } |
85fcc9ee |
119 | keys %subsystems; |
8fde61e3 |
120 | my $build = SDL::Build->new( |
85fcc9ee |
121 | module_name => 'SDL', |
8fde61e3 |
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', |
3e4c401d |
129 | 'YAML' => '0.68' |
8fde61e3 |
130 | }, |
131 | build_recommends => |
132 | { |
133 | 'Pod::ToDemo' => '0.20', |
134 | }, |
85fcc9ee |
135 | c_source => 'src', |
8fde61e3 |
136 | xs_files => \%xs, |
fc3f64f4 |
137 | meta_add => |
138 | { |
139 | no_index => { file => [ <make/lib/SDL/*.pm>, <make/lib/SDL/Build/*.pm> ] }, |
140 | }, |
8fde61e3 |
141 | dist_author => 'David J. Goehrig <DGOEHRIG@cpan.org>', |
142 | ); |
143 | |
85fcc9ee |
144 | # and here's where the real (and ugly) magic works... see SDL::Build |
8fde61e3 |
145 | $build->set_flags( |
146 | \%subsystems, |
147 | $build_systems, |
148 | $defines, |
149 | $includes, |
150 | $links, |
151 | $sdl_compile_flags, |
152 | $sdl_link_flags, |
153 | ); |
8fde61e3 |
154 | # now we're ready to go! |
155 | $build->create_build_script(); |