SDL_ttf: autotools build system updates:

From c344d057ac4bcb415dddef171b77b01ced8346ee Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 26 Jan 2022 17:55:50 +0300
Subject: [PATCH] autotools build system updates:

- Add -Wall to CFLAGS, when available.
- Use visibility attribs if available.
---
 configure        | 1130 +++++++++++++++++++++++++---------------------
 configure.ac     |   86 +++-
 touch-autofoo.sh |    7 +
 3 files changed, 694 insertions(+), 529 deletions(-)
 create mode 100755 touch-autofoo.sh

diff --git a/configure b/configure
index 0d128c6..914b41e 100755
--- a/configure
+++ b/configure
@@ -785,16 +785,16 @@ X_LIBS
 X_PRE_LIBS
 X_CFLAGS
 XMKMF
-SDL_CONFIG
-SDL_LIBS
-SDL_CFLAGS
-SDL_VERSION
 FT2_CONFIG
 FT2_LIBS
 FT2_CFLAGS
+SDL_CONFIG
+SDL_LIBS
+SDL_CFLAGS
 PKG_CONFIG_LIBDIR
 PKG_CONFIG_PATH
 PKG_CONFIG
+SDL_VERSION
 USE_VERSION_RC_FALSE
 USE_VERSION_RC_TRUE
 ALLOCA
@@ -927,12 +927,12 @@ enable_fast_install
 with_gnu_ld
 enable_libtool_lock
 enable_dependency_tracking
-with_ft_prefix
-with_ft_exec_prefix
-enable_freetypetest
 with_sdl_prefix
 with_sdl_exec_prefix
 enable_sdltest
+with_ft_prefix
+with_ft_exec_prefix
+enable_freetypetest
 with_x
 '
       ac_precious_vars='build_alias
@@ -947,10 +947,10 @@ CPP
 PKG_CONFIG
 PKG_CONFIG_PATH
 PKG_CONFIG_LIBDIR
-FT2_CFLAGS
-FT2_LIBS
 SDL_CFLAGS
 SDL_LIBS
+FT2_CFLAGS
+FT2_LIBS
 XMKMF'
 
 
@@ -1581,9 +1581,9 @@ Optional Features:
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
+  --disable-sdltest       Do not try to compile and run a test SDL program
   --disable-freetypetest  Do not try to compile and run a test FreeType
                           program
-  --disable-sdltest       Do not try to compile and run a test SDL program
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1591,11 +1591,11 @@ Optional Packages:
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)
+  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)
   --with-ft-prefix=PREFIX Prefix where FreeType is installed (optional)
   --with-ft-exec-prefix=PREFIX
                           Exec prefix where FreeType is installed (optional)
-  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)
-  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)
   --with-x                use the X Window System
 
 Some influential environment variables:
@@ -1612,10 +1612,10 @@ Some influential environment variables:
               directories to add to pkg-config's search path
   PKG_CONFIG_LIBDIR
               path overriding pkg-config's built-in search path
-  FT2_CFLAGS  C compiler flags for FT2, overriding pkg-config
-  FT2_LIBS    linker flags for FT2, overriding pkg-config
   SDL_CFLAGS  C compiler flags for SDL, overriding pkg-config
   SDL_LIBS    linker flags for SDL, overriding pkg-config
