Description: Fix ac_find_xft.m4
 ac_find_xft.m4 fails tests required to enable building with Xft anti-aliased fonts.
 We also need to add -lfontconfig to LIBS to prevent underlinking of libXm.
 .
 This patch fixes these.  Build-depends on libfontconfig1-dev, libfreetype6-dev and
 libxrender-dev can be dropped as they are all dependencies of libxft-dev.
Author: Graham Inggs <graham@nerve.org.za>
Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1591
Last-Update: 2013-03-13
--- a/ac_find_xft.m4
+++ b/ac_find_xft.m4
@@ -54,28 +54,28 @@
 
 case "$freetype_lib" in
 no)
-	freetype_lib=""
+	FREETYPE_LIBS=""
 	;;
 yes)
 	case "$ft_config" in
 	no)
-		freetype_lib=""
+		FREETYPE_LIBS="-lfreetype"
 		;;
 	*)
-		freetype_lib="`$ft_config --libs`"
+		FREETYPE_LIBS="`$ft_config --libs`"
 		;;
 	esac
 	;;
 *)
-	freetype_lib="-L$freetype_lib -lfreetype"
+	FREETYPE_LIBS="-L$freetype_lib -lfreetype"
 	;;
 esac
 
 saved_LIBS="$LIBS"
-LIBS="$LIBS $freetype_lib"
+LIBS="$LIBS $FREETYPE_LIBS"
 saved_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
-AC_CHECK_HEADERS(freetype/freetype.h)
+AC_CHECK_HEADERS(freetype/freetype.h,,,[#include <ft2build.h>])
 
 FINDXFT_HAVE_FREETYPE="no"
 case "$ac_cv_header_freetype_freetype_h" in
@@ -94,6 +94,7 @@
 		FINDXFT_HAVE_FREETYPE="yes"
 		AC_DEFINE(HAVE_FREETYPE, 1, Means we have discovered the FreeType library)
 		AC_SUBST(FREETYPE_CFLAGS)
+		AC_SUBST(FREETYPE_LIBS)
 		;;
 	esac
 	;;
@@ -134,8 +135,19 @@
 FINDXFT_HAVE_XRENDER="no"
 case "$have_x" in
 yes)
-	XRENDER_CFLAGS="-I$x_includes"
-	XRENDER_LIBS="-L$x_libraries -lXft -lXrender"
+	if test x$x_includes = x
+	then
+		XRENDER_CFLAGS=""
+	else
+		XRENDER_CFLAGS="-I$x_includes"
+	fi
+
+	if test x$x_libraries = x
+	then
+		XRENDER_LIBS="-lXft -lXrender"
+	else
+		XRENDER_LIBS="-I$x_libraries -lXft -lXrender"
+	fi
 
 	saved_LIBS="$LIBS"
 	LIBS="$LIBS $XRENDER_LIBS"
@@ -203,12 +215,12 @@
 
 case "$fontconfig_lib" in
 no)
-	fontconfig_lib=""
+	FONTCONFIG_LIBS=""
 	;;
 yes)
 	case "$fc_config" in
 	no)
-		fontconfig_lib=""
+		FONTCONFIG_LIBS="-lfontconfig"
 		;;
 	*)
 		FONTCONFIG_LIBS="`$fc_config --libs`"
