Skip to content

Commit

Permalink
fallback to gdlib.pc [RT #114788]
Browse files Browse the repository at this point in the history
Taken from the debian patch, which does not ship gdlib-config
anymore. But as fallback
  • Loading branch information
rurban committed Apr 20, 2017
1 parent e064689 commit 069e6cf
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ WriteMakefile(
'NAME' => 'GD',
'VERSION_FROM' => 'lib/GD.pm',
'PREREQ_PM' => {
'Math::Trig' => 0,
},
'Math::Trig' => 0,
'ExtUtils::PkgConfig' => 0,
},
'PM' => { 'lib/GD.pm' => '$(INST_LIBDIR)/GD.pm',
'lib/GD/Polyline.pm' => '$(INST_LIBDIR)/GD/Polyline.pm',
'lib/GD/Polygon.pm' => '$(INST_LIBDIR)/GD/Polygon.pm',
Expand All @@ -248,8 +249,6 @@ WriteMakefile(
'LIBS' => [join(' ',$ENV{'GD_LIBS'},@LIBPATH,@LIBS)],
'INC' => join(' ',$ENV{'GD_INC'},@INC),



'PL_FILES' => {'bdf_scripts/bdf2gdfont.PLS' => 'bdf_scripts/bdf2gdfont.pl',
'lib/GD/Image.pm.PLS' => 'lib/GD/Image.pm',
},
Expand Down Expand Up @@ -278,36 +277,55 @@ exit 0;

sub try_to_autoconfigure {
my ($options,$lib_gd_path,$INC,$LIBPATH,$LIBS) = @_;
my ($version, $cflags, $ldflags, $libs, $libdir, $features, $includedir);
my $config = `gdlib-config --all`;
return unless $config;
$AUTOCONFIG++;

my ($version) = $config =~ /^GD library\s+(\S+)/m;
warn "Configuring for libgd version $version.\n";

my ($cflags) = $config =~ /^cflags:\s+(.+)/m;
my ($ldflags) = $config =~ /^ldflags:\s+(.+)/m;
my ($libs) = $config =~ /^libs:\s+(.+)/m;
my ($libdir) = $config =~ /^libdir:\s+(.+)/m;
my ($features) = $config =~ /^features:\s+(.+)/m;
my ($includedir) = $config =~ /^includedir:\s+(.+)/m;
unless ($config) {
require ExtUtils::PkgConfig;
my %config = ExtUtils::PkgConfig->find ('gdlib');
return unless %config;
$version = $config{modversion};
warn "Configuring for libgd version $version.\n";
$cflags = $config{cflags};
$libs = $config{libs};
$libdir = ExtUtils::PkgConfig->variable('gdlib', 'libdir');
$features = 'GD_GIF GD_GIFANIM GD_OPENPOLYGON GD_ZLIB GD_PNG GD_FREETYPE GD_FONTCONFIG GD_JPEG GD_XPM GD_TIFF GD_WEBP';
$AUTOCONFIG++;
} else {
$AUTOCONFIG++;

($version) = $config =~ /^GD library\s+(\S+)/m;
warn "Configuring for libgd version $version.\n";

($includedir) = $config =~ /^includedir:\s+(.+)/m;
($cflags) = $config =~ /^cflags:\s+(.+)/m;
($ldflags) = $config =~ /^ldflags:\s+(.+)/m;
($libs) = $config =~ /^libs:\s+(.+)/m;
($libdir) = $config =~ /^libdir:\s+(.+)/m;
($features) = $config =~ /^features:\s+(.+)/m;
($includedir) = $config =~ /^includedir:\s+(.+)/m;
}

@$INC = map {s/^-I// && "-I$_"} split /\s+/,$cflags;
@$LIBPATH = map {s/^-L// && "-L$_"} split /\s+/,$ldflags;
@$LIBS = split /\s+/,$libs;

push @$LIBS,"-lgd";
if ($config) {
@$LIBPATH = map {s/^-L// && "-L$_"} split /\s+/,$ldflags;
push @$LIBS,"-lgd";
($$lib_gd_path = $libdir) =~ s!/[^/]+$!!;
} else {
$$lib_gd_path = $libdir;
}
push @$LIBPATH,"-L$libdir";
($$lib_gd_path = $libdir) =~ s!/[^/]+$!!;
$$options = $features;

my ($minor, $patch) = $version =~ /^2\.(\d+)\.(\d+)$/;
if ((defined($minor) && $minor > 0) or (defined($patch) && $patch >= 33)) {
$$options .= " GD_UNCLOSEDPOLY GD_ANIMGIF GD_FTCIRCLE VERSION_33";
}

my @correct_inc = map {s/^-I// && $_} split /\s+/,$cflags;
check_for_stray_headers($includedir,@correct_inc);
if ($config) {
my @correct_inc = map {s/^-I// && $_} split /\s+/,$cflags;
check_for_stray_headers($includedir,@correct_inc);
}
return 1;
}

Expand Down

0 comments on commit 069e6cf

Please sign in to comment.