+  FT2_CFLAGS  C compiler flags for FT2, overriding pkg-config
+  FT2_LIBS    linker flags for FT2, overriding pkg-config
   XMKMF       Path to xmkmf, Makefile generator for X Window System
 
 Use these variables to override the choices made by `configure' or to help
@@ -11773,6 +11773,8 @@ else
 fi
 
 
+SDL_VERSION=1.2.4
+
 
 
 
@@ -11894,20 +11896,47 @@ $as_echo "no" >&6; }
 	fi
 fi
 
+# Check whether --with-sdl-prefix was given.
+if test "${with_sdl_prefix+set}" = set; then :
+  withval=$with_sdl_prefix; sdl_prefix="$withval"
+else
+  sdl_prefix=""
+fi
+
+
+# Check whether --with-sdl-exec-prefix was given.
+if test "${with_sdl_exec_prefix+set}" = set; then :
+  withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval"
+else
+  sdl_exec_prefix=""
+fi
+
+# Check whether --enable-sdltest was given.
+if test "${enable_sdltest+set}" = set; then :
+  enableval=$enable_sdltest;
+else
+  enable_sdltest=yes
+fi
+
+
+  min_sdl_version=$SDL_VERSION
+
+  if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
+
 pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype2 >= 7.0.1" >&5
-$as_echo_n "checking for freetype2 >= 7.0.1... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl >= $min_sdl_version" >&5
+$as_echo_n "checking for sdl >= $min_sdl_version... " >&6; }
 
-if test -n "$FT2_CFLAGS"; then
-    pkg_cv_FT2_CFLAGS="$FT2_CFLAGS"
+if test -n "$SDL_CFLAGS"; then
+    pkg_cv_SDL_CFLAGS="$SDL_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2 >= 7.0.1\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "freetype2 >= 7.0.1") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl >= \$min_sdl_version\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "sdl >= $min_sdl_version") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_FT2_CFLAGS=`$PKG_CONFIG --cflags "freetype2 >= 7.0.1" 2>/dev/null`
+  pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl >= $min_sdl_version" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -11915,16 +11944,16 @@ fi
  else
     pkg_failed=untried
 fi
-if test -n "$FT2_LIBS"; then
-    pkg_cv_FT2_LIBS="$FT2_LIBS"
+if test -n "$SDL_LIBS"; then
+    pkg_cv_SDL_LIBS="$SDL_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2 >= 7.0.1\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "freetype2 >= 7.0.1") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl >= \$min_sdl_version\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "sdl >= $min_sdl_version") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_FT2_LIBS=`$PKG_CONFIG --libs "freetype2 >= 7.0.1" 2>/dev/null`
+  pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl >= $min_sdl_version" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -11945,66 +11974,59 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        FT2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "freetype2 >= 7.0.1" 2>&1`
+	        SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sdl >= $min_sdl_version" 2>&1`
         else
