configure script: Implement testing for build-time Metal SDK support.
authorAlex Szpakowski <slime73@gmail.com>
Tue, 02 Jan 2018 19:06:14 -0400
changeset 11808510c0e047122
parent 11807 6b3d9e08c586
child 11809 4b858abfb24d
configure script: Implement testing for build-time Metal SDK support.
configure
configure.in
     1.1 --- a/configure	Tue Jan 02 14:32:15 2018 -0800
     1.2 +++ b/configure	Tue Jan 02 19:06:14 2018 -0400
     1.3 @@ -21230,11 +21230,47 @@
     1.4  fi
     1.5  
     1.6      if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
     1.7 +        save_CFLAGS="$CFLAGS"
     1.8 +                CFLAGS="$CFLAGS -x objective-c"
     1.9 +        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Metal framework" >&5
    1.10 +$as_echo_n "checking for Metal framework... " >&6; }
    1.11 +        have_metal=no
    1.12 +        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    1.13 +/* end confdefs.h.  */
    1.14 +
    1.15 +          #import <Cocoa/Cocoa.h>
    1.16 +          #import <Metal/Metal.h>
    1.17 +          #import <QuartzCore/CAMetalLayer.h>
    1.18 +
    1.19 +          #if !TARGET_CPU_X86_64
    1.20 +          #error Metal doesn't work on this configuration
    1.21 +          #endif
    1.22 +
    1.23 +int
    1.24 +main ()
    1.25 +{
    1.26 +
    1.27 +
    1.28 +  ;
    1.29 +  return 0;
    1.30 +}
    1.31 +_ACEOF
    1.32 +if ac_fn_c_try_compile "$LINENO"; then :
    1.33 +
    1.34 +        have_metal=yes
    1.35 +
    1.36 +fi
    1.37 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    1.38 +        CFLAGS="$save_CFLAGS"
    1.39 +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_metal" >&5
    1.40 +$as_echo "$have_metal" >&6; }
    1.41 +        if test x$have_metal = xyes; then
    1.42  
    1.43  $as_echo "#define SDL_VIDEO_RENDER_METAL 1" >>confdefs.h
    1.44  
    1.45 -        SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
    1.46 -        SUMMARY_video="${SUMMARY_video} metal"
    1.47 +            SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
    1.48 +            SUMMARY_video="${SUMMARY_video} metal"
    1.49 +        fi
    1.50      fi
    1.51  }
    1.52  
     2.1 --- a/configure.in	Tue Jan 02 14:32:15 2018 -0800
     2.2 +++ b/configure.in	Tue Jan 02 19:06:14 2018 -0400
     2.3 @@ -2066,10 +2066,30 @@
     2.4  AC_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[default=yes]]]),
     2.5                                  , enable_render_metal=yes)
     2.6      if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
     2.7 -        dnl This should maybe make sure you have a supported SDK version.
     2.8 -        AC_DEFINE(SDL_VIDEO_RENDER_METAL, 1, [ ])
     2.9 -        SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
    2.10 -        SUMMARY_video="${SUMMARY_video} metal"
    2.11 +        save_CFLAGS="$CFLAGS"
    2.12 +        dnl Work around that we don't have Objective-C support in autoconf
    2.13 +        CFLAGS="$CFLAGS -x objective-c"
    2.14 +        AC_MSG_CHECKING(for Metal framework)
    2.15 +        have_metal=no
    2.16 +        AC_TRY_COMPILE([
    2.17 +          #import <Cocoa/Cocoa.h>
    2.18 +          #import <Metal/Metal.h>
    2.19 +          #import <QuartzCore/CAMetalLayer.h>
    2.20 +
    2.21 +          #if !TARGET_CPU_X86_64
    2.22 +          #error Metal doesn't work on this configuration
    2.23 +          #endif
    2.24 +        ],[
    2.25 +        ],[
    2.26 +        have_metal=yes
    2.27 +        ])
    2.28 +        CFLAGS="$save_CFLAGS"
    2.29 +        AC_MSG_RESULT($have_metal)
    2.30 +        if test x$have_metal = xyes; then
    2.31 +            AC_DEFINE(SDL_VIDEO_RENDER_METAL, 1, [ ])
    2.32 +            SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
    2.33 +            SUMMARY_video="${SUMMARY_video} metal"
    2.34 +        fi
    2.35      fi
    2.36  }
    2.37