Alien-SDL

 view release on metacpan or  search on metacpan

inc/My/Utility.pm  view on Meta::CPAN

package My::Utility;
use strict;
use warnings;
use base qw(Exporter);

our @EXPORT_OK = qw(check_config_script check_prebuilt_binaries check_prereqs_libs check_prereqs_tools find_SDL_dir find_file check_header
                    sed_inplace get_dlext $inc_lib_candidates $source_packs check_perl_buildlibs);
use Config;
use ExtUtils::CBuilder;
use File::Spec::Functions qw(splitdir catdir splitpath catpath rel2abs);
use File::Find qw(find);
use File::Which;
use File::Copy qw(cp);
use Cwd qw(realpath);

our $cc                 = $Config{cc};
our $inc_lib_candidates = {
  '/usr/local/include'       => '/usr/local/lib',
  '/usr/include'             => '/usr/lib',
  '/usr/X11R6/include'       => '/usr/X11R6/lib',
  '/usr/local/include/smpeg' => '/usr/local/lib',
};
$inc_lib_candidates->{'/usr/pkg/include/smpeg'} = '/usr/local/lib'            if -f '/usr/pkg/include/smpeg/smpeg.h';
$inc_lib_candidates->{'/usr/include/smpeg'}     = '/usr/lib'                  if -f '/usr/include/smpeg/smpeg.h';
$inc_lib_candidates->{'/usr/X11R6/include'}     = '/usr/X11R6/lib'            if -f '/usr/X11R6/include/GL/gl.h';
$inc_lib_candidates->{'/usr/X11R7/include'}     = '/usr/X11R7/lib'            if -f '/usr/X11R7/include/GL/gl.h';
$inc_lib_candidates->{'/usr/X11R7/include'}     = '/usr/X11R7/lib'            if -f '/usr/X11R7/include/freetype2/freetype/freetype.h';
$inc_lib_candidates->{'/usr/X11R7/include'}     = '/usr/X11R7/lib'            if -f '/usr/X11R7/include/fontconfig/fontconfig.h';
$inc_lib_candidates->{'/usr/include/ogg'}       = '/usr/lib/x86_64-linux-gnu' if -f '/usr/lib/x86_64-linux-gnu/libogg.so';
$inc_lib_candidates->{'/usr/include/vorbis'}    = '/usr/lib/x86_64-linux-gnu' if -f '/usr/lib/x86_64-linux-gnu/libvorbis.so';
$inc_lib_candidates->{'/usr/include'}           = '/usr/lib64'                if -e '/usr/lib64' && $Config{'myarchname'} =~ /64/;
$inc_lib_candidates->{$ENV{SDL_INC}}            = $ENV{SDL_LIB}               if exists $ENV{SDL_LIB} && exists $ENV{SDL_INC};