-	        FT2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "freetype2 >= 7.0.1" 2>&1`
+	        SDL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sdl >= $min_sdl_version" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$FT2_PKG_ERRORS" >&5
-
-	    # Get the cflags and libraries from the freetype-config script
-
-# Check whether --with-ft-prefix was given.
-if test "${with_ft_prefix+set}" = set; then :
-  withval=$with_ft_prefix; ft_config_prefix="$withval"
-else
-  ft_config_prefix=""
-fi
-
-
-
-# Check whether --with-ft-exec-prefix was given.
-if test "${with_ft_exec_prefix+set}" = set; then :
-  withval=$with_ft_exec_prefix; ft_config_exec_prefix="$withval"
-else
-  ft_config_exec_prefix=""
-fi
-
+	echo "$SDL_PKG_ERRORS" >&5
 
-   # Check whether --enable-freetypetest was given.
-if test "${enable_freetypetest+set}" = set; then :
-  enableval=$enable_freetypetest;
+	sdl_pc=no
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	sdl_pc=no
 else
-  enable_fttest=yes
+	SDL_CFLAGS=$pkg_cv_SDL_CFLAGS
+	SDL_LIBS=$pkg_cv_SDL_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	sdl_pc=yes
 fi
+  else
+    sdl_pc=no
+    if test x$sdl_exec_prefix != x ; then
+      sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
+      if test x${SDL_CONFIG+set} != xset ; then
+        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
+      fi
+    fi
+    if test x$sdl_prefix != x ; then
+      sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
+      if test x${SDL_CONFIG+set} != xset ; then
+        SDL_CONFIG=$sdl_prefix/bin/sdl-config
+      fi
+    fi
+  fi
 
-
-   if test x$ft_config_exec_prefix != x ; then
-     ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
-     if test x${FT2_CONFIG+set} != xset ; then
-       FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
-     fi
-   fi
-
-   if test x$ft_config_prefix != x ; then
-     ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
-     if test x${FT2_CONFIG+set} != xset ; then
-       FT2_CONFIG=$ft_config_prefix/bin/freetype-config
-     fi
-   fi
-
-   if test "x$FT2_CONFIG" = x ; then
-     if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}freetype-config", so it can be a program name with args.
-set dummy ${ac_tool_prefix}freetype-config; ac_word=$2
+  if test "x$sdl_pc" = xyes ; then
+    no_sdl=""
+    SDL_CONFIG="pkg-config sdl"
+  else
+    as_save_PATH="$PATH"
+    if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
+      PATH="$prefix/bin:$prefix/usr/bin:$PATH"
+    fi
+    # Extract the first word of "sdl-config", so it can be a program name with args.
+set dummy sdl-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_FT2_CONFIG+:} false; then :
+if ${ac_cv_path_SDL_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $FT2_CONFIG in
+  case $SDL_CONFIG in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_FT2_CONFIG="$FT2_CONFIG" # Let the user override the test with a path.
+  ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -12014,7 +12036,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_FT2_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -12022,247 +12044,332 @@ done
   done
 IFS=$as_save_IFS
 
+  test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no"
   ;;
 esac
 fi
-FT2_CONFIG=$ac_cv_path_FT2_CONFIG
-if test -n "$FT2_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FT2_CONFIG" >&5
-$as_echo "$FT2_CONFIG" >&6; }
+SDL_CONFIG=$ac_cv_path_SDL_CONFIG
+if test -n "$SDL_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDL_CONFIG" >&5
+$as_echo "$SDL_CONFIG" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-fi
-if test -z "$ac_cv_path_FT2_CONFIG"; then
-  ac_pt_FT2_CONFIG=$FT2_CONFIG
-  # Extract the first word of "freetype-config", so it can be a program name with args.
-set dummy freetype-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_ac_pt_FT2_CONFIG+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ac_pt_FT2_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ac_pt_FT2_CONFIG="$ac_pt_FT2_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_ac_pt_FT2_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+    PATH="$as_save_PATH"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL - version >= $min_sdl_version" >&5
+$as_echo_n "checking for SDL - version >= $min_sdl_version... " >&6; }
+    no_sdl=""
 
-  ;;
-esac
-fi
-ac_pt_FT2_CONFIG=$ac_cv_path_ac_pt_FT2_CONFIG
-if test -n "$ac_pt_FT2_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_FT2_CONFIG" >&5
-$as_echo "$ac_pt_FT2_CONFIG" >&6; }
+    if test "$SDL_CONFIG" = "no" ; then
+      no_sdl=yes
+    else
+      SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
+      SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
+
+      sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
+             sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
+      sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
+             sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
+      sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
+             sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
+      if test "x$enable_sdltest" = "xyes" ; then
+        ac_save_CFLAGS="$CFLAGS"
+        ac_save_CXXFLAGS="$CXXFLAGS"
+        ac_save_LIBS="$LIBS"
+        CFLAGS="$CFLAGS $SDL_CFLAGS"
+        CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+        LIBS="$LIBS $SDL_LIBS"
+      rm -f conf.sdltest
+      if test "$cross_compiling" = yes; then :
+  echo $ac_n "cross compiling; assumed OK... $ac_c"
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-  if test "x$ac_pt_FT2_CONFIG" = x; then
-    FT2_CONFIG="no"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    FT2_CONFIG=$ac_pt_FT2_CONFIG
-  fi
-else
-  FT2_CONFIG="$ac_cv_path_FT2_CONFIG"
-fi
-
-   fi
-
-   min_ft_version=7.0.1
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeType -- version >= $min_ft_version" >&5
-$as_echo_n "checking for FreeType -- version >= $min_ft_version... " >&6; }
-   no_ft=""
-   if test "$FT2_CONFIG" = "no" ; then
-     no_ft=yes
-   else
-     FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
-     FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
-     ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
-       sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
-     ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
-       sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
-     ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
-       sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
-     ft_min_major_version=`echo $min_ft_version | \
-       sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
-     ft_min_minor_version=`echo $min_ft_version | \
-       sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
-     ft_min_micro_version=`echo $min_ft_version | \
-       sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
-     if test x$enable_fttest = xyes ; then
-       ft_config_is_lt=""
-       if test $ft_config_major_version -lt $ft_min_major_version ; then
-         ft_config_is_lt=yes
-       else
-         if test $ft_config_major_version -eq $ft_min_major_version ; then
-           if test $ft_config_minor_version -lt $ft_min_minor_version ; then
-             ft_config_is_lt=yes
-           else
-             if test $ft_config_minor_version -eq $ft_min_minor_version ; then
-               if test $ft_config_micro_version -lt $ft_min_micro_version ; then
-                 ft_config_is_lt=yes
-               fi
-             fi
-           fi
-         fi
-       fi
-       if test x$ft_config_is_lt = xyes ; then
-         no_ft=yes
-       else
-         ac_save_CFLAGS="$CFLAGS"
-         ac_save_LIBS="$LIBS"
-         CFLAGS="$CFLAGS $FT2_CFLAGS"
-         LIBS="$FT2_LIBS $LIBS"
-
-         #
-         # Sanity checks for the results of freetype-config to some extent.
-         #
-         if test "$cross_compiling" = yes; then :
-  echo $ECHO_N "cross compiling; assuming OK... $ECHO_C"
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-
-#include <ft2build.h>
-#include <freetype/freetype.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "SDL.h"
 
