File: Build.PL

package info (click to toggle)
libalien-sdl-perl 1.430-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,404 kB
  • sloc: perl: 1,470; makefile: 4
file content (153 lines) | stat: -rw-r--r-- 5,056 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
use strict;
use warnings;

use lib "inc";
use File::Spec::Functions qw(catdir catfile);
use My::Utility qw(check_config_script check_prebuilt_binaries check_src_build);

#### we need the platform-specific module
my %platforms =(
       # Unix = default, thus not listing all UNIX like systems
       MSWin32 => 'Windows',
);
my $package = 'My::Builder::' . ($platforms{$^O} || 'Unix');
print "Gonna use '$package' class ...\n";
eval "require $package" or die "Require '$package' failed: $@\n";

my $sdl_config;

#### Stadard Module::Builder stuff
my $build = $package->new(
  module_name          => 'Alien::SDL',
  all_from             => 'lib/Alien/SDL.pm',
  dist_abstract        => 'Get, Build and Use SDL libraries',
  dist_author          => 'Kartik Thakore <KTHAKORE@cpan.org>',
  license              => 'perl',
  requires             => {
    'File::Spec'       => '0',
    'File::Temp'       => '0',
    'File::ShareDir'   => '0',
    'File::Which'      => '0',
    'ExtUtils::CBuilder' => '0',
    'Capture::Tiny'    => '0',
  },
  build_requires       => {  #need to have for running: ./Build (install|test)
    'File::Spec'       => '0',
    'File::Temp'       => '0',
    'File::ShareDir'   => '0',
    'ExtUtils::CBuilder' => '0',
    'File::Path'       => '2.08',
    'File::Fetch'      => '0.24',
    'File::Find'       => '0',
    'File::Which'      => '0',
    'Digest::SHA'      => '0',
    'Archive::Extract' => '0',
    'Archive::Tar'     => '0',
    'Archive::Zip'     => '0',
    'Module::Build'    => '0.36',
    'Text::Patch'      => '1.4',
  },
  configure_requires   => {  #need to have for running: perl Build.PL
    'File::Spec'       => '0',
    'File::Path'       => '2.08',
    'File::Fetch'      => '0.24',
    'File::Find'       => '0',
    'File::Which'      => '0',
    'Digest::SHA'      => '0',
    'Archive::Extract' => '0',
    'Module::Build'    => '0.36',
    'Text::Patch'      => '1.4',
    'File::ShareDir'   => '0',
    'Capture::Tiny'    => '0',
  },
  meta_merge => {
    resources  => {
      bugtracker => 'http://sdlperl.ath.cx/projects/SDLPerl/query?component=Alien%3A%3ASDL&status=!closed',
      repository => 'http://github.com/PerlGameDev/Alien-SDL'
    }
  },
  get_options => { 'with-sdl-config' => { qw(type :s  store) => \$sdl_config } },
  dynamic_config => 1,
  create_readme => 1,
  share_dir => 'sharedir',
  # sharedir is used for storing compiled/prebuilt binaries of SDL lib + related libraries
  # avoid using 'share' name as M::B doe not handle well paths like /xx/yy/share/zz/ww/share/xx
);

my $choice;

if (defined $sdl_config) {  
  # handle --with-sdl-config (without params)
  $sdl_config = 'sdl-config' if $sdl_config eq ''; 
  # Don't prompt; just use specified location:
  $choice = check_config_script($sdl_config)
      or warn "###ERROR### Unable to use config script $sdl_config\n";
}
else {
  # Search for possible methods, then prompt:
  print "\nWelcome to Alien::SDL module installation";
  print "\n-----------------------------------------\n\n";

  #### check what options we have for our platform
  my $rv; my @candidates = ();

  if(defined($ENV{SDL_INST_DIR})) {
    print "Gonna use SDL_INST_DIR environment variable...\n";
    print "(SDL_INST_DIR=$ENV{SDL_INST_DIR})\n";
    if (-d $ENV{SDL_INST_DIR}) {
      my @sdlinst = File::Spec->splitdir($ENV{SDL_INST_DIR});
      if($rv=check_config_script(File::Spec->catdir(@sdlinst, 'bin', 'sdl-config'))) {
        push @candidates, $rv;
      }
      elsif($rv=check_config_script(File::Spec->catdir(@sdlinst, 'sdl-config'))) {
        push @candidates, $rv;
      }
    }
    else {
      warn "###WARN### Non-existing directory '$ENV{SDL_INST_DIR}' - skipping";
    }
  }

  if($rv=check_config_script("sdl-config")) {
    push @candidates, $rv;
  };

  if($rv=check_prebuilt_binaries($build->os_type)) {
    push @candidates, @{$rv};
  };

  if($build->can_build_binaries_from_sources() && ($rv=check_src_build($build->os_type))) {
    push @candidates, @{$rv};
  };

  push @candidates, { title => 'Quit installation' };

  #### ask user what way to go
  my $i                     = 1;
  my $prompt_string         = "\nYou have the following options:\n";
  my $recommended_candidate = 1;
  foreach my $c (@candidates) {
    $recommended_candidate = $i if $c->{title} =~ /RECOMMENDED/;
    $prompt_string        .= "[" . $i++ . "] " . $c->{title} . "\n"
  }
  $prompt_string .= "\nWhat way do you wanna go?";
  my $ans = $build->prompt($prompt_string, $recommended_candidate);

  if(($ans>0) && ($ans<scalar(@candidates))) {
    $choice = $candidates[$ans-1];
  }
} # end else search and prompt for build method

#### store build params into 'notes'
if($choice) {
  print "Using \l$choice->{title}\n";
  $build->notes('build_params', $choice);
  $build->create_build_script();

  #### clean build_done stamp; force rebuild when running 'Build'
  $build->clean_build_done_marker;
}
else {
  $build->notes('build_params', undef); # just to be sure
  exit(0); # we want no reports from CPAN Testers in this case
}