Fixed bug 2149 - Don't search for libusbhid except on BSD

Joseph Carter

There's a whole set of configure tests for BSD's libusbhid, and they only matter on BSD.  However, if you have the library on Linux, it gets pulled in as library bloat.  And it's bloat of the highest order since not a single function call to the library is ever made unless you're on a *BSD.
This commit is contained in:
Sam Lantinga 2013-10-13 19:49:45 -07:00
parent a7b2db05cd
commit 2337a684b3
3 changed files with 251 additions and 242 deletions

228
configure vendored
View File

@ -21634,8 +21634,10 @@ $as_echo "#define SDL_LOADSO_DLOPEN 1" >>confdefs.h
CheckUSBHID()
{
if test x$enable_joystick = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5
case "$host" in
*-*-*bsd*)
if test x$enable_joystick = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5
$as_echo_n "checking for hid_init in -lusbhid... " >&6; }
if ${ac_cv_lib_usbhid_hid_init+:} false; then :
$as_echo_n "(cached) " >&6
@ -21675,34 +21677,34 @@ if test "x$ac_cv_lib_usbhid_hid_init" = xyes; then :
have_libusbhid=yes
fi
if test x$have_libusbhid = xyes; then
ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default"
if test x$have_libusbhid = xyes; then
ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default"
if test "x$ac_cv_header_usbhid_h" = xyes; then :
USB_CFLAGS="-DHAVE_USBHID_H"
fi
ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default"
ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default"
if test "x$ac_cv_header_libusbhid_h" = xyes; then :
USB_CFLAGS="-DHAVE_LIBUSBHID_H"
fi
USB_LIBS="$USB_LIBS -lusbhid"
else
ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default"
USB_LIBS="$USB_LIBS -lusbhid"
else
ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default"
if test "x$ac_cv_header_usb_h" = xyes; then :
USB_CFLAGS="-DHAVE_USB_H"
fi
ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
if test "x$ac_cv_header_libusb_h" = xyes; then :
USB_CFLAGS="-DHAVE_LIBUSB_H"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5
$as_echo_n "checking for hid_init in -lusb... " >&6; }
if ${ac_cv_lib_usb_hid_init+:} false; then :
$as_echo_n "(cached) " >&6
@ -21742,43 +21744,43 @@ if test "x$ac_cv_lib_usb_hid_init" = xyes; then :
USB_LIBS="$USB_LIBS -lusb"
fi
fi
fi
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $USB_CFLAGS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $USB_CFLAGS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5
$as_echo_n "checking for usbhid... " >&6; }
have_usbhid=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
have_usbhid=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
int
main ()
{
struct report_desc *repdesc;
struct usb_ctl_report *repbuf;
hid_kind_t hidkind;
struct report_desc *repdesc;
struct usb_ctl_report *repbuf;
hid_kind_t hidkind;
;
return 0;
@ -21786,45 +21788,45 @@ main ()
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_usbhid=yes
have_usbhid=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5
$as_echo "$have_usbhid" >&6; }
if test x$have_usbhid = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5
if test x$have_usbhid = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5
$as_echo_n "checking for ucr_data member of usb_ctl_report... " >&6; }
have_usbhid_ucr_data=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
have_usbhid_ucr_data=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
int
main ()
{
struct usb_ctl_report buf;
if (buf.ucr_data) { }
struct usb_ctl_report buf;
if (buf.ucr_data) { }
;
return 0;
@ -21832,47 +21834,47 @@ main ()
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_usbhid_ucr_data=yes
have_usbhid_ucr_data=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test x$have_usbhid_ucr_data = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5
if test x$have_usbhid_ucr_data = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5
$as_echo "$have_usbhid_ucr_data" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5
$as_echo_n "checking for new usbhid API... " >&6; }
have_usbhid_new=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
have_usbhid_new=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
#include <bus/usb/usb.h>
#include <bus/usb/usbhid.h>
#else
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
#include <bus/usb/usb.h>
#include <bus/usb/usbhid.h>
#else
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
int
main ()
{
report_desc_t d;
hid_start_parse(d, 1, 1);
report_desc_t d;
hid_start_parse(d, 1, 1);
;
return 0;
@ -21880,29 +21882,29 @@ main ()
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_usbhid_new=yes
have_usbhid_new=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test x$have_usbhid_new = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5
if test x$have_usbhid_new = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5
$as_echo "$have_usbhid_new" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5
$as_echo_n "checking for struct joystick in machine/joystick.h... " >&6; }
have_machine_joystick=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
have_machine_joystick=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <machine/joystick.h>
#include <machine/joystick.h>
int
main ()
{
struct joystick t;
struct joystick t;
;
return 0;
@ -21910,28 +21912,30 @@ main ()
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_machine_joystick=yes
have_machine_joystick=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test x$have_machine_joystick = xyes; then
if test x$have_machine_joystick = xyes; then
$as_echo "#define SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5
$as_echo "$have_machine_joystick" >&6; }
$as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
have_joystick=yes
fi
CFLAGS="$save_CFLAGS"
fi
SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
have_joystick=yes
fi
CFLAGS="$save_CFLAGS"
fi
;;
esac
}
CheckClockGettime()

