From 82d944f7eecb86210e6a36cf5218a0fec133e3d6 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 8 Oct 2009 17:21:15 -0400 Subject: augmented search for libusb --- config/usrp_libusb.m4 | 92 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 24 deletions(-) (limited to 'config') diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index 0c271e0f3..6666eaedf 100644 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -24,45 +24,89 @@ dnl Boston, MA 02110-1301, USA. AC_DEFUN([USRP_LIBUSB], [ - libusbok=yes + dnl Use PKGCONFIG to check for packages first, then check to + dnl make sure the USB_* variables work (whether from PKGCONFIG + dnl or overridden by the user) + + libusbok=no have_libusb1=no - if test [x]$1 = xyes; then - PKG_CHECK_MODULES(USB, libusb-1.0, [have_libusb1=yes], [ - AC_LANG_PUSH(C) - AC_CHECK_HEADERS([libusb-1.0/libusb.h], [have_libusb1=yes], - [libusbok=no; AC_MSG_RESULT([USRP requires libusb-1.0. libusb.h not found. See http://www.libusb.org])]) - AC_SEARCH_LIBS(libusb_bulk_transfer, [usb-1.0], [USB_LIBS="$LIBS"], - [libusbok=no; AC_MSG_RESULT([USRP requires libusb-1.0. libusb_bulk_transfer not found. See http://www.libusb.org])]) - AC_LANG_POP + if test x$1 = xyes; then + PKG_CHECK_MODULES(USB, libusb-1.0, [ + libusbok=yes + have_libusb1=yes + usb_header='libusb-1.0/libusb.h' + usb_lib_func='libusb_bulk_transfer' + usb_lib_name='usb-1.0' ]) + fi + if test $libusbok = no; then + dnl not using libusb1, or PKGCONFIG check for libusb1 failed; + dnl see if legacy version is found. + dnl it might be installed under the name either 'libusb' or + dnl 'libusb-legacy'. check them in that order. + + dnl see if the pkgconfig module 'libusb' is available + PKG_CHECK_MODULES(USB, libusb, [libusbok=yes], [libusbok=no]) + dnl PKG_CHECK_MODULES does not work correctly when embedded + if test $libusbok = no; then + dnl if not, see if the pkgconfig module 'libusb-legacy' is available + PKG_CHECK_MODULES(USB, [libusb-legacy], [libusbok=yes], [libusbok=no]) + fi + if test $libusbok = yes; then + dnl if PKGCONFIG worked, set variables for further testing + usb_header='usb.h' + usb_lib_func='usb_bulk_write' + usb_lib_name='usb' + fi + fi + if test $libusbok = no; then + AC_MSG_RESULT([USRP requires libusb, which was not found. See http://www.libusb.org]) else - PKG_CHECK_MODULES(USB, libusb, [], [ + + dnl either some pkgconfig LIBUSB* variant was found, or USB_* + dnl variables were overridden by the user as arguments to configure. + dnl either way, check the USB_* variables to make sure they work + + AC_LANG_PUSH(C) + save_CPPFLAGS="$CPPFLAGS" + if test x$USB_INCLUDEDIR != x; then + USB_INCLUDES="-I$USB_INCLUDEDIR" + CPPFLAGS="$CPPFLAGS $USB_INCLUDES" + AC_SUBST(USB_INCLUDES) + fi + AC_CHECK_HEADERS([$usb_header], [], [libusbok=no]) + CPPFLAGS="$save_CPPFLAGS" + AC_LANG_POP(C) + + if test $libusbok = no; then + AC_MSG_RESULT([USRP requires libusb header '$usb_header' which was not found or was not usable. See http://www.libusb.org]) + else + + dnl found the header; now make sure the library is OK + AC_LANG_PUSH(C) - AC_CHECK_HEADERS([usb.h], [], - [libusbok=no; AC_MSG_RESULT([USRP requires libusb. usb.h not found. See http://www.libusb.org])]) save_LIBS="$LIBS" case "$host_os" in darwin*) - LIBS="$LIBS -lIOKit" + USB_LIBS="$USB_LIBS -lIOKit" ;; *) ;; esac - - AC_SEARCH_LIBS(usb_bulk_write, [usb], [USB_LIBS="$LIBS"], - [libusbok=no; AC_MSG_RESULT([USRP requires libusb. usb_bulk_write not found. See http://www.libusb.org])]) + LIBS="$LIBS $USB_LIBS" + AC_CHECK_LIB([$usb_lib_name], [$usb_lib_func], [], [ + libusbok=no + AC_MSG_RESULT([USRP requires library '$usb_lib_name' with function '$usb_lib_func', which was either not found or was not usable. See http://www.libusb.org]) + ]) LIBS="$save_LIBS" - AC_LANG_POP - ]) - fi - - if test x$libusbok = xyes; then - if test x$USB_INCLUDEDIR != x; then - USB_INCLUDES="-I$USB_INCLUDEDIR" - AC_SUBST(USB_INCLUDES) + AC_LANG_POP(C) fi + fi + if test $libusbok = yes; then AC_SUBST(USB_LIBS) ifelse([$2], , :, [$2]) else + USB_INCLUDES= + USB_LIBS= ifelse([$3], , :, [$3]) fi ]) -- cgit From c97d1b08209f09a121950386f7af360aac26cc1b Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 12 Oct 2009 11:05:03 -0400 Subject: merged updated libusb checks with older version --- config/usrp_libusb.m4 | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'config') diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index 6666eaedf..b5653f1cf 100644 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -38,12 +38,11 @@ AC_DEFUN([USRP_LIBUSB], [ usb_lib_func='libusb_bulk_transfer' usb_lib_name='usb-1.0' ]) - fi - if test $libusbok = no; then - dnl not using libusb1, or PKGCONFIG check for libusb1 failed; - dnl see if legacy version is found. + else + dnl not using libusb1 (for now); see if legacy version is found. dnl it might be installed under the name either 'libusb' or - dnl 'libusb-legacy'. check them in that order. + dnl 'libusb-legacy', or just available via the + dnl user's shell environment dnl see if the pkgconfig module 'libusb' is available PKG_CHECK_MODULES(USB, libusb, [libusbok=yes], [libusbok=no]) @@ -52,20 +51,23 @@ AC_DEFUN([USRP_LIBUSB], [ dnl if not, see if the pkgconfig module 'libusb-legacy' is available PKG_CHECK_MODULES(USB, [libusb-legacy], [libusbok=yes], [libusbok=no]) fi - if test $libusbok = yes; then - dnl if PKGCONFIG worked, set variables for further testing - usb_header='usb.h' - usb_lib_func='usb_bulk_write' - usb_lib_name='usb' - fi + dnl set variables for further testing + usb_header='usb.h' + usb_lib_func='usb_bulk_write' + usb_lib_name='usb' fi - if test $libusbok = no; then - AC_MSG_RESULT([USRP requires libusb, which was not found. See http://www.libusb.org]) - else + if test x$1 != xyes || test $have_libusb1 = yes; then + dnl Either (1) libusb1 was specified and found; or + dnl (2) libusb1 was not specified. + + dnl Verify that $usb_header is a valid header, and if so, + dnl then verify that $usb_lib_func can be found in the + dnl library $usb_lib_name. - dnl either some pkgconfig LIBUSB* variant was found, or USB_* - dnl variables were overridden by the user as arguments to configure. - dnl either way, check the USB_* variables to make sure they work + dnl If PKGCONFIG found variable USB_INCLUDEDIR, and it is + dnl not empty, use it for checking for $usb_header. + dnl Otherwise, maybe the user's shell environment is already + dnl configured to find this header. AC_LANG_PUSH(C) save_CPPFLAGS="$CPPFLAGS" @@ -83,6 +85,7 @@ AC_DEFUN([USRP_LIBUSB], [ else dnl found the header; now make sure the library is OK + dnl On Darwin, need to include the IOKit library. AC_LANG_PUSH(C) save_LIBS="$LIBS" -- cgit From f5ccf9d4391b6a9e9f64b42543d45a00d31475c3 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 12 Oct 2009 13:51:05 -0400 Subject: fix to restart libusbok checking for non-PKGCONFIG --- config/usrp_libusb.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index b5653f1cf..4347bfba3 100644 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -58,7 +58,8 @@ AC_DEFUN([USRP_LIBUSB], [ fi if test x$1 != xyes || test $have_libusb1 = yes; then dnl Either (1) libusb1 was specified and found; or - dnl (2) libusb1 was not specified. + dnl (2) libusb1 was not specified. Restart checking. + libusbok=yes dnl Verify that $usb_header is a valid header, and if so, dnl then verify that $usb_lib_func can be found in the -- cgit From 77a3e7e8f2940b8a86d80518ebd7d39365f2c5be Mon Sep 17 00:00:00 2001 From: Don Ward Date: Mon, 12 Oct 2009 17:58:32 -0400 Subject: usrp: Applied patch from Don Ward for Cygwin libusb Moved the case statement after the call to AC_CHECK_LIB Initialized LIBS="" before calling AC_CHECK_LIB --- config/usrp_libusb.m4 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) mode change 100644 => 100755 config/usrp_libusb.m4 (limited to 'config') diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 old mode 100644 new mode 100755 index 4347bfba3..6ed7f5e9f --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -90,17 +90,20 @@ AC_DEFUN([USRP_LIBUSB], [ AC_LANG_PUSH(C) save_LIBS="$LIBS" + LIBS="" + AC_CHECK_LIB([$usb_lib_name], [$usb_lib_func], [], [ + libusbok=no + AC_MSG_RESULT([USRP requires library '$usb_lib_name' with function '$usb_lib_func', which was either not found or was not usable. See http://www.libusb.org]) + ]) case "$host_os" in darwin*) USB_LIBS="$USB_LIBS -lIOKit" ;; + cygwin* | mingw*) + USB_LIBS="$LIBS" + ;; *) ;; esac - LIBS="$LIBS $USB_LIBS" - AC_CHECK_LIB([$usb_lib_name], [$usb_lib_func], [], [ - libusbok=no - AC_MSG_RESULT([USRP requires library '$usb_lib_name' with function '$usb_lib_func', which was either not found or was not usable. See http://www.libusb.org]) - ]) LIBS="$save_LIBS" AC_LANG_POP(C) fi -- cgit From 6b626de1518b3897f8707acd7b920f19cc15da94 Mon Sep 17 00:00:00 2001 From: Michael Dickens Date: Mon, 12 Oct 2009 21:18:40 -0400 Subject: usrp: Applied patch from Michael Dickens for Darwin libusb Update usrp_libusb.m4 to work on Darwin for both libusb-legacy and libusb1 --- config/usrp_libusb.m4 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index 6ed7f5e9f..428a57992 100755 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -91,14 +91,18 @@ AC_DEFUN([USRP_LIBUSB], [ AC_LANG_PUSH(C) save_LIBS="$LIBS" LIBS="" + case "$host_os" in + darwin*) + USB_LIBS="$USB_LIBS -lIOKit" + LIBS="$USB_LIBS" + ;; + *) ;; + esac AC_CHECK_LIB([$usb_lib_name], [$usb_lib_func], [], [ libusbok=no AC_MSG_RESULT([USRP requires library '$usb_lib_name' with function '$usb_lib_func', which was either not found or was not usable. See http://www.libusb.org]) ]) case "$host_os" in - darwin*) - USB_LIBS="$USB_LIBS -lIOKit" - ;; cygwin* | mingw*) USB_LIBS="$LIBS" ;; -- cgit