From 2337a684b363dfc4ba3d6f2773e029a3301cfdad Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 13 Oct 2013 19:49:45 -0700 Subject: [PATCH] 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. --- configure | 228 +++++++++++++++++++++--------------------- configure.in | 262 +++++++++++++++++++++++++------------------------ test/configure | 3 +- 3 files changed, 251 insertions(+), 242 deletions(-) diff --git a/configure b/configure index dae19ac1c..ba2489430 100755 --- a/configure +++ b/configure @@ -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 - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #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 - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #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 - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - #include - #include - #else - #include - #include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + #include + #include + #else + #include + #include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #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 + #include 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() diff --git a/configure.in b/configure.in index 890503cda..5c56f0080 100644 --- a/configure.in +++ b/configure.in @@ -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 - - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $USB_CFLAGS" + 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" - AC_MSG_CHECKING(for usbhid) - have_usbhid=no - AC_TRY_COMPILE([ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #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 + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #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 - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #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 + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #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 + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + #include + #include + #else + #include + #include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #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 + ],[ + 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 - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - #include - #include - #else - #include - #include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #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 - ],[ - 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() diff --git a/test/configure b/test/configure index 57da5548a..94a2f1394 100755 --- a/test/configure +++ b/test/configure @@ -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 :