Fixed building on Mac OS X without libusb

This commit is contained in:
Sam Lantinga 2019-08-02 18:14:31 -07:00
parent e92fe23c83
commit 67fa8601d9
2 changed files with 46 additions and 72 deletions

57
configure vendored
View File

@ -1675,7 +1675,7 @@ Optional Features:
--enable-wasapi use the Windows WASAPI audio driver [[default=yes]] --enable-wasapi use the Windows WASAPI audio driver [[default=yes]]
--enable-sdl-dlopen use dlopen for shared object loading [[default=yes]] --enable-sdl-dlopen use dlopen for shared object loading [[default=yes]]
--enable-hidapi use HIDAPI for low level joystick drivers --enable-hidapi use HIDAPI for low level joystick drivers
[[default=maybe]] [[default=yes]]
--enable-clock_gettime use clock_gettime() instead of gettimeofday() on --enable-clock_gettime use clock_gettime() instead of gettimeofday() on
UNIX [[default=yes]] UNIX [[default=yes]]
--enable-rpath use an rpath when linking SDL [[default=yes]] --enable-rpath use an rpath when linking SDL [[default=yes]]
@ -24105,20 +24105,16 @@ CheckHIDAPI()
{ {
# The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers, # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
# so we'll just use libusb when it's available. # so we'll just use libusb when it's available.
#
# libusb does not support iOS, so we default to yes on iOS.
# TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
skiplibusb=no
case "$host" in case "$host" in
*-*-cygwin* | *-*-mingw32* | arm*-apple-darwin* | *-ios-* ) # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
*-*-cygwin* | *-*-mingw32* )
skiplibusb=yes skiplibusb=yes
;; ;;
esac # libusb does not support iOS
arm*-apple-darwin* | *-ios-* )
# On the other hand, *BSD specifically uses libusb only, so we make a skiplibusb=yes
# special case just for them. ;;
onlylibusb=no # On the other hand, *BSD specifically uses libusb only
case "$host" in
*-*-*bsd* ) *-*-*bsd* )
onlylibusb=yes onlylibusb=yes
;; ;;
@ -24128,15 +24124,9 @@ CheckHIDAPI()
if test "${enable_hidapi+set}" = set; then : if test "${enable_hidapi+set}" = set; then :
enableval=$enable_hidapi; enableval=$enable_hidapi;
else else
enable_hidapi=maybe enable_hidapi=yes
fi fi
hidapi_support=no
if test x$enable_hidapi = xmaybe; then
enable_hidapi=$skiplibusb
fi
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
if test x$skiplibusb = xyes; then if test x$skiplibusb = xyes; then
hidapi_support=yes hidapi_support=yes
@ -24221,12 +24211,10 @@ fi
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
if test x$have_libusb_h = xyes; then if test x$have_libusb_h = xyes; then
hidapi_support=yes hidapi_support=yes
elif test x$onlylibusb = xno; then elif test x$onlylibusb = xyes; then
case "$host" in hidapi_support=no
*-*-darwin* ) else
hidapi_support=yes hidapi_support=yes
;;
esac
fi fi
fi fi
@ -24237,17 +24225,11 @@ $as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi" EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c" SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
if test x$skiplibusb = xno; then if test x$have_libusb_h = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
if test x$onlylibusb = xyes; then if test x$onlylibusb = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c" SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS" EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
elif test x$have_libusb_h != xyes ; then
case "$host" in
*-*-darwin* )
SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
;;
esac
else else
if test x$have_loadso != xyes; then if test x$have_loadso != xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&5
@ -24273,6 +24255,15 @@ cat >>confdefs.h <<_ACEOF
_ACEOF _ACEOF
fi fi
else
case "$host" in
*-*-cygwin* | *-*-mingw32* )
SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
;;
*-*-darwin* )
SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
;;
esac
fi fi
fi fi
@ -24778,10 +24769,6 @@ $as_echo "#define SDL_JOYSTICK_WINMM 1" >>confdefs.h
fi fi
SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c" SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
have_joystick=yes have_joystick=yes
# TODO: Remove this block once SDL_hidapi.c supports Windows!
if test x$hidapi_support = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
fi
fi fi
if test x$enable_haptic = xyes; then if test x$enable_haptic = xyes; then
if test x$have_dinput = xyes -o x$have_xinput = xyes; then if test x$have_dinput = xyes -o x$have_xinput = xyes; then

View File

@ -3197,34 +3197,24 @@ CheckHIDAPI()
{ {
# The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers, # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
# so we'll just use libusb when it's available. # so we'll just use libusb when it's available.
#
# libusb does not support iOS, so we default to yes on iOS.
# TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
skiplibusb=no
case "$host" in case "$host" in
*-*-cygwin* | *-*-mingw32* | arm*-apple-darwin* | *-ios-* ) # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
*-*-cygwin* | *-*-mingw32* )
skiplibusb=yes skiplibusb=yes
;; ;;
esac # libusb does not support iOS
arm*-apple-darwin* | *-ios-* )
# On the other hand, *BSD specifically uses libusb only, so we make a skiplibusb=yes
# special case just for them. ;;
onlylibusb=no # On the other hand, *BSD specifically uses libusb only
case "$host" in
*-*-*bsd* ) *-*-*bsd* )
onlylibusb=yes onlylibusb=yes
;; ;;
esac esac
AC_ARG_ENABLE(hidapi, AC_ARG_ENABLE(hidapi,
AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=maybe]]]), AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=yes]]]),
, enable_hidapi=maybe) , enable_hidapi=yes)
hidapi_support=no
if test x$enable_hidapi = xmaybe; then
enable_hidapi=$skiplibusb
fi
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
if test x$skiplibusb = xyes; then if test x$skiplibusb = xyes; then
hidapi_support=yes hidapi_support=yes
@ -3236,12 +3226,10 @@ AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[d
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
if test x$have_libusb_h = xyes; then if test x$have_libusb_h = xyes; then
hidapi_support=yes hidapi_support=yes
elif test x$onlylibusb = xno; then elif test x$onlylibusb = xyes; then
case "$host" in hidapi_support=no
*-*-darwin* ) else
hidapi_support=yes hidapi_support=yes
;;
esac
fi fi
fi fi
@ -3250,17 +3238,11 @@ AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[d
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi" EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c" SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
if test x$skiplibusb = xno; then if test x$have_libusb_h = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
if test x$onlylibusb = xyes; then if test x$onlylibusb = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c" SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS" EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
elif test x$have_libusb_h != xyes ; then
case "$host" in
*-*-darwin* )
SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
;;
esac
else else
if test x$have_loadso != xyes; then if test x$have_loadso != xyes; then
AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libusb loading]) AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libusb loading])
@ -3281,6 +3263,15 @@ AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[d
fi fi
AC_DEFINE_UNQUOTED(SDL_LIBUSB_DYNAMIC, "$libusb_lib", [ ]) AC_DEFINE_UNQUOTED(SDL_LIBUSB_DYNAMIC, "$libusb_lib", [ ])
fi fi
else
case "$host" in
*-*-cygwin* | *-*-mingw32* )
SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
;;
*-*-darwin* )
SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
;;
esac
fi fi
fi fi
@ -3640,10 +3631,6 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
fi fi
SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c" SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
have_joystick=yes have_joystick=yes
# TODO: Remove this block once SDL_hidapi.c supports Windows!
if test x$hidapi_support = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
fi
fi fi
if test x$enable_haptic = xyes; then if test x$enable_haptic = xyes; then
if test x$have_dinput = xyes -o x$have_xinput = xyes; then if test x$have_dinput = xyes -o x$have_xinput = xyes; then