configure.ac
changeset 12974 0fef4b21fa1d
parent 12931 881705583f45
child 12978 d2e027c5a389
     1.1 --- a/configure.ac	Wed Jul 31 10:20:37 2019 -0700
     1.2 +++ b/configure.ac	Wed Jul 31 12:20:55 2019 -0400
     1.3 @@ -3198,16 +3198,24 @@
     1.4      # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
     1.5      # so we'll just use libusb when it's available.
     1.6      #
     1.7 -    # Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
     1.8 -    #
     1.9 -    #  On macOS and Windows, where you don't need libusb or root, we default to yes.
    1.10 +    # libusb does not support iOS, so we default to yes on iOS.
    1.11 +    # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
    1.12      skiplibusb=no
    1.13      case "$host" in
    1.14 -        *-*-cygwin* | *-*-mingw32* | *-*-darwin* )
    1.15 +        *-*-cygwin* | *-*-mingw32* | arm*-apple-darwin* | *-ios-* )
    1.16              skiplibusb=yes
    1.17              ;;
    1.18      esac
    1.19  
    1.20 +    # On the other hand, *BSD specifically uses libusb only, so we make a
    1.21 +    # special case just for them.
    1.22 +    onlylibusb=no
    1.23 +    case "$host" in
    1.24 +        *-*-*bsd* )
    1.25 +            onlylibusb=yes
    1.26 +            ;;
    1.27 +    esac
    1.28 +
    1.29      AC_ARG_ENABLE(hidapi,
    1.30  AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=maybe]]]),
    1.31                    , enable_hidapi=maybe)
    1.32 @@ -3237,9 +3245,30 @@
    1.33              SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    1.34  
    1.35              if test x$skiplibusb = xno; then
    1.36 -                SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    1.37                  EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    1.38 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    1.39 +                if test x$onlylibusb = xyes; then
    1.40 +                    SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    1.41 +                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    1.42 +                else
    1.43 +                    if test x$have_loadso != xyes; then
    1.44 +                        AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libusb loading])
    1.45 +                    fi
    1.46 +                    SOURCES="$SOURCES $srcdir/src/hidapi/SDL_hidapi.c"
    1.47 +                    # libusb is loaded dynamically, so don't add it to LDFLAGS
    1.48 +                    libusb_lib=""
    1.49 +                    case "$host" in
    1.50 +                        *-*-darwin* )
    1.51 +                            libusb_lib="libusb-1.0.0.dylib"
    1.52 +                            ;;
    1.53 +                        *-*-cygwin* | *-*-mingw32* )
    1.54 +                            libusb_lib="libusb-1.0.dll"
    1.55 +                            ;;
    1.56 +                    esac
    1.57 +                    if test x$libusb_lib = x; then
    1.58 +                        libusb_lib=[`find_lib "libusb-1.0.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
    1.59 +                    fi
    1.60 +                    AC_DEFINE_UNQUOTED(SDL_LIBUSB_DYNAMIC, "$libusb_lib", [ ])
    1.61 +                fi
    1.62              fi
    1.63          fi
    1.64  
    1.65 @@ -3599,6 +3628,7 @@
    1.66              fi
    1.67              SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
    1.68              have_joystick=yes
    1.69 +            # TODO: Remove this block once SDL_hidapi.c supports Windows!
    1.70              if test x$hidapi_support = xyes; then
    1.71                  SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
    1.72              fi
    1.73 @@ -3842,9 +3872,6 @@
    1.74              AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
    1.75              SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
    1.76              have_joystick=yes
    1.77 -            if test x$hidapi_support = xyes; then
    1.78 -                SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
    1.79 -            fi
    1.80          fi
    1.81          # Set up files for the haptic library
    1.82          if test x$enable_haptic = xyes; then