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