Added -fobjc-arc to support automatic reference counting on macOS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/configure b/configure
index b5e5b72..069b263 100755
--- a/configure
+++ b/configure
@@ -20385,6 +20385,40 @@ $as_echo "#define SDL_ARM_NEON_BLITTERS 1" >>confdefs.h
fi
}
+CheckObjectiveCARC()
+{
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang -fobjc-arc option" >&5
+$as_echo_n "checking for clang -fobjc-arc option... " >&6; }
+ have_clang_objc_arc=no
+
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$save_CFLAGS -fobjc-arc"
+ 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_clang_objc_arc=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_clang_objc_arc" >&5
+$as_echo "$have_clang_objc_arc" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+ if test x$have_clang_objc_arc = xyes; then
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -fobjc-arc"
+ fi
+}
+
CheckVisibilityHidden()
{
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5
@@ -26454,6 +26488,7 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
+ CheckObjectiveCARC
CheckVisibilityHidden
CheckDeclarationAfterStatement
CheckDummyVideo
diff --git a/configure.ac b/configure.ac
index ed3405d..2958d3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1432,6 +1432,26 @@ CheckNEON()
fi
}
+dnl See if clang's -fobjc-arc supported.
+dnl Reference: https://github.com/libsdl-org/SDL/pull/5632
+CheckObjectiveCARC()
+{
+ AC_MSG_CHECKING(for clang -fobjc-arc option)
+ have_clang_objc_arc=no
+
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$save_CFLAGS -fobjc-arc"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ int x = 0;
+ ]],[])], [have_clang_objc_arc=yes],[])
+ AC_MSG_RESULT($have_clang_objc_arc)
+ CFLAGS="$save_CFLAGS"
+
+ if test x$have_clang_objc_arc = xyes; then
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -fobjc-arc"
+ fi
+}
+
dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
CheckVisibilityHidden()
@@ -4197,6 +4217,7 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
+ CheckObjectiveCARC
CheckVisibilityHidden
CheckDeclarationAfterStatement
CheckDummyVideo