View File

@ -2189,138 +2189,142 @@ AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[de
dnl Check for the usbhid(3) library on *BSD
CheckUSBHID()
{
if test x$enable_joystick = xyes; then
AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
if test x$have_libusbhid = xyes; then
AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
USB_LIBS="$USB_LIBS -lusbhid"
else
AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
fi
case "$host" in
*-*-*bsd*)
if test x$enable_joystick = xyes; then
AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
if test x$have_libusbhid = xyes; then
AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
USB_LIBS="$USB_LIBS -lusbhid"
else
AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
fi
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $USB_CFLAGS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $USB_CFLAGS"
AC_MSG_CHECKING(for usbhid)
have_usbhid=no
AC_TRY_COMPILE([
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
],[
struct report_desc *repdesc;
struct usb_ctl_report *repbuf;
hid_kind_t hidkind;
],[
have_usbhid=yes
])
AC_MSG_RESULT($have_usbhid)
AC_MSG_CHECKING(for usbhid)
have_usbhid=no
AC_TRY_COMPILE([
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
],[
struct report_desc *repdesc;
struct usb_ctl_report *repbuf;
hid_kind_t hidkind;
],[
have_usbhid=yes
])
AC_MSG_RESULT($have_usbhid)
if test x$have_usbhid = xyes; then
AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
have_usbhid_ucr_data=no
AC_TRY_COMPILE([
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
],[
struct usb_ctl_report buf;
if (buf.ucr_data) { }
],[
have_usbhid_ucr_data=yes
])
if test x$have_usbhid_ucr_data = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
if test x$have_usbhid = xyes; then
AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
have_usbhid_ucr_data=no
AC_TRY_COMPILE([
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
],[
struct usb_ctl_report buf;
if (buf.ucr_data) { }
],[
have_usbhid_ucr_data=yes
])
if test x$have_usbhid_ucr_data = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
fi
AC_MSG_RESULT($have_usbhid_ucr_data)
AC_MSG_CHECKING(for new usbhid API)
have_usbhid_new=no
AC_TRY_COMPILE([
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
#include <bus/usb/usb.h>
#include <bus/usb/usbhid.h>
#else
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
],[
report_desc_t d;
hid_start_parse(d, 1, 1);
],[
have_usbhid_new=yes
])
if test x$have_usbhid_new = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
fi
AC_MSG_RESULT($have_usbhid_new)
AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
have_machine_joystick=no
AC_TRY_COMPILE([
#include <machine/joystick.h>
],[
struct joystick t;
],[
have_machine_joystick=yes
])
if test x$have_machine_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
fi
AC_MSG_RESULT($have_machine_joystick)
AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
have_joystick=yes
fi
CFLAGS="$save_CFLAGS"
fi
AC_MSG_RESULT($have_usbhid_ucr_data)
AC_MSG_CHECKING(for new usbhid API)
have_usbhid_new=no
AC_TRY_COMPILE([
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
#include <bus/usb/usb.h>
#include <bus/usb/usbhid.h>
#else
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
],[
report_desc_t d;
hid_start_parse(d, 1, 1);
],[
have_usbhid_new=yes
])
if test x$have_usbhid_new = xyes; then
USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
fi
AC_MSG_RESULT($have_usbhid_new)
AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
have_machine_joystick=no
AC_TRY_COMPILE([
#include <machine/joystick.h>
],[
struct joystick t;
],[
have_machine_joystick=yes
])
if test x$have_machine_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
fi
AC_MSG_RESULT($have_machine_joystick)
AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
have_joystick=yes
fi
CFLAGS="$save_CFLAGS"
fi
;;
esac
}
dnl Check for clock_gettime()

3
test/configure vendored
View File

@ -586,8 +586,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
SDL_TTF_LIB
XLIB
GLLIB
GLESLIB
GLLIB
CPP
XMKMF
SDL_CONFIG
@ -3874,6 +3874,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5
$as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; }
if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then :