-if test $build_usb = yes -o $build_usb_ng = yes; then
- if test $check_libusb0 = no -a $build_usb_ng = yes; then
- AC_CHECK_HEADER([libusb-1.0/libusb.h],
- [AC_DEFINE(HAVE_LIBUSB1, 1, [Define if you have libusb-1.0]) check_libusb0=no use_libusb1=yes ],
- [ check_libusb0=yes use_libusb1=no ])
- fi
+if test $need_usb = yes -o $need_usb_ng = yes; then
+ AC_CHECK_HEADER([libusb-1.0/libusb.h], [
+ AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
+ use_libusb1=yes
+ AC_SEARCH_LIBS([libusb_error_name], [usb-1.0],
+ [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
+ [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
+ ], [
+ if test $need_usb_ng = yes; then
+ AC_MSG_ERROR([libusb-1.x is required for some driver(s) you've selected])
+ else
+ AC_MSG_WARN([Trying legacy libusb-0.1 as a fallback, consider installing libusb-1 instead])
+ need_usb0=yes
+ fi
+ ])
+fi