From f0b394528f2c73e7b8d867f8d832d477cb52c527 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 14 Dec 2021 23:01:02 +0300
Subject: [PATCH] autotools: support for visibility attributes for relevant
targets.
---
configure | 46 ++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 31 +++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/configure b/configure
index 137616f..0c3e0e8 100755
--- a/configure
+++ b/configure
@@ -12468,6 +12468,50 @@ find_lib()
done
}
+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
+}
+
# Check whether --enable-bmp was given.
if test "${enable_bmp+set}" = set; then :
enableval=$enable_bmp;
@@ -13716,6 +13760,8 @@ fi
+CheckVisibilityHidden
+
OBJCFLAGS=$CFLAGS
# Finally create all the generated files
diff --git a/configure.ac b/configure.ac
index 96a80eb..89b3bfb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,34 @@ find_lib()
done
}
+dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
+CheckVisibilityHidden()
+{
+ AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
+ have_gcc_fvisibility=no
+ case "$host" in
+ *-*-cygwin* | *-*-mingw* | *-*-os2*)
+ AC_MSG_RESULT([ignored for $host_os])
+ return
+ ;;
+ esac
+
+ visibility_CFLAGS="-fvisibility=hidden"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #if !defined(__GNUC__) || __GNUC__ < 4
+ #error SDL only uses visibility attributes in GCC 4 or newer
+ #endif
+ ]],[])], [have_gcc_fvisibility=yes],[])
+ AC_MSG_RESULT($have_gcc_fvisibility)
+ CFLAGS="$save_CFLAGS"
+
+ if test x$have_gcc_fvisibility = xyes; then
+ CFLAGS="$CFLAGS $visibility_CFLAGS"
+ fi
+}
+
dnl Check command-line options
AC_ARG_ENABLE([bmp], [AS_HELP_STRING([--enable-bmp], [support loading BMP/ICO/CUR images [default=yes]])],
[], [enable_bmp=yes])
@@ -392,6 +420,9 @@ fi
AC_SUBST([WINDRES])
AC_SUBST([IMG_LIBS])
+dnl check for GCC visibility attributes
+CheckVisibilityHidden
+
OBJCFLAGS=$CFLAGS
# Finally create all the generated files