Skip to content

Commit 5938187

Browse files
committed
Use pkg-config for FreeType2 detection
1 parent 751dfc7 commit 5938187

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

ext/gd/config.m4

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,29 @@ AC_DEFUN([PHP_GD_XPM],[
184184
AC_DEFUN([PHP_GD_FREETYPE2],[
185185
if test "$PHP_FREETYPE_DIR" != "no"; then
186186
187-
for i in $PHP_FREETYPE_DIR /usr/local /usr; do
188-
if test -f "$i/bin/freetype-config"; then
189-
FREETYPE2_DIR=$i
190-
FREETYPE2_CONFIG="$i/bin/freetype-config"
191-
break
187+
if test -z "$PKG_CONFIG"; then
188+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
189+
fi
190+
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists freetype2 ; then
191+
FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags freetype2`
192+
FREETYPE2_LIBS=`$PKG_CONFIG --libs freetype2`
193+
else
194+
for i in $PHP_FREETYPE_DIR /usr/local /usr; do
195+
if test -f "$i/bin/freetype-config"; then
196+
FREETYPE2_DIR=$i
197+
FREETYPE2_CONFIG="$i/bin/freetype-config"
198+
break
199+
fi
200+
done
201+
202+
if test -z "$FREETYPE2_DIR"; then
203+
AC_MSG_ERROR([freetype-config not found.])
192204
fi
193-
done
194205
195-
if test -z "$FREETYPE2_DIR"; then
196-
AC_MSG_ERROR([freetype-config not found.])
206+
FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
207+
FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
197208
fi
198209
199-
FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
200-
FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
201-
202210
PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
203211
PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
204212
AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])

0 commit comments

Comments
 (0)