]> git.imager.perl.org - imager.git/commitdiff
parse defines from the options returned by pkg-config --cflags
authorTony Cook <tony@develop=help.com>
Mon, 6 Dec 2010 08:18:23 +0000 (08:18 +0000)
committerTony Cook <tony@develop=help.com>
Mon, 6 Dec 2010 08:18:23 +0000 (08:18 +0000)
https://rt.cpan.org/Ticket/Display.html?id=63223

Changes
lib/Imager/Probe.pm

diff --git a/Changes b/Changes
index b155d02d08e8a55ce59291b4490f7fcaf936c3ad..77f81d3f4c244737b82bb9f494aadeea9d7ff98f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -25,6 +25,10 @@ Bug fixes:
    crash preventing loading of later fonts.
    https://rt.cpan.org/Ticket/Display.html?id=62855
 
+ - parse defines from the options returned by pkg-config --cflags
+   https://rt.cpan.org/Ticket/Display.html?id=63223
+   
+
 Imager 0.78 - 4 Oct 2010
 ===========
 
index fe160f9e6f26f6970f14975f11c86098d55d547a..5dffc67116fee95b21b486ed1aa644f7ad3aef35 100644 (file)
@@ -26,7 +26,7 @@ sub probe {
   ALTCHECK:
     my $index = 1;
     for my $alt (@{$req->{alternatives}}) {
-      $req->{altname} ||= "alt $index";
+      $req->{altname} = $alt->{altname} || "alt $index";
       $req->{verbose}
        and print "$req->{name}: Trying alternative $index\n";
       my %work = %$req;
@@ -110,6 +110,9 @@ sub _probe_pkg {
       my $lflags = `pkg-config $pkg --libs`
        and !$? or return;
 
+      my $defines = '';
+      $cflags =~ s/(-D\S+)/$defines .= " $1"; ''/ge;
+
       chomp $cflags;
       chomp $lflags;
       print "$req->{name}: Found via pkg-config $pkg\n";
@@ -117,6 +120,7 @@ sub _probe_pkg {
        {
         INC => $cflags,
         LIBS => $lflags,
+        DEFINES => $defines,
        };
     }
   }
@@ -169,7 +173,7 @@ sub _probe_check {
   }
 
   my $alt = "";
-  if ($req->{alternatives}) {
+  if ($req->{altname}) {
     $alt = " $req->{altname}:";
   }
   print "$req->{name}:$alt includes ", $found_incpath ? "" : "not ",
@@ -186,7 +190,7 @@ sub _probe_check {
     push @libs, "-l$libbase";
   }
   else {
-    die "$req->{name}: inccheck but no libbase or libopts";
+    die "$req->{altname}: inccheck but no libbase or libopts";
   }
 
   return
@@ -217,6 +221,7 @@ sub _probe_fake {
       {
        INC => "",
        LIBS => $lopts,
+       DEFINES => "",
       };
   }
   else {