#### packs with prebuilt binaries
# - all regexps has to match: arch_re ~ $Config{archname}, cc_re ~ $Config{cc}, os_re ~ $^O
# - the order matters, we offer binaries to user in the same order (1st = preffered)
my $prebuilt_binaries = [
    {
      title    => "Binaries Win/32bit SDL-1.2.14 (extended, 20100704) RECOMMENDED\n" .
                  "\t(gfx, image, mixer, net, smpeg, ttf, sound, svg, rtf, Pango)",
      url      => [
        'http://strawberryperl.com/package/kmx/sdl/Win32_SDL-1.2.14-extended-bin_20100704.zip',
        'http://froggs.de/libsdl/Win32_SDL-1.2.14-extended-bin_20100704.zip',
      ],
      sha1sum  => '98409ddeb649024a9cc1ab8ccb2ca7e8fe804fd8',
      arch_re  => qr/^MSWin32-x86-multi-thread(-64int)?$/,
      os_re    => qr/^MSWin32$/,
      cc_re    => qr/gcc/,
    },
    {
      title    => "Binaries Win/32bit SDL-1.2.14 (extended, 20111205)\n" .
                  "\t(gfx, image, mixer, net, smpeg, ttf, sound, svg, rtf, Pango)",
      url      => [
        'http://strawberryperl.com/package/kmx/sdl/Win32_SDL-1.2.14-extended-bin_20111205.zip',
        'http://froggs.de/libsdl/Win32_SDL-1.2.14-extended-bin_20111205.zip',
      ],
      sha1sum  => '553b7e21bb650d047ec9f2a5f650c67d76430e61',
      arch_re  => qr/^MSWin32-x86-multi-thread(-64int)?$/,
      os_re    => qr/^MSWin32$/,
      cc_re    => qr/gcc/,
    },
    {
      title    => "Binaries Win/64bit SDL-1.2.14 (extended, 20100824)\n" .
                  "\t(gfx, image, mixer, net, smpeg, ttf, sound, svg, rtf, Pango)\n" .
                  "\tBEWARE: binaries are using old ABI - will fail with the latest gcc\n" .
                  "\tBEWARE: this is intended just for old strawberryperl 5.12.x/64bit",
      url      => [
        'http://strawberryperl.com/package/kmx/sdl/Win64_SDL-1.2.14-extended-bin_20100824.zip',
        'http://froggs.de/libsdl/Win64_SDL-1.2.14-extended-bin_20100824.zip',
      ],
      sha1sum  => 'ccffb7218bcb17544ab00c8a1ae383422fe9586d',
      arch_re  => qr/^MSWin32-x64-multi-thread$/,
      os_re    => qr/^MSWin32$/,
      cc_re    => qr/gcc/,
      gccversion_re => qr/^4\.4\.3$/, #specific to the old gcc compiler used in 64bit strawberryperl 5.12.x
    },
    {
      title    => "Binaries Win/64bit SDL-1.2.14 (extended, 20111205) RECOMMENDED\n" .
                  "\t(gfx, image, mixer, net, smpeg, ttf, sound, svg, rtf, Pango)",
      url      => [
        'http://strawberryperl.com/package/kmx/sdl/Win64_SDL-1.2.14-extended-bin_20111205.zip',
        'http://froggs.de/libsdl/Win64_SDL-1.2.14-extended-bin_20111205.zip',
      ],
      sha1sum  => '35f3b496ca443a9d14eff77e9e26acfa813afafd',
      arch_re  => qr/^MSWin32-x64-multi-thread$/,
      os_re    => qr/^MSWin32$/,
      cc_re    => qr/gcc/,
      gccversion_re => qr/^4\.(4\.[5-9]|[5-9]\.[0-9])$/,
    },
    {
      title    => "Binaries Win/32bit SDL-1.2.15 (20120612)\n" .
                  "\t(gfx, image, mixer, smpeg, ttf)",
      url      => [
        'http://froggs.de/libsdl/Win32_SDL-1.2.15-20120612.zip',
      ],
      sha1sum  => '22c531c1d0cc5a363c05045760870b2f45e9d0da',
      arch_re  => qr/^MSWin32/,
      os_re    => qr/^MSWin32$/,
      cc_re    => qr/cl/,
    },
 ];

