configure.ac
changeset 12931 881705583f45
parent 12899 11cb5d784a3a
child 12974 0fef4b21fa1d
     1.1 --- a/configure.ac	Sun Jul 07 11:23:16 2019 -0700
     1.2 +++ b/configure.ac	Mon Jul 08 16:08:16 2019 -0400
     1.3 @@ -3199,26 +3199,50 @@
     1.4      # so we'll just use libusb when it's available.
     1.5      #
     1.6      # Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
     1.7 +    #
     1.8 +    #  On macOS and Windows, where you don't need libusb or root, we default to yes.
     1.9 +    skiplibusb=no
    1.10 +    case "$host" in
    1.11 +        *-*-cygwin* | *-*-mingw32* | *-*-darwin* )
    1.12 +            skiplibusb=yes
    1.13 +            ;;
    1.14 +    esac
    1.15 +
    1.16      AC_ARG_ENABLE(hidapi,
    1.17 -AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=no]]]),
    1.18 -                  , enable_hidapi=no)
    1.19 +AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=maybe]]]),
    1.20 +                  , enable_hidapi=maybe)
    1.21 +    hidapi_support=no
    1.22 +
    1.23 +    if test x$enable_hidapi = xmaybe; then
    1.24 +      enable_hidapi=$skiplibusb
    1.25 +    fi
    1.26 +
    1.27      if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
    1.28 -        PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
    1.29 -        hidapi_support=no
    1.30 -        save_CFLAGS="$CFLAGS"
    1.31 -        CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
    1.32 -        AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
    1.33 -        CFLAGS="$save_CFLAGS"
    1.34 -
    1.35 -        if test x$have_libusb_h = xyes; then
    1.36 +        if test x$skiplibusb = xyes; then
    1.37              hidapi_support=yes
    1.38 +        else
    1.39 +            PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
    1.40 +            save_CFLAGS="$CFLAGS"
    1.41 +            CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
    1.42 +            AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
    1.43 +            CFLAGS="$save_CFLAGS"
    1.44 +            if test x$have_libusb_h = xyes; then
    1.45 +                hidapi_support=yes
    1.46 +            fi
    1.47 +        fi
    1.48 +
    1.49 +        if test x$hidapi_support = xyes; then
    1.50              AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
    1.51              EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    1.52              SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    1.53 -            SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    1.54 -            EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    1.55 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    1.56 +
    1.57 +            if test x$skiplibusb = xno; then
    1.58 +                SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    1.59 +                EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    1.60 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    1.61 +            fi
    1.62          fi
    1.63 +
    1.64          AC_MSG_CHECKING(for hidapi support)
    1.65          AC_MSG_RESULT($hidapi_support)
    1.66      fi
    1.67 @@ -3521,6 +3545,7 @@
    1.68          CheckWINDOWSGLES
    1.69          CheckVulkan
    1.70          CheckDIRECTX
    1.71 +        CheckHIDAPI
    1.72  
    1.73          # Set up the core platform files
    1.74          SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
    1.75 @@ -3572,12 +3597,11 @@
    1.76              else
    1.77                  AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
    1.78              fi
    1.79 -            AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
    1.80              SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
    1.81 -            SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    1.82 -            SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
    1.83 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    1.84              have_joystick=yes
    1.85 +            if test x$hidapi_support = xyes; then
    1.86 +                SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
    1.87 +            fi
    1.88          fi
    1.89          if test x$enable_haptic = xyes; then
    1.90              if test x$have_dinput = xyes -o x$have_xinput = xyes; then
    1.91 @@ -3803,6 +3827,7 @@
    1.92          CheckOpenGLX11
    1.93          CheckVulkan
    1.94          CheckPTHREAD
    1.95 +        CheckHIDAPI
    1.96  
    1.97          # Set up files for the audio library
    1.98          if test x$enable_audio = xyes; then
    1.99 @@ -3815,12 +3840,11 @@
   1.100          # Set up files for the joystick library
   1.101          if test x$enable_joystick = xyes; then
   1.102              AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
   1.103 -            AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
   1.104              SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
   1.105 -            SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
   1.106 -            SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
   1.107 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
   1.108              have_joystick=yes
   1.109 +            if test x$hidapi_support = xyes; then
   1.110 +                SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
   1.111 +            fi
   1.112          fi
   1.113          # Set up files for the haptic library
   1.114          if test x$enable_haptic = xyes; then