Skip to content

Commit

Permalink
Check whether we have -lusb-1.0 and it has libusb_init().
Browse files Browse the repository at this point in the history
Don't just check for the libusb header file - apparently at least some
Linux distributions can't install both the 32-bit and 64-bit developer
versions of the libusb library, so you might have the libusb header, and
the library for one bit-width, but not the library for the other
bit-width, so the configure would succeed for the other bit-width but
the build would fail.
  • Loading branch information
guyharris committed Jul 8, 2014
1 parent f209b03 commit e925053
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
40 changes: 37 additions & 3 deletions configure
Expand Up @@ -8124,8 +8124,43 @@ fi
if test "x$enable_canusb" != "xno" ; then
case "$host_os" in
linux*)
ac_fn_c_check_header_mongrel "$LINENO" "libusb-1.0/libusb.h" "ac_cv_header_libusb_1_0_libusb_h" "$ac_includes_default"
if test "x$ac_cv_header_libusb_1_0_libusb_h" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5
$as_echo_n "checking for libusb_init in -lusb-1.0... " >&6; }
if ${ac_cv_lib_usb_1_0_libusb_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lusb-1.0 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char libusb_init ();
int
main ()
{
return libusb_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_usb_1_0_libusb_init=yes
else
ac_cv_lib_usb_1_0_libusb_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_1_0_libusb_init" >&5
$as_echo "$ac_cv_lib_usb_1_0_libusb_init" >&6; }
if test "x$ac_cv_lib_usb_1_0_libusb_init" = xyes; then :
$as_echo "#define PCAP_SUPPORT_CANUSB 1" >>confdefs.h
Expand All @@ -8141,7 +8176,6 @@ $as_echo "$as_me: canusb sniffing is not supported; install libusb1.0 lib devel
fi
;;
*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: no canusb support implemented for $host_os" >&5
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -1528,7 +1528,7 @@ if test "x$enable_canusb" != "xno" ; then
dnl check for canusb support
case "$host_os" in
linux*)
AC_CHECK_HEADER(libusb-1.0/libusb.h,
AC_CHECK_LIB(usb-1.0, libusb_init,
[
AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb])
CANUSB_SRC=pcap-canusb-linux.c
Expand Down

0 comments on commit e925053

Please sign in to comment.