Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile.PL: let Alien::gdal provide all the GDAL details #77

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 4 additions & 67 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,70 +1,10 @@
use strict;
use warnings;

my $have_alien;
BEGIN {
my $gdal = 'Alien::gdal';
my @argv = ();
for (@ARGV) {
if (/GDAL=(.+)/) {
$gdal = $1;
} else {
push @argv, $_;
}
}
@ARGV = @argv;
eval "use Alien::gdal" if $gdal eq 'Alien::gdal';
if ($gdal ne 'Alien::gdal' or $@) {
if ($gdal eq 'Alien::gdal') {
print "I can't find Alien::gdal.\n";
$gdal = '/usr';
}
print "Trying GDAL from '$gdal'.\n";
$have_alien = 0;
my $version = `$gdal/bin/gdalinfo --version`;
unless ($version) {
print "I can't find gdal in '$gdal', I'm sorry.\n";
exit(1);
}
$version = $1 if $version =~ /(\d+\.\d+\.\d+)/;
my @a = (grep {-l} glob("$gdal/lib/libgdal*"));
my $lib = $a[0];
my $data = "$gdal/share/gdal";
print "I'm creating Geo::GDAL::gdal as a wrapper to $lib, which I believe is GDAL $version.\n";
my $fh = IO::File->new;
$fh->open("lib/Geo/GDAL/gdal.pm","w");
print $fh <<EOF;
package Geo::GDAL::gdal;
use strict;
use warnings;
sub new {
return shift;
}
sub version {
return '$version';
}
sub data_dir {
return ('$data');
}
sub dynamic_libs {
return '$lib';
}
1;
EOF
} else {
eval "use Alien::Base::Wrapper qw(Alien::gdal !export)";
$have_alien = 1;
my $fh = IO::File->new;
$fh->open("lib/Geo/GDAL/gdal.pm","w");
print $fh <<EOF;
package Geo::GDAL::gdal;
use strict;
use warnings;
1;
EOF
}
}
use ExtUtils::MakeMaker;

use ExtUtils::MakeMaker 6.52;


use Config;
my %args = (
AUTHOR => ['Ari Jolma <ari.jolma at gmail.com>'],
Expand Down Expand Up @@ -104,8 +44,5 @@ my %args = (
},
},
);
if ($have_alien) {
%args = (%args, Alien::Base::Wrapper->mm_args);
}

WriteMakefile(%args);
Loading