-int
-main()
+int main (int argc, char *argv[])
 {
-  FT_Library library;
-  FT_Error  error;
+  int major, minor, micro;
+  FILE *fp = fopen("conf.sdltest", "w");
 
-  error = FT_Init_FreeType(&library);
+  if (fp) fclose(fp);
 
-  if (error)
-    return 1;
+  if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
+     printf("%s, bad version string\n", "$min_sdl_version");
+     exit(1);
+   }
+
+   if (($sdl_major_version > major) ||
+      (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
+      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
+    {
+      return 0;
+    }
   else
-  {
-    FT_Done_FreeType(library);
-    return 0;
-  }
+    {
+      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
+      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
+      printf("*** best to upgrade to the required version.\n");
+      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
+      printf("*** to point to the correct copy of sdl-config, and remove the file\n");
+      printf("*** config.cache before re-running configure\n");
+      return 1;
+    }
 }
 
 
-
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
 
 else
-  no_ft=yes
+  no_sdl=yes
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
-
-         CFLAGS="$ac_save_CFLAGS"
-         LIBS="$ac_save_LIBS"
-       fi             # test $ft_config_version -lt $ft_min_version
-     fi               # test x$enable_fttest = xyes
-   fi                 # test "$FT2_CONFIG" = "no"
-
-   if test x$no_ft = x ; then
-     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        CFLAGS="$ac_save_CFLAGS"
+        CXXFLAGS="$ac_save_CXXFLAGS"
+        LIBS="$ac_save_LIBS"
+      fi
+    fi
+    if test "x$no_sdl" = x ; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-     :
-   else
-     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-     if test "$FT2_CONFIG" = "no" ; then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-
-  The freetype-config script installed by FreeType 2 could not be found.
-  If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in
-  your path, or set the FT2_CONFIG environment variable to the
-  full path to freetype-config.
-       " >&5
-$as_echo "$as_me: WARNING:
-
-  The freetype-config script installed by FreeType 2 could not be found.
-  If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in
-  your path, or set the FT2_CONFIG environment variable to the
-  full path to freetype-config.
-       " >&2;}
+    fi
+  fi
+  if test "x$no_sdl" = x ; then
+     :
+  else
+     if test "$SDL_CONFIG" = "no" ; then
+       echo "*** The sdl-config script installed by SDL could not be found"
+       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
+       echo "*** your path, or set the SDL_CONFIG environment variable to the"
+       echo "*** full path to sdl-config."
      else
-       if test x$ft_config_is_lt = xyes ; then
-         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-
-  Your installed version of the FreeType 2 library is too old.
-  If you have different versions of FreeType 2, make sure that
-  correct values for --with-ft-prefix or --with-ft-exec-prefix
-  are used, or set the FT2_CONFIG environment variable to the
-  full path to freetype-config.
-         " >&5
-$as_echo "$as_me: WARNING:
-
-  Your installed version of the FreeType 2 library is too old.
-  If you have different versions of FreeType 2, make sure that
-  correct values for --with-ft-prefix or --with-ft-exec-prefix
-  are used, or set the FT2_CONFIG environment variable to the
-  full path to freetype-config.
-         " >&2;}
+       if test -f conf.sdltest ; then
+        :
        else
-         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
+          echo "*** Could not run SDL test program, checking why..."
+          CFLAGS="$CFLAGS $SDL_CFLAGS"
+          CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+          LIBS="$LIBS $SDL_LIBS"
+          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-  The FreeType test program failed to run.  If your system uses
-  shared libraries and they are installed outside the normal
-  system library path, make sure the variable LD_LIBRARY_PATH
-  (or whatever is appropriate for your system) is correctly set.
-         " >&5
-$as_echo "$as_me: WARNING:
+#include <stdio.h>
+#include "SDL.h"
 
-  The FreeType test program failed to run.  If your system uses
-  shared libraries and they are installed outside the normal
-  system library path, make sure the variable LD_LIBRARY_PATH
-  (or whatever is appropriate for your system) is correctly set.
-         " >&2;}
+int main(int argc, char *argv[])
+{ return 0; }
+#undef  main
+#define main K_and_R_C_main
+
+int
+main ()
+{
+ return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+   echo "*** The test program compiled, but did not run. This usually means"
+          echo "*** that the run-time linker is not finding SDL or finding the wrong"
+          echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
+          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+          echo "*** is required on your system"
+	  echo "***"
+          echo "*** If you have an old version installed, it is best to remove it, although"
+          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
+else
+   echo "*** The test program failed to compile or link. See the file config.log for the"
+          echo "*** exact error that occured. This usually means SDL was incorrectly installed"
+          echo "*** or that you have moved SDL since it was installed. In the latter case, you"
+          echo "*** may want to edit the sdl-config script: $SDL_CONFIG"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+          CFLAGS="$ac_save_CFLAGS"
+          CXXFLAGS="$ac_save_CXXFLAGS"
+          LIBS="$ac_save_LIBS"
        fi
      fi
+     SDL_CFLAGS=""
+     SDL_LIBS=""
+     as_fn_error $? "*** SDL version $SDL_VERSION not found!" "$LINENO" 5
 
-     FT2_CFLAGS=""
-     FT2_LIBS=""
-     as_fn_error $? "*** Unable to find FreeType2 library (http://www.freetype.org/)" "$LINENO" 5
+  fi
 
-   fi
 
+  rm -f conf.sdltest
+
+CFLAGS="$CFLAGS $SDL_CFLAGS"
+LIBS="$LIBS $SDL_LIBS"
+
+CheckWarnAll()
+{
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wall option" >&5
+$as_echo_n "checking for GCC -Wall option... " >&6; }
+    have_gcc_Wall=no
+
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$save_CFLAGS -Wall"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int x = 0;
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  have_gcc_Wall=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_Wall" >&5
+$as_echo "$have_gcc_Wall" >&6; }
+    CFLAGS="$save_CFLAGS"
+
+    if test x$have_gcc_Wall = xyes; then
+        CFLAGS="$CFLAGS -Wall"
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for necessary GCC -Wno-multichar option" >&5
+$as_echo_n "checking for necessary GCC -Wno-multichar option... " >&6; }
+        need_gcc_Wno_multichar=no
+        case "$host" in
+            *-*-beos* | *-*-haiku*)
+                need_gcc_Wno_multichar=yes
+                ;;
+        esac
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $need_gcc_Wno_multichar" >&5
+$as_echo "$need_gcc_Wno_multichar" >&6; }
+        if test x$need_gcc_Wno_multichar = xyes; then
+            CFLAGS="$CFLAGS -Wno-multichar"
+        fi
+    fi
+}
+
+CheckVisibilityHidden()
+{
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5
+$as_echo_n "checking for GCC -fvisibility=hidden option... " >&6; }
+    have_gcc_fvisibility=no
+    case "$host" in
+    *-*-cygwin* | *-*-mingw* | *-*-os2*)
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: ignored for $host_os" >&5
+$as_echo "ignored for $host_os" >&6; }
+        return
+        ;;
+    esac
+
+    visibility_CFLAGS="-fvisibility=hidden"
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+    #if !defined(__GNUC__) || __GNUC__ < 4
+    #error SDL only uses visibility attributes in GCC 4 or newer
+    #endif
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  have_gcc_fvisibility=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_fvisibility" >&5
+$as_echo "$have_gcc_fvisibility" >&6; }
+    CFLAGS="$save_CFLAGS"
+
+    if test x$have_gcc_fvisibility = xyes; then
+        CFLAGS="$CFLAGS $visibility_CFLAGS"
+    fi
+}
+
+CheckWarnAll
+
+CheckVisibilityHidden
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype2 >= 7.0.1" >&5
+$as_echo_n "checking for freetype2 >= 7.0.1... " >&6; }
+
+if test -n "$FT2_CFLAGS"; then
+    pkg_cv_FT2_CFLAGS="$FT2_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2 >= 7.0.1\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "freetype2 >= 7.0.1") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_FT2_CFLAGS=`$PKG_CONFIG --cflags "freetype2 >= 7.0.1" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$FT2_LIBS"; then
+    pkg_cv_FT2_LIBS="$FT2_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2 >= 7.0.1\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "freetype2 >= 7.0.1") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_FT2_LIBS=`$PKG_CONFIG --libs "freetype2 >= 7.0.1" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
 
 
-    PC_LIBS="$FT2_LIBS $PC_LIBS"
 
