Description: Use pkg-config to find freetype2
Author: Stephen Kitt <skitt@debian.org>

--- a/configure
+++ b/configure
@@ -201,7 +201,6 @@
 _sparklepath=
 _sdlconfig=sdl2-config
 _libcurlconfig=curl-config
-_freetypeconfig=freetype-config
 _sdlpath="$PATH"
 _freetypepath="$PATH"
 _libcurlpath="$PATH"
@@ -417,40 +416,6 @@
 }
 
 #
-# Determine freetype-config
-#
-find_freetypeconfig() {
-	echo_n "Looking for freetype-config... "
-	freetypeconfigs="$_freetypeconfig"
-	_freetypeconfig=
-
-	IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="$SEPARATOR"
-	for path_dir in $_freetypepath; do
-		#reset separator to parse freetypeconfigs
-		IFS=":"
-		for freetypeconfig in $freetypeconfigs; do
-			if test -f "$path_dir/$freetypeconfig" ; then
-				_freetypeconfig="$path_dir/$freetypeconfig"
-				echo $_freetypeconfig
-				# Save the prefix
-				_freetypepath=$path_dir
-				if test `basename $path_dir` = bin ; then
-					_freetypepath=`dirname $path_dir`
-				fi
-				# break at first freetype-config found in path
-				break 2
-			fi
-		done
-	done
-
-	IFS="$ac_save_ifs"
-
-	if test -z "$_freetypeconfig"; then
-		echo "none found!"
-	fi
-}
-
-#
 # Determine curl-config
 #
 find_libcurlconfig() {
@@ -4602,30 +4567,13 @@
 #
 if test "$_freetype2" != "no"; then
 
-	# Look for the freetype-config script
-	find_freetypeconfig
+	FREETYPE2_LIBS=`pkg-config --libs freetype2`
+	FREETYPE2_CFLAGS=`pkg-config --cflags freetype2`
 
-	if test -z "$_freetypeconfig"; then
+	if test "$_freetype2" = "auto"; then
 		_freetype2=no
-	else
-		# Since 2.3.12, freetype-config prepends $SYSROOT to everything.
-		# This means we can't pass it a --prefix that includes $SYSROOT.
-		freetypeprefix="$_freetypepath"
-		if test -n "$SYSROOT" -a "$SYSROOT" != "/"; then
-			teststring=VeryImplausibleSysrootX1Y2Z3
-			if ( env SYSROOT=/$teststring "$_freetypeconfig" --cflags | grep $teststring 2> /dev/null > /dev/null ); then
-				echo "Adapting FreeType prefix to SYSROOT" >> "$TMPLOG"
-				freetypeprefix="${freetypeprefix##$SYSROOT}"
-			fi
-		fi
-
-		FREETYPE2_LIBS=`$_freetypeconfig --prefix="$freetypeprefix" --libs`
-		FREETYPE2_CFLAGS=`$_freetypeconfig --prefix="$freetypeprefix" --cflags`
-
-		if test "$_freetype2" = "auto"; then
-			_freetype2=no
 
-			cat > $TMPC << EOF
+		cat > $TMPC << EOF
 #include <ft2build.h>
 #include FT_FREETYPE_H
 
@@ -4636,23 +4584,21 @@
 }
 EOF
 
+		cc_check_no_clean $FREETYPE2_CFLAGS $FREETYPE2_LIBS && _freetype2=yes
+		# Modern freetype-config scripts accept --static to get all
+		# required flags for static linking. We abuse this to detect
+		# FreeType2 builds which are static themselves.
+		if test "$_freetype2" != "yes"; then
+			FREETYPE2_LIBS=`pkg-config --static --libs freetype2 2>/dev/null`
 			cc_check_no_clean $FREETYPE2_CFLAGS $FREETYPE2_LIBS && _freetype2=yes
-			# Modern freetype-config scripts accept --static to get all
-			# required flags for static linking. We abuse this to detect
-			# FreeType2 builds which are static themselves.
-			if test "$_freetype2" != "yes"; then
-				FREETYPE2_LIBS=`$_freetypeconfig --prefix="$_freetypepath" --static --libs 2>/dev/null`
-				cc_check_no_clean $FREETYPE2_CFLAGS $FREETYPE2_LIBS && _freetype2=yes
-			fi
-			cc_check_clean
-		fi
-
-		if test "$_freetype2" = "yes"; then
-			append_var LIBS "$FREETYPE2_LIBS"
-			append_var INCLUDES "$FREETYPE2_CFLAGS"
 		fi
+		cc_check_clean
 	fi
 
+	if test "$_freetype2" = "yes"; then
+		append_var LIBS "$FREETYPE2_LIBS"
+		append_var INCLUDES "$FREETYPE2_CFLAGS"
+	fi
 fi
 
 echocheck "FreeType2"
