Alien-spatialite

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

        $make_cmd =~ s/type/cat/;
        $make_cmd =~ s/"/'/g;
        $make_inst_cmd =~ s/%%/%/;
        $make_inst_cmd =~ s/type/cat/;
        $make_inst_cmd =~ s/"/'/g;
    }
    #  clean up the build dir on cpan testers etc
    plugin 'Cleanse::BuildDir';
  }

  meta->around_hook( build => \&set_compiler_flags );
  meta->around_hook(
    build => sub {
      my ($orig, $build, @args) = @_;
      $build->log("Setting CCACHE_BASEDIR to " . getcwd());
      local $ENV{CCACHE_BASEDIR} = getcwd();
      $orig->($build, @args);
    }
  );

  meta->before_hook( build => \&update_configure_freebsd );

  build [
    "%{configure} $with_local $with_cpp11 $build_static $extra_build_args",
    \&pause,
    $make_cmd,
    \&patch_rpaths,
    \&rename_la_files,
    $make_inst_cmd,
    #@make_clean
  ];

};


sub update_configure_freebsd {
  my ($build) = @_;

  return if not $^O =~ /bsd/;

  $build->log ('Updating configure for FreeBSD');

  use File::Find::Rule;
  my @configures
    = File::Find::Rule->file()
                        ->name( 'configure' )
                        ->in( '.' );
  
  foreach my $fname (@configures) {
    $build->log ($fname);
    my $permissions = (stat ($fname))[2];
    open my $fh, $fname or die $!;
    my $text = do {local $/ = undef; <$fh>};
    $fh->close;
    $text =~ s/(freebsd[12])\*/$1.*/gms;
    $text =~ s/(freebsd\[123?\])\*/$1.*/gms;
    rename $fname, "$fname.bak";
    open my $ofh, '>', $fname or die $!;
    print {$ofh} $text;
    $ofh->close;
    chmod $permissions, $fname;
  }
  
  return;
}

sub rename_la_files {
    #  need to return if not share
    return if !$on_windows;
    
    use File::Find::Rule;
    my @la_files
      = File::Find::Rule->file()
                        ->name( '*.la' )
                        ->in( '.' );
    foreach my $file (@la_files) {
        Alien::Build->log("Renaming $file so it will not interfere with gdal compilation");
        rename $file, $file . '.bak';
    }

}

#  should be a gather hook working on the stage dir
sub patch_rpaths {
  my ($build) = @_;
  
  #  only run on unices - incomplete check but
  #  I don't think aliens work on VMS or zOS
  return if ($on_windows or $^O =~ /darwin/i);

  my $h = get_alien_state_hash();
  my $install_path = $h->{install}{prefix};
  return if !defined $install_path;

  my @alien_rpaths;
  for my $alien (@alien_deps) {
    next if not $alien->install_type('share');
    push @alien_rpaths, $alien->dist_dir . '/lib';
  }
  if (!@alien_rpaths) {
    $build->log('No shared alien deps found, not updating rpaths');
    return;
  }

  my $origin_string = $^O =~ /darwin/ ? '@loader_path' : '${ORIGIN}';
  my $alien_rpath_text
    = join ':', (
       (map {$origin_string . '/../' . path ($_)->relative($install_path)->stringify} @alien_rpaths),
       @alien_rpaths
      );

  $build->log ("Prepending rpaths with $alien_rpath_text");
  
  use File::Find::Rule;
  my (@so_files)
    = grep {not -l $_}
      File::Find::Rule
              ->file()
              ->name( qr/^(lib|mod_)spatialite.so.?/ )
              ->in( getcwd() );
  



( run in 0.664 second using v1.01-cache-2.11-cpan-bbe5e583499 )