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