# HG changeset patch # User Ozkan Sezer # Date 1606216230 -10800 # Node ID 80ffdcd9a01e8d426e209299b2481f4cbd77e9f2 # Parent 3bf2dae56f420802fefa12b13f034e50105a4e89 configure.ac: check GameController framework support when targeting Darwin disables SDL_JOYSTICK_MFI for i386 or if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 --disable-joystick-mfi disables it unconditionally. diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2807,6 +2807,43 @@ fi } +dnl Check to see if GameController framework support is desired +CheckJoystickMFI() +{ + AC_ARG_ENABLE(joystick-mfi, +AS_HELP_STRING([--enable-joystick-mfi], [include macOS MFI joystick support [[default=yes]]]), + , enable_joystick_mfi=yes) + + if test x$enable_joystick_mfi = xyes; then + 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 GameController framework) + enable_joystick_mfi=no + AC_TRY_COMPILE([ + #include + #include + #import + + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 + #error GameController framework doesn't work on this configuration + #endif + #if TARGET_CPU_X86 + #error GameController framework doesn't work on this configuration + #endif + ],[ + ],[ + enable_joystick_mfi=yes + ]) + CFLAGS="$save_CFLAGS" + AC_MSG_RESULT($enable_joystick_mfi) + if test x$enable_joystick_mfi = xyes; then + AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ]) + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" + fi + fi +} + dnl See what type of thread model to use on Linux and Solaris CheckPTHREAD() { @@ -4063,10 +4100,9 @@ # Set up files for the joystick library if test x$enable_joystick = xyes; then AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ]) - AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ]) SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c" SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" + CheckJoystickMFI have_joystick=yes fi # Set up files for the haptic library diff --git a/configure b/configure --- a/configure +++ b/configure @@ -887,6 +887,7 @@ enable_ime enable_ibus enable_fcitx +enable_joystick_mfi enable_pthreads enable_pthread_sem enable_directx @@ -1670,6 +1671,7 @@ --enable-ime enable IME support [[default=yes]] --enable-ibus enable IBus support [[default=yes]] --enable-fcitx enable fcitx support [[default=yes]] + --enable-joystick-mfi include macOS MFI joystick support [[default=yes]] --enable-pthreads use POSIX threads for multi-threading [[default=yes]] --enable-pthread-sem use pthread semaphores [[default=yes]] @@ -23173,6 +23175,63 @@ fi } +CheckJoystickMFI() +{ + # Check whether --enable-joystick-mfi was given. +if test "${enable_joystick_mfi+set}" = set; then : + enableval=$enable_joystick_mfi; +else + enable_joystick_mfi=yes +fi + + + if test x$enable_joystick_mfi = xyes; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -x objective-c" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GameController framework" >&5 +$as_echo_n "checking for GameController framework... " >&6; } + enable_joystick_mfi=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + #import + + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 + #error GameController framework doesn't work on this configuration + #endif + #if TARGET_CPU_X86 + #error GameController framework doesn't work on this configuration + #endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + enable_joystick_mfi=yes + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$save_CFLAGS" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_joystick_mfi" >&5 +$as_echo "$enable_joystick_mfi" >&6; } + if test x$enable_joystick_mfi = xyes; then + +$as_echo "#define SDL_JOYSTICK_MFI 1" >>confdefs.h + + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" + fi + fi +} + CheckPTHREAD() { # Check whether --enable-pthreads was given. @@ -25383,12 +25442,9 @@ $as_echo "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h - -$as_echo "#define SDL_JOYSTICK_MFI 1" >>confdefs.h - SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c" SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" + CheckJoystickMFI have_joystick=yes fi # Set up files for the haptic library