+ dnl Check for the function in the library. Similar to
+ dnl AC_CHECK_LIB, but doesn't append to known \#defines.
+ AC_MSG_CHECKING([$libusb_name for function $usb_lib_func in library $usb_lib_name])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ char $usb_lib_func ();
+ ]], [[return $usb_lib_func ();]])],
+ [libusbok=yes],[libusbok=no])
+ AC_MSG_RESULT([$libusbok])
+ case "$host_os" in
+ cygwin* | mingw*)
+ USB_LIBS="$LIBS"
+ ;;
+ *) ;;
+ esac
+ LIBS="$save_LIBS"
+ AC_LANG_POP(C)
+
+ if test $libusbok = yes; then
+ if test ${libusb_name} != "libusb-1.0"; then
+ dnl PKGCONFIG found a legacy version of libusb; make sure the
+ dnl variable _usb_debug is available in the found library
+ AC_LANG_PUSH(C)
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$USB_INCLUDES"
+ save_LIBS="$LIBS"
+ LIBS="$USB_LIBS"
+ AC_MSG_CHECKING([$libusb_name for symbol usb_debug in library $usb_lib_name])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ extern int usb_debug;]],
+ [[usb_debug = 0;]])],
+ [libusbok=yes],[libusbok=no])
+ AC_MSG_RESULT([$libusbok])
+ LIBS="$save_LIBS"
+ CPPFLAGS="$save_CPPFLAGS"
+ AC_LANG_POP(C)
+ fi
+ fi
+ fi
+ fi
+ dnl if everything checks out OK, finish up
+ if test $libusbok = yes; then
+ LIBUSB_PKG_CONFIG_NAME="${libusb_name}"
+ break
+ else
+ dnl something wasn't found in this LIBUSB version.
+ dnl HACK: clear cache variables for header and library
+ unset USB_INCLUDEDIR
+ unset USB_INCLUDES
+ unset USB_LIBS
+ unset $as_ac_Header
+ unset $as_ac_Lib
+ fi
+ done
+
+ if test $libusbok = yes; then
+ dnl final error checking, mostly to create #define's