Alien-SDL2

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

  create_readme => 1,
  share_dir => 'sharedir',
);

my $choice;
my %have_libs = ();

if (defined $sdl2_config) {
  # handle --with-sdl2-config (without params)
  $sdl2_config = 'sdl2-config' if $sdl2_config eq '';
  # Don't prompt; just use specified location:
  $choice = check_config_script($sdl2_config)
      or warn "###ERROR### Unable to use config script $sdl2_config\n";
}
else {
  $| = 1;

  if( $My::Utility::cc eq 'cl' && $^O eq 'MSWin32' ) {
    print "checking INCLUDE and LIB... ";
    if( !$ENV{INCLUDE} || !$ENV{LIB} ) {
      my @set = `\@vcvars32 & set`;

Build.PL  view on Meta::CPAN

        }
      }
      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(SDL2 SDL2_image SDL2_mixer SDL2_ttf SDL2_gfx)) {
        $c->{title} .= "$_(v$have_libs{$_}->[0]) " if $have_libs{$_}[0];
      }
    }

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

  # select option '1' for travis
  if ($travis == 1) {
      $ans = 1;
      #set 'travis' var for inc/My/Builder.pm
      $build->notes( 'travis', '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->create_build_script();

README  view on Meta::CPAN

    *   When given "--with-sdl2-config" option use specified sdl2-config
        script to locate SDL2 libs.

         perl Build.PL --with-sdl2-config=/opt/sdl2/bin/sdl2-config

        or using default script name 'sdl2-config' by running:

         perl Build.PL --with-sdl2-config

        IMPORTANT NOTE: Using --with-sdl2-config avoids considering any
        other build methods; no prompt with other available build options.

    *   Locate an already installed SDL2 via 'sdl2-config' script.

    *   Download prebuilt SDL2 binaries (if available for your platform).

    *   Build SDL2 binaries from source codes (if possible on your system).

    Later you can use Alien::SDL2 in your module that needs to link agains
    SDL2 and/or related libraries like this:

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

      $self->set_ld_config($build_out);
    }
    elsif ( $bp->{buildtype} eq 'build_from_sources' ) {

        my $m = '';
        if ( $self->notes('travis') && $self->notes('travis') == 1 ) {
            # always select option '1'
            $m = 1;
        }
        else {
            $m = $self->prompt(
"\nDo you want to see all messages during configure/make (y/n)?",
                'n'
            );
        }

      $self->notes('build_msgs', lc($m) eq 'y' ? 1 : 0);
      # all the following functions die on error, no need to test ret values
      $self->fetch_sources($download);
      $self->extract_sources($download, $patches, $build_src);
      $self->clean_dir($build_out);

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

  my ($version, $prefix, $incdir, $libdir) = find_SDL2_dir(rel2abs($build_out));
  sed_inplace("$prefix/bin/sdl2-config", 's/^prefix=.*/prefix=\''.quotemeta($prefix).'\'/');
}

sub extract_sources {
  my ($self, $download, $patches, $build_src) = @_;
  my $bp = $self->notes('build_params');
  foreach my $pack (@{$bp->{members}}) {
    my $srcdir = catfile($build_src, $pack->{dirname});
    my $unpack = 'y';
    $unpack = $self->prompt("Dir '$srcdir' exists, wanna replace with clean sources?", "y") if (-d $srcdir);
    if (lc($unpack) eq 'y') {
      my $archive = catfile($download, File::Fetch->new(uri => @{$pack->{url}}[0])->file);
      print "Extracting $pack->{pack}...\n";
      my $ae = Archive::Extract->new( archive => $archive );
      die "###ERROR###: cannot extract $pack ", $ae->error unless $ae->extract(to => $build_src);
      $self->apply_patch($srcdir, "$patches/$_") for (@{$pack->{patches}});
    }
  }
  return 1;
}

inc/My/Builder/Unix.pm  view on Meta::CPAN

        # otherwise we get "false cru build/libSDLmain.a build/SDL_dummy_main.o"
        # see http://fixunix.com/ntp/245613-false-cru-libs-libopts-libopts_la-libopts-o.html#post661558
        for (qw[/usr/ccs/bin /usr/xpg4/bin /usr/sfw/bin /usr/xpg6/bin /usr/gnu/bin /opt/gnu/bin /usr/bin]) {
          $extra_PATH .= ":$_" if -d $_;
        }
      }
      $ENV{PATH} = "$prefixdir/bin:$ENV{PATH}$extra_PATH";

      # do './configure ...'
      my $run_configure = 'y';
      $run_configure    = $self->prompt("Run ./configure for '$pack->{pack}' again?", "y") if (-f "config.status");
      if (lc($run_configure) eq 'y') {
        my $cmd = $self->_get_configure_cmd($pack->{pack}, $prefixdir);
        unless($self->run_custom($cmd)) {
          if(-f "config.log" && open(CONFIGLOG, "<config.log")) {
            print "config.log:\n";
            print while <CONFIGLOG>;
            close(CONFIGLOG);
          }
          die "###ERROR### [$?] during ./configure for package '$pack->{pack}'...";
        }

lib/Alien/SDL2.pm  view on Meta::CPAN

=item * When given C<--with-sdl2-config> option use specified sdl2-config
script to locate SDL2 libs.

 perl Build.PL --with-sdl2-config=/opt/sdl2/bin/sdl2-config

or using default script name 'sdl2-config' by running:

 perl Build.PL --with-sdl2-config

B<IMPORTANT NOTE:> Using --with-sdl2-config avoids considering any other
build methods; no prompt with other available build options.

=item * Locate an already installed SDL2 via 'sdl2-config' script.

=item * Download prebuilt SDL2 binaries (if available for your platform).

=item * Build SDL2 binaries from source codes (if possible on your system).

=back

Later you can use Alien::SDL2 in your module that needs to link agains SDL2



( run in 1.685 second using v1.01-cache-2.11-cpan-0b5f733616e )