- deal with freetype-config --cflags returning the directories
authorTony Cook <tony@develop=help.com>
Fri, 13 Jan 2006 06:00:32 +0000 (06:00 +0000)
committerTony Cook <tony@develop=help.com>
Fri, 13 Jan 2006 06:00:32 +0000 (06:00 +0000)
  in the wrong order (Freetype 2.1.4 and earlier)
  Thanks to David Wheeler for his help in tracking this down.

Changes
Makefile.PL

diff --git a/Changes b/Changes
index 72f86625c172092ed6cb2830e1bb661da829d52b..c1cf07320a037e64d885883dddeafe62a4c824c1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1297,6 +1297,9 @@ Revision history for Perl extension Imager.
 - document Imager::Filter::Mandelbrot
 - convert dynfilt/flines.c to Imager::Filter::Flines
 - minor changes for older perl/ExtUtils::MM
+- deal with freetype-config --cflags returning the directories
+  in the wrong order (Freetype 2.1.4 and earlier)
+  Thanks to David Wheeler for his help in tracking this down.
 
 =================================================================
 
index e2b62372f74a006cd9d57020d18e96a68db83852..7e01cccb29a201119a57cc5a11f45ad1f5b956fc 100644 (file)
@@ -597,11 +597,30 @@ sub freetype2_probe {
   my $cflags = `freetype-config --cflags`
     and !$? or return;
   chomp $cflags;
-  
-  $frm->{cflags} = $cflags;
+
   my $lflags = `freetype-config --libs`
     and !$? or return;
   chomp $lflags;
+
+  # before 2.1.5 freetype-config --cflags could output
+  # the -I options in the wrong order, causing a conflict with
+  # freetype1.x installed with the same --prefix
+  #
+  # can happen iff:
+  #  - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags
+  #    in that order
+  #  - freetype 1.x headers are in prefix/include/freetype
+  my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags;
+  if (@incdirs == 2 
+      && $incdirs[1] eq "$incdirs[0]/freetype2"
+      && -e "$incdirs[0]/freetype/freetype.h"
+      && -e "$incdirs[0]/freetype/fterrid.h") {
+    print "** freetype-config provided -I options out of order, correcting\n"
+      if $VERBOSE;
+    $cflags = join(' ', grep(!/-I/, split ' ', $cflags),
+                  map "-I$_", reverse @incdirs);
+  }
+  $frm->{cflags} = $cflags;
   $frm->{libfiles} = $lflags;
 
   printf "%10s: configured via freetype-config\n", $frmkey;