Alien-SDL

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

      print "directory '$ENV{SDL_INST_DIR}' does not exist";
    }
  }
  print "no\n";

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

  if( $build->can_build_binaries_from_sources || scalar(@candidates) ) {
    for(qw(pthread SDL
           z jpeg tiff png SDL_image
           ogg vorbis vorbisfile SDL_mixer
           freetype SDL_ttf
           SDL_gfx
           pangoft2 pango gobject gmodule glib fontconfig expat SDL_Pango)) {
      $have_libs{$_} = check_prereqs_libs($_);
    }
  }

  $perl_libs{pthread} = check_perl_buildlibs('pthread') if $have_libs{pthread} && $^O eq 'openbsd';

  # prebuilt binaries (windows only)
  push @candidates, @{$rv} if $rv = check_prebuilt_binaries($build->os_type);

  if($build->can_build_binaries_from_sources) {
    for my $p ( @$source_packs ) {
      $rv = { title => $p->{title}, members => [], buildtype => 'build_from_sources' };
      for my $m (@{ $p->{members} }) {
        next if $m->{pack} !~ /^SDL/ && $have_libs{ $m->{pack} }[0];
        my $good = 1;
        $good   &= $have_libs{$_} && $have_libs{$_}[0] ? 1 : 0 for @{ $m->{prereqs}->{libs} };
        if( $good ) {
          $have_libs{ $m->{pack} }[0] ||= 1;
          push @{ $rv->{members} }, $m;
          $rv->{title} .= "$m->{pack}(v$m->{version}) ";
        }
      }
      push @candidates, $rv if scalar( @{ $rv->{members} } );
    }
  };

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

  #### 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->{buildtype} eq 'build_from_sources';

    if( $c->{buildtype} eq 'use_config_script' ) {
      $c->{title} .= "\n    ";
      for(qw(SDL SDL_image SDL_mixer SDL_ttf SDL_gfx SDL_Pango)) {
        $c->{title} .= "$_(v$have_libs{$_}->[0]) " if $have_libs{$_}[0];
      }
    }

    $prompt_string .= "[" . $i++ . "] " . $c->{title} . "\n";
  }

  # select option '1' for travis
  if ( defined $travis and $travis == 1 ) {
    $ans = 1;
  }

# or prompt user for build option
  else {
    $prompt_string .= "\nWhat way do you wanna go?";
    $ans = $build->prompt( $prompt_string, $recommended_candidate );
  }

  if($ans > 0 && $ans < scalar(@candidates)) {
    $choice = $candidates[$ans - 1];
  }

  $| = 0;
} # 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->notes('env_include', $ENV{INCLUDE}) if $ENV{INCLUDE};
  $build->notes('env_lib',     $ENV{LIB})     if $ENV{LIB};
  $build->notes('have_libs',   \%have_libs);
  $build->notes('perl_libs',   \%perl_libs);
  $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
}



( run in 1.265 second using v1.01-cache-2.11-cpan-796a6f069b2 )