···11+From a0955f351c7eb1022da7ae36970ffef3b00c8aff Mon Sep 17 00:00:00 2001
22+From: Adam Harvey <aharvey@php.net>
33+Date: Sat, 7 Dec 2013 19:39:40 -0800
44+Subject: [PATCH] Switch to using freetype-config for freetype detection.
55+66+This fixes GD compilation against libfreetype 2.5.1 and later after they made
77+the rather interesting decision to change their include directory layout in a
88+point release.
99+1010+The original suggestion in the bug was to use pkg-config, but my inclination is
1111+to use freetype-config instead: we should be able to get the same configuration
1212+information without actually needing pkg-config installed, since pkg-config is
1313+by no means guaranteed to exist on many Unices and distros, whereas
1414+freetype-config should always be present if a libfreetype build environment is
1515+installed. Let's try it out and see what happens.
1616+1717+Fixes bug #64405 (Use freetype-config for determining freetype2 dir(s)).
1818+1919+diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
2020+index 0e35ece..732e14c 100644
2121+--- a/ext/gd/config.m4
2222++++ b/ext/gd/config.m4
2323+@@ -193,30 +193,25 @@ AC_DEFUN([PHP_GD_FREETYPE2],[
2424+ if test "$PHP_FREETYPE_DIR" != "no"; then
2525+2626+ for i in $PHP_FREETYPE_DIR /usr/local /usr; do
2727+- if test -f "$i/include/freetype2/freetype/freetype.h"; then
2828++ if test -f "$i/bin/freetype-config"; then
2929+ FREETYPE2_DIR=$i
3030+- FREETYPE2_INC_DIR=$i/include/freetype2
3131++ FREETYPE2_CONFIG="$i/bin/freetype-config"
3232+ break
3333+ fi
3434+ done
3535+3636+ if test -z "$FREETYPE2_DIR"; then
3737+- AC_MSG_ERROR([freetype.h not found.])
3838++ AC_MSG_ERROR([freetype-config not found.])
3939+ fi
4040+4141+- PHP_CHECK_LIBRARY(freetype, FT_New_Face,
4242+- [
4343+- PHP_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE2_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
4444+- PHP_ADD_INCLUDE($FREETYPE2_DIR/include)
4545+- PHP_ADD_INCLUDE($FREETYPE2_INC_DIR)
4646+- AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
4747+- AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
4848+- AC_DEFINE(ENABLE_GD_TTF,1,[ ])
4949+- ],[
5050+- AC_MSG_ERROR([Problem with freetype.(a|so). Please check config.log for more information.])
5151+- ],[
5252+- -L$FREETYPE2_DIR/$PHP_LIBDIR
5353+- ])
5454++ FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
5555++ FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
5656++
5757++ PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
5858++ PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
5959++ AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
6060++ AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
6161++ AC_DEFINE(ENABLE_GD_TTF,1,[ ])
6262+ else
6363+ AC_MSG_RESULT([If configure fails try --with-freetype-dir=<DIR>])
6464+ fi