From 669f159665b04a3bf9c2dbbe9db71b59a45e46c2 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 30 Jan 2019 17:58:22 +0100 Subject: [PATCH] Fix for STR#3473 (and its duplicate STR#3507) Recent Linux distribution have replaced the freetype-config command by pkg-config. The fix tries the new procedure with pkg-config and falls back to freetype-config if the new procedure fails. --- configure.ac | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index dd1a1ef36..ff8fcd8b3 100644 --- a/configure.ac +++ b/configure.ac @@ -1032,21 +1032,37 @@ case $host_os_gui in xft_found=no if test x$enable_xft != xno; then - AC_PATH_PROG(FTCONFIG, freetype-config) + # Try pkg-config first (freetype2 deprecated freetype-config from some version on) + AC_PATH_PROG(PKGCONFIG, pkg-config) + FT_FLAGS="" + if test "x$PKGCONFIG" != x; then + FT_FLAGS="`$PKGCONFIG --cflags xft`" + if test "x$FT_FLAGS" = x; then + FT_FLAGS="`$PKGCONFIG --cflags freetype2`" + fi + fi + # if that failed, try freetype-config + if test "x$FT_FLAGS" = x; then + AC_PATH_PROG(FTCONFIG, freetype-config) + if test "x$FTCONFIG" != x; then + FT_FLAGS="`$FTCONFIG --cflags`" + else + # abort if both methods failed + AC_MSG_NOTICE([please install pkg-config or use 'configure --disable-xft'.]) + AC_MSG_ERROR([Aborting.]) + fi + fi + CPPFLAGS="$FT_FLAGS $CPPFLAGS" + CXXFLAGS="$FT_FLAGS $CXXFLAGS" + CFLAGS="$FT_FLAGS $CFLAGS" - if test "x$FTCONFIG" != x; then - CPPFLAGS="`$FTCONFIG --cflags` $CPPFLAGS" - CFLAGS="`$FTCONFIG --cflags` $CFLAGS" - CXXFLAGS="`$FTCONFIG --cflags` $CXXFLAGS" - - AC_CHECK_LIB(fontconfig, FcPatternCreate) - AC_CHECK_HEADER(X11/Xft/Xft.h, + AC_CHECK_LIB(fontconfig, FcPatternCreate) + AC_CHECK_HEADER(X11/Xft/Xft.h, AC_CHECK_LIB(Xft, XftDrawCreate, [AC_DEFINE(USE_XFT) LIBS="-lXft $LIBS" BUILD="XFT" xft_found=yes])) - fi fi dnl Issue a warning message if Xft was not found, abort configure