5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
40 my $sdl_compile_flags = `sdl-config --cflags`;
41 my $sdl_link_flags = `sdl-config --libs`;
45 croak "SDL doesn't appear to be installed.\n" .
46 "Please check that sdl-config is in your path and try again.\n";
49 chomp( $sdl_compile_flags );
50 chomp( $sdl_link_flags );
54 # location of source file => location of build file to get name right
56 # name of shared library (soname)
57 # preprocessor definition
64 to => 'src/SDL_perl.xs',
66 libraries => [qw( SDL SDL_image SDL_mixer SDL_sound SDL_net SDL_ttf
67 SDL_gfx SDL_svg png jpeg smpeg )],
71 from => 'src/OpenGL.xs',
72 to => 'src/SDL/OpenGL.xs',
74 libraries => [qw( SDL GL GLU )],
78 from => 'src/SFont.xs',
79 to => 'src/SDL/SFont.xs',
81 libraries => [qw( SDL SDL_image )],
91 define => 'HAVE_SDL_IMAGE',
92 header => 'SDL_image.h'
95 define => 'HAVE_SDL_MIXER',
96 header => 'SDL_mixer.h'
99 define => 'HAVE_SDL_SOUND',
100 header => 'SDL_sound.h'
103 define => 'HAVE_SDL_NET',
104 header => 'SDL_net.h'
107 define => 'HAVE_SDL_TTF',
108 header => 'SDL_ttf.h'
111 define => 'HAVE_SDL_GFX',
112 header => 'SDL_gfxPrimitives.h'
115 define => 'HAVE_SDL_SVG',
116 header => 'SDL_svg.h'
119 define => 'HAVE_PNG',
123 define => 'HAVE_JPEG',
124 header => 'jpeglib.h',
127 define => 'HAVE_SMPEG',
135 define => 'HAVE_GLU',
140 # need the platform-specific module to find include paths correctly
141 # see build/lib/SDL/Build/*pm
142 my $arch = SDL::Build->get_arch( $^O );
144 print "[Build.PL] arch $arch\n";
146 # see which subsystems can be built -- do we have headers for them?
147 my $build_systems = $arch->find_subsystems( \%subsystems, \%libraries );
149 # now write SDL::Config
150 $arch->write_sdl_config( $build_systems );
152 # and fetch all of the information needed to compile
153 my $defines = $arch->build_defines( \%libraries, $build_systems );
154 my $includes = $arch->build_includes( \%libraries, $build_systems );
155 my $links = $arch->build_links( \%libraries, $build_systems );
156 my $c_sources = $arch->build_c_sources( \%libraries, $build_systems );
157 my $c_source = $arch->build_c_source( \%libraries, $build_systems );
158 my $install_base = $arch->build_install_base( \%libraries, $build_systems );
160 # mangle the compilable files into a format Module::Build can understand
161 my %xs = map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} }
164 my $build = SDL::Build->new(
165 dist_name => 'SDL_Perl',
167 dist_version_from => 'lib/SDL.pm',
170 'Test::Simple' => '0.47',
171 'Module::Build' => '0.22',
175 'Pod::ToDemo' => '0.20',
177 c_source => $c_source,
178 c_sources => $c_sources,
180 dist_author => 'David J. Goehrig <DGOEHRIG@cpan.org>',
181 install_base => $install_base
184 # and here's where the real (and ugly) magic works... see SDL::Build
195 # now we're ready to go!
196 $build->create_build_script();