Windows super hack
[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
0cdd4aa7 12use Data::Dumper;
8fde61e3 13use SDL::Build;
9632eafc 14use SDL::Utility;
8fde61e3 15use YAML;
85fcc9ee 16use YAML::Node;
8fde61e3 17
9632eafc 18my $sdl_compile_flags = SDL::Utility->sdl_c_flags();
19my $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
27my %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
53my %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
102my $arch = SDL::Build->get_arch( $^O );
103
104# see which subsystems can be built -- do we have headers for them?
105my $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 111my $defines = $arch->build_defines( \%libraries, $build_systems );
112my $includes = $arch->build_includes( \%libraries, $build_systems );
113my $links = $arch->build_links( \%libraries, $build_systems );
8fde61e3 114
115# mangle the compilable files into a format Module::Build can understand
116my %xs = map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} }
85fcc9ee 117 keys %subsystems;
8fde61e3 118my $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',
3e4c401d 127 'YAML' => '0.68'
8fde61e3 128 },
129 build_recommends =>
130 {
131 'Pod::ToDemo' => '0.20',
132 },
85fcc9ee 133 c_source => 'src',
8fde61e3 134 xs_files => \%xs,
135 dist_author => 'David J. Goehrig <DGOEHRIG@cpan.org>',
136);
137
85fcc9ee 138# and here's where the real (and ugly) magic works... see SDL::Build
8fde61e3 139$build->set_flags(
140 \%subsystems,
141 $build_systems,
142 $defines,
143 $includes,
144 $links,
145 $sdl_compile_flags,
146 $sdl_link_flags,
147);
8fde61e3 148# now we're ready to go!
149$build->create_build_script();