Fixed building on Mac OS X without libusb
authorSam Lantinga <slouken@libsdl.org>
Fri, 02 Aug 2019 18:14:31 -0700
changeset 12984774ceeac9335
parent 12983 2b95ace6e7bd
child 12990 b7e03b88e36b
Fixed building on Mac OS X without libusb
configure
configure.ac
     1.1 --- a/configure	Fri Aug 02 17:20:00 2019 -0700
     1.2 +++ b/configure	Fri Aug 02 18:14:31 2019 -0700
     1.3 @@ -1675,7 +1675,7 @@
     1.4    --enable-wasapi         use the Windows WASAPI audio driver [[default=yes]]
     1.5    --enable-sdl-dlopen     use dlopen for shared object loading [[default=yes]]
     1.6    --enable-hidapi         use HIDAPI for low level joystick drivers
     1.7 -                          [[default=maybe]]
     1.8 +                          [[default=yes]]
     1.9    --enable-clock_gettime  use clock_gettime() instead of gettimeofday() on
    1.10                            UNIX [[default=yes]]
    1.11    --enable-rpath          use an rpath when linking SDL [[default=yes]]
    1.12 @@ -24105,20 +24105,16 @@
    1.13  {
    1.14      # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
    1.15      # so we'll just use libusb when it's available.
    1.16 -    #
    1.17 -    # libusb does not support iOS, so we default to yes on iOS.
    1.18 -    # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
    1.19 -    skiplibusb=no
    1.20      case "$host" in
    1.21 -        *-*-cygwin* | *-*-mingw32* | arm*-apple-darwin* | *-ios-* )
    1.22 +        # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
    1.23 +        *-*-cygwin* | *-*-mingw32* )
    1.24              skiplibusb=yes
    1.25              ;;
    1.26 -    esac
    1.27 -
    1.28 -    # On the other hand, *BSD specifically uses libusb only, so we make a
    1.29 -    # special case just for them.
    1.30 -    onlylibusb=no
    1.31 -    case "$host" in
    1.32 +        # libusb does not support iOS
    1.33 +        arm*-apple-darwin* | *-ios-* )
    1.34 +            skiplibusb=yes
    1.35 +            ;;
    1.36 +        # On the other hand, *BSD specifically uses libusb only
    1.37          *-*-*bsd* )
    1.38              onlylibusb=yes
    1.39              ;;
    1.40 @@ -24128,14 +24124,8 @@
    1.41  if test "${enable_hidapi+set}" = set; then :
    1.42    enableval=$enable_hidapi;
    1.43  else
    1.44 -  enable_hidapi=maybe
    1.45 -fi
    1.46 -
    1.47 -    hidapi_support=no
    1.48 -
    1.49 -    if test x$enable_hidapi = xmaybe; then
    1.50 -      enable_hidapi=$skiplibusb
    1.51 -    fi
    1.52 +  enable_hidapi=yes
    1.53 +fi
    1.54  
    1.55      if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
    1.56          if test x$skiplibusb = xyes; then
    1.57 @@ -24221,12 +24211,10 @@
    1.58              CFLAGS="$save_CFLAGS"
    1.59              if test x$have_libusb_h = xyes; then
    1.60                  hidapi_support=yes
    1.61 -            elif test x$onlylibusb = xno; then
    1.62 -                case "$host" in
    1.63 -                *-*-darwin* )
    1.64 -                    hidapi_support=yes
    1.65 -                    ;;
    1.66 -                esac
    1.67 +            elif test x$onlylibusb = xyes; then
    1.68 +                hidapi_support=no
    1.69 +            else
    1.70 +                hidapi_support=yes
    1.71              fi
    1.72          fi
    1.73  
    1.74 @@ -24237,17 +24225,11 @@
    1.75              EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    1.76              SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    1.77  
    1.78 -            if test x$skiplibusb = xno; then
    1.79 +            if test x$have_libusb_h = xyes; then
    1.80                  EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    1.81                  if test x$onlylibusb = xyes; then
    1.82                      SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    1.83                      EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    1.84 -                elif test x$have_libusb_h != xyes ; then
    1.85 -                    case "$host" in
    1.86 -                    *-*-darwin* )
    1.87 -                        SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
    1.88 -                        ;;
    1.89 -                    esac
    1.90                  else
    1.91                      if test x$have_loadso != xyes; then
    1.92                          { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&5
    1.93 @@ -24273,6 +24255,15 @@
    1.94  _ACEOF
    1.95  
    1.96                  fi
    1.97 +            else
    1.98 +                case "$host" in
    1.99 +                *-*-cygwin* | *-*-mingw32* )
   1.100 +                    SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
   1.101 +                    ;;
   1.102 +                *-*-darwin* )
   1.103 +                    SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
   1.104 +                    ;;
   1.105 +                esac
   1.106              fi
   1.107          fi
   1.108  
   1.109 @@ -24778,10 +24769,6 @@
   1.110              fi
   1.111              SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
   1.112              have_joystick=yes
   1.113 -            # TODO: Remove this block once SDL_hidapi.c supports Windows!
   1.114 -            if test x$hidapi_support = xyes; then
   1.115 -                SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
   1.116 -            fi
   1.117          fi
   1.118          if test x$enable_haptic = xyes; then
   1.119              if test x$have_dinput = xyes -o x$have_xinput = xyes; then
     2.1 --- a/configure.ac	Fri Aug 02 17:20:00 2019 -0700
     2.2 +++ b/configure.ac	Fri Aug 02 18:14:31 2019 -0700
     2.3 @@ -3197,34 +3197,24 @@
     2.4  {
     2.5      # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
     2.6      # so we'll just use libusb when it's available.
     2.7 -    #
     2.8 -    # libusb does not support iOS, so we default to yes on iOS.
     2.9 -    # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
    2.10 -    skiplibusb=no
    2.11      case "$host" in
    2.12 -        *-*-cygwin* | *-*-mingw32* | arm*-apple-darwin* | *-ios-* )
    2.13 +        # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
    2.14 +        *-*-cygwin* | *-*-mingw32* )
    2.15              skiplibusb=yes
    2.16              ;;
    2.17 -    esac
    2.18 -
    2.19 -    # On the other hand, *BSD specifically uses libusb only, so we make a
    2.20 -    # special case just for them.
    2.21 -    onlylibusb=no
    2.22 -    case "$host" in
    2.23 +        # libusb does not support iOS
    2.24 +        arm*-apple-darwin* | *-ios-* )
    2.25 +            skiplibusb=yes
    2.26 +            ;;
    2.27 +        # On the other hand, *BSD specifically uses libusb only
    2.28          *-*-*bsd* )
    2.29              onlylibusb=yes
    2.30              ;;
    2.31      esac
    2.32  
    2.33      AC_ARG_ENABLE(hidapi,
    2.34 -AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=maybe]]]),
    2.35 -                  , enable_hidapi=maybe)
    2.36 -    hidapi_support=no
    2.37 -
    2.38 -    if test x$enable_hidapi = xmaybe; then
    2.39 -      enable_hidapi=$skiplibusb
    2.40 -    fi
    2.41 -
    2.42 +AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=yes]]]),
    2.43 +                  , enable_hidapi=yes)
    2.44      if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
    2.45          if test x$skiplibusb = xyes; then
    2.46              hidapi_support=yes
    2.47 @@ -3236,12 +3226,10 @@
    2.48              CFLAGS="$save_CFLAGS"
    2.49              if test x$have_libusb_h = xyes; then
    2.50                  hidapi_support=yes
    2.51 -            elif test x$onlylibusb = xno; then
    2.52 -                case "$host" in
    2.53 -                *-*-darwin* )
    2.54 -                    hidapi_support=yes
    2.55 -                    ;;
    2.56 -                esac
    2.57 +            elif test x$onlylibusb = xyes; then
    2.58 +                hidapi_support=no
    2.59 +            else
    2.60 +                hidapi_support=yes
    2.61              fi
    2.62          fi
    2.63  
    2.64 @@ -3250,17 +3238,11 @@
    2.65              EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    2.66              SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    2.67  
    2.68 -            if test x$skiplibusb = xno; then
    2.69 +            if test x$have_libusb_h = xyes; then
    2.70                  EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
    2.71                  if test x$onlylibusb = xyes; then
    2.72                      SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
    2.73                      EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
    2.74 -                elif test x$have_libusb_h != xyes ; then
    2.75 -                    case "$host" in
    2.76 -                    *-*-darwin* )
    2.77 -                        SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
    2.78 -                        ;;
    2.79 -                    esac
    2.80                  else
    2.81                      if test x$have_loadso != xyes; then
    2.82                          AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libusb loading])
    2.83 @@ -3281,6 +3263,15 @@
    2.84                      fi
    2.85                      AC_DEFINE_UNQUOTED(SDL_LIBUSB_DYNAMIC, "$libusb_lib", [ ])
    2.86                  fi
    2.87 +            else
    2.88 +                case "$host" in
    2.89 +                *-*-cygwin* | *-*-mingw32* )
    2.90 +                    SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
    2.91 +                    ;;
    2.92 +                *-*-darwin* )
    2.93 +                    SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
    2.94 +                    ;;
    2.95 +                esac
    2.96              fi
    2.97          fi
    2.98  
    2.99 @@ -3640,10 +3631,6 @@
   2.100              fi
   2.101              SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
   2.102              have_joystick=yes
   2.103 -            # TODO: Remove this block once SDL_hidapi.c supports Windows!
   2.104 -            if test x$hidapi_support = xyes; then
   2.105 -                SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
   2.106 -            fi
   2.107          fi
   2.108          if test x$enable_haptic = xyes; then
   2.109              if test x$have_dinput = xyes -o x$have_xinput = xyes; then