Alien-wxWidgets

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

BEGIN { our $NO_INIT = 1 }

use strict;
use lib "./lib", "./inc";
use My::Build;
use Config;

our( $TYPE, $URL, $FORCE_GTX );

my %VERSIONS =

  ( '2.8.12'        => 'patches/data-2.8.12',
    '2.8.11'        => 'patches/data-2.8.11',
    '2.8.10'        => 'patches/data-2.8.10',
    '2.9.0'         => 'patches/data-2.9.0',
    '2.9.1'         => 'patches/data-2.9.1',
    '2.9.2'         => 'patches/data-2.9.2',
    '2.9.3'         => 'patches/data-2.9.3',
    '2.9.4'	        => 'patches/data-2.9.4',
    '3.0.0'         => 'patches/data-3.0.0',
    '3.0.1'         => 'patches/data-3.0.1',
    '3.0.2'         => 'patches/data-3.0.2',
    );

my ($DEFAULT_VERSION, $DEFAULT_ARCHIVE_TYPE) = _get_default_wxwidgets_version_and_type();

if( $^O eq 'cygwin' ) {
    print <<EOT;
==========================================================
There is no support to build Alien::wxWidgets (and wxPerl)
on Cygwin.
==========================================================
EOT
    exit 1;
}

# new_from_context is broken: it does not restore
# @INC set in Build.PL before trying to load a base class not
# defined using ->subclass...
my $class = Module::Build->subclass
  ( class            => 'My::Build::new_from_context_is_broken',
    code             => <<'EOC' );
use lib qw(lib inc);
@ISA = qw(My::Build Module::Build);
require My::Build;
EOC
my $build = $class->new
  ( module_name     => 'Alien::wxWidgets',
    license         => 'perl',
    author          => 'Mattia Barbon <mbarbon@cpan.org>',
    requires        => { perl                             => '5.006',
                         'Module::Pluggable'              => '2.6',
                        },
    build_requires  => { 'Module::Build'                  => '0.28',
                         'ExtUtils::CBuilder'             => '0.24',
                         'File::Spec'                     => '1.50',
                         'LWP::Protocol::https'           => '0',
                         },
    configure_requires => { 'Module::Build'               => '0.28',
                            },
    get_options     => { 'wxWidgets-debug'           => { type => '!' },
                         'wxWidgets-unicode'         => { type => '!' },
                         'wxWidgets-mslu'            => { type => '!' },
                         'wxWidgets-static'          => { type => '!' },
                         'wxWidgets-monolithic'      => { type => '!' },
                         'wxWidgets-universal'       => { type => '!' },
                         'wxWidgets-build'           => { type => '!' },
                         'wxWidgets-portable'        => { type => '!',
                                                        default => $^O eq 'MSWin32' },
                         'wxWidgets-build-opengl'    => { type => '!' },
                         'wxWidgets-source'          => { type => '=s' },
                         'wxWidgets-version'         => { type => '=s' },
                         'wxWidgets-extraflags'      => { type => '=s' },
                         'wxWidgets-userpatch'       => { type => '=s' },
                         'wxWidgets-graphicscontext' => { type => '!', default => 1 },
                         },
    
    create_makefile_pl => 'passthrough',
    meta_merge =>
      { resources       =>
          { 'license'       => [ 'http://dev.perl.org/licenses/' ],
            'homepage'      => 'http://www.wxperl.it/',
            'bugtracker'    => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=Alien-wxWidgets',
            'repository'    => 'http://svn.code.sf.net/p/wxperl/code/Alien-wxWidgets',
            'MailingList'   => 'http://lists.perl.org/list/wxperl-users.html',
            },
        },
  );

my $accept_defaults = $ENV{PERL5_CPANPLUS_IS_RUNNING}
                   || $ENV{CPAN_SHELL_LEVEL}; 
my $build_wx_dflt = 'yes';
my $build_wx_opengl_dflt = 'yes';
my $build_prompt = 'Do you want to fetch and build wxWidgets from sources?';
my $have_alien_configuration = 0;

# try to detect if wxWidgets has been installed using Alien::wxWidgets and if
# it is the latest version; the rule is:
#
# if there is any any wxWidgets installation registered with Alien::wxWidgets
# it will only get upgraded if it was compiled using Alien::wxWidgets itself and
# it is older than $DEFAULT_VERSION

my $ok = eval {
    require Alien::wxWidgets;
    require File::Basename;
    require File::Spec;
    require Cwd;

    $DEFAULT_VERSION =~ m/^(\d+)\.(\d+)\.(\d+)$/ or die "Wrong default version";
    my $install_version = $1 + $2 / 1000 + $3 / 1000000;
    my @configs = Alien::wxWidgets->get_configurations;

    $build_wx_dflt = 'no' if @configs;
    $have_alien_configuration = @configs;

    foreach my $config ( @configs ) {
        last if $config->{version} >= $install_version;

        # installed version is older than $DEFAULT_VERSION, check if it
        # has been installed using Alien::wxWidgets



( run in 0.375 second using v1.01-cache-2.11-cpan-119454b85a5 )