From 7a6eedfbb51d8d7317f6f010abdadb5f5b85a831 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 11 Mar 2022 17:40:10 +0300
Subject: [PATCH] enable alloca on mingw/cygwin builds, update alloca includes
in C source
---
SDL_ttf.c | 25 ++++-
configure | 275 +++++++++++++++++++++++++--------------------------
configure.ac | 33 +++----
3 files changed, 170 insertions(+), 163 deletions(-)
diff --git a/SDL_ttf.c b/SDL_ttf.c
index d810ea9..3f75456 100644
--- a/SDL_ttf.c
+++ b/SDL_ttf.c
@@ -24,8 +24,27 @@
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
+#if defined(HAVE_ALLOCA) && !defined(alloca)
+# ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+# elif defined(__GNUC__)
+# define alloca __builtin_alloca
+# elif defined(_MSC_VER)
+# include <malloc.h>
+# define alloca _alloca
+# elif defined(__WATCOMC__)
+# include <malloc.h>
+# elif defined(__BORLANDC__)
+# include <malloc.h>
+# elif defined(__DMC__)
+# include <stdlib.h>
+# elif defined(__AIX__)
+#pragma alloca
+# elif defined(__MRC__)
+void *alloca(unsigned);
+# else
+char *alloca();
+# endif
#endif
#ifdef HAVE_ALLOCA
@@ -33,7 +52,7 @@
#define FREEA(p)
#else
#define ALLOCA(n) malloc(n)
-#define FREEA(p) free(p)
+#define FREEA(p) free(p)
#endif
#include <ft2build.h>
diff --git a/configure b/configure
index dd90a12..ece567c 100755
--- a/configure
+++ b/configure
@@ -795,9 +795,9 @@ PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
SDL_VERSION
+ALLOCA
USE_VERSION_RC_FALSE
USE_VERSION_RC_TRUE
-ALLOCA
WINDRES
am__fastdepCC_FALSE
am__fastdepCC_TRUE
@@ -2380,7 +2380,6 @@ INTERFACE_AGE=1
BINARY_AGE=11
-# libtool versioning
case `pwd` in
*\ * | *\ *)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
@@ -3879,13 +3878,13 @@ if ${lt_cv_nm_interface+:} false; then :
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
- (eval echo "\"\$as_me:3882: $ac_compile\"" >&5)
+ (eval echo "\"\$as_me:3881: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
- (eval echo "\"\$as_me:3885: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval echo "\"\$as_me:3884: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
- (eval echo "\"\$as_me:3888: output\"" >&5)
+ (eval echo "\"\$as_me:3887: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
@@ -5096,7 +5095,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 5099 "configure"' > conftest.$ac_ext
+ echo '#line 5098 "configure"' > conftest.$ac_ext
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -6926,11 +6925,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6929: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6928: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6933: \$? = $ac_status" >&5
+ echo "$as_me:6932: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7265,11 +7264,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7268: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7267: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7272: \$? = $ac_status" >&5
+ echo "$as_me:7271: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7370,11 +7369,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7373: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7372: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7377: \$? = $ac_status" >&5
+ echo "$as_me:7376: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -7425,11 +7424,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7428: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7427: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7432: \$? = $ac_status" >&5
+ echo "$as_me:7431: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -9795,7 +9794,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 9798 "configure"
+#line 9797 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -9891,7 +9890,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 9894 "configure"
+#line 9893 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11548,10 +11547,128 @@ done
case "$host" in
+ *-*-beos*)
+ ac_default_prefix=/boot/develop/tools/gnupro
+ ;;
*-*-cygwin* | *-*-mingw*)
+ if test "$build" != "$host"; then # cross-compiling
+ # Default cross-compile location
+ ac_default_prefix=/usr/local/cross-tools/i386-mingw32
+ else
+ # Look for the location of the tools and install there
+ if test "$BUILD_PREFIX" != ""; then
+ ac_default_prefix=$BUILD_PREFIX
+ fi
+ fi
+ if test x$WINDRES != x; then
+ use_version_rc=true
+ fi
+ ;;
+esac
+ if test x$use_version_rc = xtrue; then
+ USE_VERSION_RC_TRUE=
+ USE_VERSION_RC_FALSE='#'
+else
+ USE_VERSION_RC_TRUE='#'
+ USE_VERSION_RC_FALSE=
+fi
+
+
+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
- *) ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+ 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
+
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
if test "x$ac_cv_type_size_t" = xyes; then :
else
@@ -11746,36 +11863,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-fi
-
- ;;
-esac
-
-case "$host" in
- *-*-beos*)
- ac_default_prefix=/boot/develop/tools/gnupro
- ;;
- *-*-cygwin* | *-*-mingw*)
- if test "$build" != "$host"; then # cross-compiling
- # Default cross-compile location
- ac_default_prefix=/usr/local/cross-tools/i386-mingw32
- else
- # Look for the location of the tools and install there
- if test "$BUILD_PREFIX" != ""; then
- ac_default_prefix=$BUILD_PREFIX
- fi
- fi
- if test x$WINDRES != x; then
- use_version_rc=true
- fi
- ;;
-esac
- if test x$use_version_rc = xtrue; then
- USE_VERSION_RC_TRUE=
- USE_VERSION_RC_FALSE='#'
-else
- USE_VERSION_RC_TRUE='#'
- USE_VERSION_RC_FALSE=
fi
@@ -12223,100 +12310,6 @@ rm -f core conftest.err conftest.$ac_objext \
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
diff --git a/configure.ac b/configure.ac
index ee2cf6c..6bfafe1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ AC_SUBST([PATCH_VERSION], PATCH_VERSION_MACRO)
AC_SUBST([INTERFACE_AGE], INTERFACE_AGE_MACRO)
AC_SUBST([BINARY_AGE], BINARY_AGE_MACRO)
-# libtool versioning
+dnl libtool versioning
LT_INIT([win32-dll])
LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
@@ -63,14 +63,6 @@ else
fi
AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
-case "$host" in
- *-*-cygwin* | *-*-mingw*)
- ;;
-
- *) AC_FUNC_ALLOCA
- ;;
-esac
-
case "$host" in
*-*-beos*)
ac_default_prefix=/boot/develop/tools/gnupro
@@ -92,16 +84,6 @@ case "$host" in
esac
AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
-dnl Check for SDL
-SDL_VERSION=1.2.4
-AC_SUBST(SDL_VERSION)
-AM_PATH_SDL($SDL_VERSION,
- :,
- AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
-)
-CFLAGS="$CFLAGS $SDL_CFLAGS"
-LIBS="$LIBS $SDL_LIBS"
-
dnl See if GCC's -Wall is supported.
CheckWarnAll()
{
@@ -166,6 +148,19 @@ CheckWarnAll
dnl check for GCC visibility attributes
CheckVisibilityHidden
+dnl check for alloca()
+AC_FUNC_ALLOCA
+
+dnl Check for SDL
+SDL_VERSION=1.2.4
+AC_SUBST(SDL_VERSION)
+AM_PATH_SDL($SDL_VERSION,
+ :,
+ AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
+)
+CFLAGS="$CFLAGS $SDL_CFLAGS"
+LIBS="$LIBS $SDL_LIBS"
+
dnl Check for the FreeType 2 library
PKG_CHECK_MODULES([FT2], [freetype2 >= 7.0.1], [
PC_REQUIRES="freetype2 $PC_REQUIRES"