From af2a91f82eb6b5acedc0ea04dd15b0fd1906c14a Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 25 Nov 2023 20:40:03 +0100 Subject: [PATCH] check for HAVE_LIBUSB_OPTION_NO_DEVICE_DISCOVERY enum https://github.com/gphoto/gphoto2/issues/614 --- libgphoto2_port/configure.ac | 19 +++++++++++++++++++ libgphoto2_port/libusb1/libusb1.c | 2 ++ 2 files changed, 21 insertions(+) diff --git a/libgphoto2_port/configure.ac b/libgphoto2_port/configure.ac index ef57b2795c..9dd7fcbaac 100644 --- a/libgphoto2_port/configure.ac +++ b/libgphoto2_port/configure.ac @@ -388,7 +388,26 @@ GP_CHECK_LIBRARY([LIBUSB1],[libusb-1.0],[>= 1.0.0], AC_DEFINE([HAVE_LIBUSB_WRAP_SYS_DEVICE], [1], [Define if libusb-1.0 has libusb_wrap_sys_device]) ]) + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $LIBUSB1_CFLAGS" + + AC_COMPILE_IFELSE([dnl + AC_LANG_PROGRAM([[ + # include "libusb.h" + ]], [[ + enum libusb_option opt = LIBUSB_OPTION_NO_DEVICE_DISCOVERY; + ]])dnl + ], [dnl + AC_DEFINE([HAVE_LIBUSB_OPTION_NO_DEVICE_DISCOVERY], [1], + [whether we have LIBUSB_OPTION_NO_DEVICE_DISCOVERY]) + AC_MSG_RESULT([yes]) + ], [dnl + AC_MSG_RESULT([no]) + ]) + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" ], [], [default-on], [http://libusb.sourceforge.net/] diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c index 5d19d5adda..14e35930f9 100644 --- a/libgphoto2_port/libusb1/libusb1.c +++ b/libgphoto2_port/libusb1/libusb1.c @@ -131,7 +131,9 @@ static int has_external_fd() return 0; if(external_sys_device.h) return 1; +#ifdef HAVE_LIBUSB_OPTION_NO_DEVICE_DISCOVERY libusb_set_option(NULL,LIBUSB_OPTION_NO_DEVICE_DISCOVERY,NULL); +#endif C_LIBUSB (libusb_init (&external_sys_device.ctx), GP_ERROR_IO); LOG_ON_LIBUSB_E(libusb_wrap_sys_device(external_sys_device.ctx,gp_port_usb_get_sys_device(),&external_sys_device.h)); external_sys_device.d = libusb_get_device(external_sys_device.h);