#### tarballs with source codes
our $source_packs = [
  {
    title   => "Source code build\n    ",
    members => [
      {
        pack => 'z',
        version => '1.2.5',
        dirname => 'zlib-1.2.5',
        url => [
          'http://froggs.de/libz/zlib-1.2.5.tar.gz',
        ],
        sha1sum  => '8e8b93fa5eb80df1afe5422309dca42964562d7e',
        patches => [
          'zlib-1.2.5-bsd-ldconfig.patch',
        ],
        prereqs => {
          libs => [ ]
        }
      },
      {
        pack => 'jpeg',
        version => '8b',
        dirname => 'jpeg-8b',
        url => [
          'http://www.ijg.org/files/jpegsrc.v8b.tar.gz',
          'http://froggs.de/libjpeg/jpegsrc.v8b.tar.gz',
        ],
        sha1sum  => '15dc1939ea1a5b9d09baea11cceb13ca59e4f9df',
        patches => [
          'jpeg-8a_cygwin.patch',
        ],
        prereqs => {
          libs => [ ]
        }
      },
      {
        pack => 'tiff',
        version => '3.9.1',
        dirname => 'tiff-3.9.1',
        url => [
          'http://froggs.de/libtiff/tiff-3.9.1.tar.gz',
          'ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.9.1.tar.gz',
        ],
        sha1sum  => '675ad1977023a89201b80cd5cd4abadea7ba0897',
        patches => [ ],
        prereqs => {
          libs => [ ]
        }
      },
      {
        pack => 'png',
        version => '1.4.1',
        dirname => 'libpng-1.4.1',
        url => [
          'http://froggs.de/libpng/libpng-1.4.1.tar.gz',
        ],
        sha1sum  => '7a3488f5844068d67074f2507dd8a7ed9c69ff04',
        prereqs => {
          libs => [
            'z',
          ]
        }
      },
      {
        pack => 'freetype',
        version => '2.3.12',
        dirname => 'freetype-2.3.12',
        url => [
          'http://mirror.lihnidos.org/GNU/savannah/freetype/freetype-2.3.12.tar.gz',
          'http://froggs.de/libfreetype/freetype-2.3.12.tar.gz',
        ],
        sha1sum  => '0082ec5e99fec5a1c6d89b321a7e2f201542e4b3',
        prereqs => {
          libs => [ ]
        }
      },
      {
        pack => 'SDL',
        version => '1.2.15',
        dirname => 'SDL-1.2',
        url => [
          'http://froggs.de/libsdl/SDL-1.2-2b923729fd01.tar.gz',
        ],
        sha1sum  => 'ec9841377403e8d1bcfd76626434be64d11f59f0',
        patches => [
          'test1.patch',
          'SDL-1.2-openbsd-rldflags.patch',
          'libsdl-1.2.15-const-xdata32.1.patch',
          'libsdl-1.2.15-const-xdata32.2.patch',
          'libsdl-1.2.15-const-xdata32.3.patch',
          'libsdl-1.2.15-const-xdata32.4.patch',
          'SDL-1.2.15-PIC-in-CFLAGS.patch',
          'SDL-1.2.15-Makefile.in-OBJECTS.patch',
          'SDL-1.2.15-mavericks-cgdirectpallete.patch',
        ],
        prereqs => {
          libs => [
            'pthread',
          ]
        },
      },
      {
        pack => 'SDL_image',
        version => '1.2.11',
        dirname => 'SDL_image-1.2.11',
        url => [
          'http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.11.tar.gz',
          'http://froggs.de/libsdl/SDL_image-1.2.11.tar.gz',
        ],
        sha1sum  => 'dd384ff87848595fcc0691833431ec5029f973c7',
        patches => [
          'SDL_image-1.2.11-CGFloat.patch',
          'SDL_image-1.2.11-libpng-flags.patch',
        ],
        prereqs => {
          libs => [
            'jpeg', 'tiff', 'png',
          ]
        }
      },
      {
        pack => 'ogg',
        version => '1.3.0',
        dirname => 'libogg-1.3.0',
        url => [
          'http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz',
          'http://froggs.de/libsdl/libogg-1.3.0.tar.gz',
        ],
        sha1sum  => 'a900af21b6d7db1c7aa74eb0c39589ed9db991b8',
        patches => [ ],
      },
      {
        pack => 'vorbis',
        version => '1.3.3',
        dirname => 'libvorbis-1.3.3',
        url => [
          'http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz',
          'http://froggs.de/libsdl/libvorbis-1.3.3.tar.gz',
        ],
        sha1sum  => '8dae60349292ed76db0e490dc5ee51088a84518b',
        patches => [
          'libvorbis-1.3.3-configure.patch',
        ],
        prereqs => {
          libs => [ ]
        }
      },
      {
        pack => 'SDL_mixer',
        version => '1.2.12',
        dirname => 'SDL_mixer-1.2.12',
        url => [
          'http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.12.tar.gz',
          'http://froggs.de/libsdl/SDL_mixer-1.2.12.tar.gz',
        ],
        sha1sum  => 'a20fa96470ad9e1052f1957b77ffa68fb090b384',
        patches => [
          'SDL_mixer-1.2.12-native-midi-win32.patch',



( run in 2.111 seconds using v1.01-cache-2.11-cpan-df04353d9ac )