Fixed building on Mac OS X without libusb

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

59
configure vendored
View File

@ -1675,7 +1675,7 @@ Optional Features:
--enable-wasapi use the Windows WASAPI audio driver [[default=yes]]
--enable-sdl-dlopen use dlopen for shared object loading [[default=yes]]
--enable-hidapi use HIDAPI for low level joystick drivers
[[default=maybe]]
[[default=yes]]
--enable-clock_gettime use clock_gettime() instead of gettimeofday() on
UNIX [[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,
# 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
*-*-cygwin* | *-*-mingw32* | arm*-apple-darwin* | *-ios-* )
# TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
*-*-cygwin* | *-*-mingw32* )
skiplibusb=yes
;;
esac
# On the other hand, *BSD specifically uses libusb only, so we make a
# special case just for them.
onlylibusb=no
case "$host" in
# libusb does not support iOS
arm*-apple-darwin* | *-ios-* )
skiplibusb=yes
;;
# On the other hand, *BSD specifically uses libusb only
*-*-*bsd* )
onlylibusb=yes
;;
@ -24128,15 +24124,9 @@ CheckHIDAPI()
if test "${enable_hidapi+set}" = set; then :
enableval=$enable_hidapi;
else
enable_hidapi=maybe
enable_hidapi=yes
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$skiplibusb = xyes; then
hidapi_support=yes
@ -24221,12 +24211,10 @@ fi
CFLAGS="$save_CFLAGS"
if test x$have_libusb_h = xyes; then
hidapi_support=yes
elif test x$onlylibusb = xno; then
case "$host" in
*-*-darwin* )
hidapi_support=yes
;;
esac
elif test x$onlylibusb = xyes; then
hidapi_support=no
else
hidapi_support=yes
fi
fi
@ -24237,17 +24225,11 @@ $as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
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"
if test x$onlylibusb = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
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
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
@ -24273,6 +24255,15 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
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
@ -24778,10 +24769,6 @@ $as_echo "#define SDL_JOYSTICK_WINMM 1" >>confdefs.h
fi
SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
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
if test x$enable_haptic = 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,
# 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
*-*-cygwin* | *-*-mingw32* | arm*-apple-darwin* | *-ios-* )
# TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
*-*-cygwin* | *-*-mingw32* )
skiplibusb=yes
;;
esac
# On the other hand, *BSD specifically uses libusb only, so we make a
# special case just for them.
onlylibusb=no
case "$host" in
# libusb does not support iOS
arm*-apple-darwin* | *-ios-* )
skiplibusb=yes
;;
# On the other hand, *BSD specifically uses libusb only
*-*-*bsd* )
onlylibusb=yes
;;
esac
AC_ARG_ENABLE(hidapi,
AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=maybe]]]),
, enable_hidapi=maybe)
hidapi_support=no
if test x$enable_hidapi = xmaybe; then
enable_hidapi=$skiplibusb
fi
AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=yes]]]),
, enable_hidapi=yes)
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
if test x$skiplibusb = xyes; then
hidapi_support=yes
@ -3236,12 +3226,10 @@ AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[d
CFLAGS="$save_CFLAGS"
if test x$have_libusb_h = xyes; then
hidapi_support=yes
elif test x$onlylibusb = xno; then
case "$host" in
*-*-darwin* )
hidapi_support=yes
;;
esac
elif test x$onlylibusb = xyes; then
hidapi_support=no
else
hidapi_support=yes
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"
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"
if test x$onlylibusb = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
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
if test x$have_loadso != xyes; then
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
AC_DEFINE_UNQUOTED(SDL_LIBUSB_DYNAMIC, "$libusb_lib", [ ])
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
@ -3640,10 +3631,6 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
fi
SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
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
if test x$enable_haptic = xyes; then
if test x$have_dinput = xyes -o x$have_xinput = xyes; then