···1+From a0955f351c7eb1022da7ae36970ffef3b00c8aff Mon Sep 17 00:00:00 2001
2+From: Adam Harvey <aharvey@php.net>
3+Date: Sat, 7 Dec 2013 19:39:40 -0800
4+Subject: [PATCH] Switch to using freetype-config for freetype detection.
5+6+This fixes GD compilation against libfreetype 2.5.1 and later after they made
7+the rather interesting decision to change their include directory layout in a
8+point release.
9+10+The original suggestion in the bug was to use pkg-config, but my inclination is
11+to use freetype-config instead: we should be able to get the same configuration
12+information without actually needing pkg-config installed, since pkg-config is
13+by no means guaranteed to exist on many Unices and distros, whereas
14+freetype-config should always be present if a libfreetype build environment is
15+installed. Let's try it out and see what happens.
16+17+Fixes bug #64405 (Use freetype-config for determining freetype2 dir(s)).
18+19+diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
20+index 0e35ece..732e14c 100644
21+--- a/ext/gd/config.m4
22++++ b/ext/gd/config.m4
23+@@ -193,30 +193,25 @@ AC_DEFUN([PHP_GD_FREETYPE2],[
24+ if test "$PHP_FREETYPE_DIR" != "no"; then
25+26+ for i in $PHP_FREETYPE_DIR /usr/local /usr; do
27+- if test -f "$i/include/freetype2/freetype/freetype.h"; then
28++ if test -f "$i/bin/freetype-config"; then
29+ FREETYPE2_DIR=$i
30+- FREETYPE2_INC_DIR=$i/include/freetype2
31++ FREETYPE2_CONFIG="$i/bin/freetype-config"
32+ break
33+ fi
34+ done
35+36+ if test -z "$FREETYPE2_DIR"; then
37+- AC_MSG_ERROR([freetype.h not found.])
38++ AC_MSG_ERROR([freetype-config not found.])
39+ fi
40+41+- PHP_CHECK_LIBRARY(freetype, FT_New_Face,
42+- [
43+- PHP_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE2_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
44+- PHP_ADD_INCLUDE($FREETYPE2_DIR/include)
45+- PHP_ADD_INCLUDE($FREETYPE2_INC_DIR)
46+- AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
47+- AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
48+- AC_DEFINE(ENABLE_GD_TTF,1,[ ])
49+- ],[
50+- AC_MSG_ERROR([Problem with freetype.(a|so). Please check config.log for more information.])
51+- ],[
52+- -L$FREETYPE2_DIR/$PHP_LIBDIR
53+- ])
54++ FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
55++ FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
56++
57++ PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
58++ PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
59++ AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
60++ AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
61++ AC_DEFINE(ENABLE_GD_TTF,1,[ ])
62+ else
63+ AC_MSG_RESULT([If configure fails try --with-freetype-dir=<DIR>])
64+ fi