[Commits] SDL: configure script: Implement testing for build-time Metal SD...

libsdl.org revision control commits-owner at libsdl.org
Tue Jan 2 15:07:09 PST 2018


details:   https://hg.libsdl.org/SDL/rev/510c0e047122
changeset: 11808:510c0e047122
user:      Alex Szpakowski <slime73 at gmail.com>
date:      Tue Jan 02 19:06:14 2018 -0400
description:
configure script: Implement testing for build-time Metal SDK support.

diffstat:

 configure    |  40 ++++++++++++++++++++++++++++++++++++++--
 configure.in |  28 ++++++++++++++++++++++++----
 2 files changed, 62 insertions(+), 6 deletions(-)

diffs (91 lines):

diff -r 6b3d9e08c586 -r 510c0e047122 configure
--- a/configure	Tue Jan 02 14:32:15 2018 -0800
+++ b/configure	Tue Jan 02 19:06:14 2018 -0400
@@ -21230,11 +21230,47 @@
 fi
 
     if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
+        save_CFLAGS="$CFLAGS"
+                CFLAGS="$CFLAGS -x objective-c"
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Metal framework" >&5
+$as_echo_n "checking for Metal framework... " >&6; }
+        have_metal=no
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+          #import <Cocoa/Cocoa.h>
+          #import <Metal/Metal.h>
+          #import <QuartzCore/CAMetalLayer.h>
+
+          #if !TARGET_CPU_X86_64
+          #error Metal doesn't work on this configuration
+          #endif
+
+int
+main ()
+{
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+        have_metal=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+        CFLAGS="$save_CFLAGS"
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_metal" >&5
+$as_echo "$have_metal" >&6; }
+        if test x$have_metal = xyes; then
 
 $as_echo "#define SDL_VIDEO_RENDER_METAL 1" >>confdefs.h
 
-        SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
-        SUMMARY_video="${SUMMARY_video} metal"
+            SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
+            SUMMARY_video="${SUMMARY_video} metal"
+        fi
     fi
 }
 
diff -r 6b3d9e08c586 -r 510c0e047122 configure.in
--- a/configure.in	Tue Jan 02 14:32:15 2018 -0800
+++ b/configure.in	Tue Jan 02 19:06:14 2018 -0400
@@ -2066,10 +2066,30 @@
 AC_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[default=yes]]]),
                                 , enable_render_metal=yes)
     if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
-        dnl This should maybe make sure you have a supported SDK version.
-        AC_DEFINE(SDL_VIDEO_RENDER_METAL, 1, [ ])
-        SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
-        SUMMARY_video="${SUMMARY_video} metal"
+        save_CFLAGS="$CFLAGS"
+        dnl Work around that we don't have Objective-C support in autoconf
+        CFLAGS="$CFLAGS -x objective-c"
+        AC_MSG_CHECKING(for Metal framework)
+        have_metal=no
+        AC_TRY_COMPILE([
+          #import <Cocoa/Cocoa.h>
+          #import <Metal/Metal.h>
+          #import <QuartzCore/CAMetalLayer.h>
+
+          #if !TARGET_CPU_X86_64
+          #error Metal doesn't work on this configuration
+          #endif
+        ],[
+        ],[
+        have_metal=yes
+        ])
+        CFLAGS="$save_CFLAGS"
+        AC_MSG_RESULT($have_metal)
+        if test x$have_metal = xyes; then
+            AC_DEFINE(SDL_VIDEO_RENDER_METAL, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
+            SUMMARY_video="${SUMMARY_video} metal"
+        fi
     fi
 }
 


More information about the commits mailing list