-elif test $pkg_failed = untried; then
+if test $pkg_failed = yes; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        FT2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "freetype2 >= 7.0.1" 2>&1`
+        else
+	        FT2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "freetype2 >= 7.0.1" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$FT2_PKG_ERRORS" >&5
+
 	    # Get the cflags and libraries from the freetype-config script
 
 # Check whether --with-ft-prefix was given.
@@ -12571,152 +12678,105 @@ $as_echo "$as_me: WARNING:
 
     PC_LIBS="$FT2_LIBS $PC_LIBS"
 
-else
-	FT2_CFLAGS=$pkg_cv_FT2_CFLAGS
-	FT2_LIBS=$pkg_cv_FT2_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-    PC_REQUIRES="freetype2 $PC_REQUIRES"
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	    # Get the cflags and libraries from the freetype-config script
 
+# Check whether --with-ft-prefix was given.
+if test "${with_ft_prefix+set}" = set; then :
+  withval=$with_ft_prefix; ft_config_prefix="$withval"
+else
+  ft_config_prefix=""
 fi
-CFLAGS="$CFLAGS $FT2_CFLAGS"
-LIBS="$LIBS $FT2_LIBS"
 
-SDL_VERSION=1.2.4
 
 
-# Check whether --with-sdl-prefix was given.
-if test "${with_sdl_prefix+set}" = set; then :
-  withval=$with_sdl_prefix; sdl_prefix="$withval"
+# Check whether --with-ft-exec-prefix was given.
+if test "${with_ft_exec_prefix+set}" = set; then :
+  withval=$with_ft_exec_prefix; ft_config_exec_prefix="$withval"
 else
-  sdl_prefix=""
+  ft_config_exec_prefix=""
 fi
 
 
-# Check whether --with-sdl-exec-prefix was given.
-if test "${with_sdl_exec_prefix+set}" = set; then :
-  withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval"
-else
-  sdl_exec_prefix=""
-fi
-
-# Check whether --enable-sdltest was given.
-if test "${enable_sdltest+set}" = set; then :
-  enableval=$enable_sdltest;
+   # Check whether --enable-freetypetest was given.
+if test "${enable_freetypetest+set}" = set; then :
+  enableval=$enable_freetypetest;
 else
-  enable_sdltest=yes
+  enable_fttest=yes
 fi
 
 
-  min_sdl_version=$SDL_VERSION
-
-  if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
+   if test x$ft_config_exec_prefix != x ; then
+     ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
+     if test x${FT2_CONFIG+set} != xset ; then
+       FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
+     fi
+   fi
 
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl >= $min_sdl_version" >&5
-$as_echo_n "checking for sdl >= $min_sdl_version... " >&6; }
+   if test x$ft_config_prefix != x ; then
+     ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
+     if test x${FT2_CONFIG+set} != xset ; then
+       FT2_CONFIG=$ft_config_prefix/bin/freetype-config
+     fi
+   fi
 
-if test -n "$SDL_CFLAGS"; then
-    pkg_cv_SDL_CFLAGS="$SDL_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl >= \$min_sdl_version\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "sdl >= $min_sdl_version") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl >= $min_sdl_version" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
+   if test "x$FT2_CONFIG" = x ; then
+     if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}freetype-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}freetype-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FT2_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
+  case $FT2_CONFIG in
+  [\\/]* | ?:[\\/]*)

(Patch may be truncated, please check the link at the top of this post.)