configure
changeset 12974 0fef4b21fa1d
parent 12931 881705583f45
child 12978 d2e027c5a389
     1.1 --- a/configure	Wed Jul 31 10:20:37 2019 -0700
     1.2 +++ b/configure	Wed Jul 31 12:20:55 2019 -0400
     1.3 @@ -24106,16 +24106,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      # Check whether --enable-hidapi was given.
    1.30  if test "${enable_hidapi+set}" = set; then :
    1.31    enableval=$enable_hidapi;
    1.32 @@ -24224,9 +24232,35 @@
    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 +                        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&5
    1.45 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&2;}
    1.46 +                    fi
    1.47 +                    SOURCES="$SOURCES $srcdir/src/hidapi/SDL_hidapi.c"
    1.48 +                    # libusb is loaded dynamically, so don't add it to LDFLAGS
    1.49 +                    libusb_lib=""
    1.50 +                    case "$host" in
    1.51 +                        *-*-darwin* )
    1.52 +                            libusb_lib="libusb-1.0.0.dylib"
    1.53 +                            ;;
    1.54 +                        *-*-cygwin* | *-*-mingw32* )
    1.55 +                            libusb_lib="libusb-1.0.dll"
    1.56 +                            ;;
    1.57 +                    esac
    1.58 +                    if test x$libusb_lib = x; then
    1.59 +                        libusb_lib=`find_lib "libusb-1.0.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`
    1.60 +                    fi
    1.61 +
    1.62 +cat >>confdefs.h <<_ACEOF
    1.63 +#define SDL_LIBUSB_DYNAMIC "$libusb_lib"
    1.64 +_ACEOF
    1.65 +
    1.66 +                fi
    1.67              fi
    1.68          fi
    1.69  
    1.70 @@ -24732,6 +24766,7 @@
    1.71              fi
    1.72              SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
    1.73              have_joystick=yes
    1.74 +            # TODO: Remove this block once SDL_hidapi.c supports Windows!
    1.75              if test x$hidapi_support = xyes; then
    1.76                  SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
    1.77              fi
    1.78 @@ -25077,9 +25112,6 @@
    1.79  
    1.80              SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
    1.81              have_joystick=yes
    1.82 -            if test x$hidapi_support = xyes; then
    1.83 -                SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
    1.84 -            fi
    1.85          fi
    1.86          # Set up files for the haptic library
    1.87          if test x$enable_haptic = xyes; then