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:
39 my $sdl_compile_flags = `sdl-config --cflags`;
40 my $sdl_link_flags = `sdl-config --libs`;
44 die "SDL doesn't appear to be installed.\n" .
45 "Please check that sdl-config is in your path and try again.\n";
48 chomp( $sdl_compile_flags );
49 chomp( $sdl_link_flags );
53 # location of source file => location of build file to get name right
55 # name of shared library (soname)
56 # preprocessor definition
63 to => 'src/SDL_perl.xs',
65 libraries => [qw( SDL SDL_image SDL_mixer SDL_sound SDL_net SDL_ttf
66 SDL_gfx SDL_svg png jpeg smpeg )],
70 from => 'src/OpenGL.xs',
71 to => 'src/SDL/OpenGL.xs',
73 libraries => [qw( SDL GL GLU )],
77 from => 'src/SFont.xs',
78 to => 'src/SDL/SFont.xs',
80 libraries => [qw( SDL SDL_image )],
90 define => 'HAVE_SDL_IMAGE',
91 header => 'SDL_image.h'
94 define => 'HAVE_SDL_MIXER',
95 header => 'SDL_mixer.h'
98 define => 'HAVE_SDL_SOUND',
99 header => 'SDL_sound.h'
102 define => 'HAVE_SDL_NET',
103 header => 'SDL_net.h'
106 define => 'HAVE_SDL_TTF',
107 header => 'SDL_ttf.h'
110 define => 'HAVE_SDL_GFX',
111 header => 'SDL_gfxPrimitives.h'
114 define => 'HAVE_SDL_SVG',
115 header => 'SDL_svg.h'
118 define => 'HAVE_PNG',
122 define => 'HAVE_JPEG',
123 header => 'jpeglib.h',
126 define => 'HAVE_SMPEG',
134 define => 'HAVE_GLU',
139 # need the platform-specific module to find include paths correctly
140 # see build/lib/SDL/Build/*pm
141 my $arch = SDL::Build->get_arch( $^O );
143 print "[Build.PL] arch $arch\n";
145 # see which subsystems can be built -- do we have headers for them?
146 my $build_systems = $arch->find_subsystems( \%subsystems, \%libraries );
148 # now write SDL::Config
149 $arch->write_sdl_config( $build_systems );
151 # and fetch all of the information needed to compile
152 my $defines = $arch->build_defines( \%libraries, $build_systems );
153 my $includes = $arch->build_includes( \%libraries, $build_systems );
154 my $links = $arch->build_links( \%libraries, $build_systems );
155 my $c_sources = $arch->build_c_sources( \%libraries, $build_systems );
156 my $c_source = $arch->build_c_source( \%libraries, $build_systems );
157 my $install_base = $arch->build_install_base( \%libraries, $build_systems );
159 # mangle the compilable files into a format Module::Build can understand
160 my %xs = map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} }
163 my $build = SDL::Build->new(
164 dist_name => 'SDL_Perl',
166 dist_version_from => 'lib/SDL.pm',
169 'Test::Simple' => '0.47',
170 'Module::Build' => '0.22',
174 'Pod::ToDemo' => '0.20',
176 c_source => $c_source,
177 c_sources => $c_sources,
179 dist_author => 'David J. Goehrig <DGOEHRIG@cpan.org>',
180 install_base => $install_base
183 # and here's where the real (and ugly) magic works... see SDL::Build
194 # now we're ready to go!
195 $build->create_build_script();