summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael2009-10-08 17:21:15 -0400
committerMichael2009-10-08 17:21:15 -0400
commit82d944f7eecb86210e6a36cf5218a0fec133e3d6 (patch)
tree287543336043604422dc1ba75d0938c1b74551eb
parent30e016dd9cf7c148d3119f01ba7dd4d6474efa50 (diff)
downloadgnuradio-82d944f7eecb86210e6a36cf5218a0fec133e3d6.tar.gz
gnuradio-82d944f7eecb86210e6a36cf5218a0fec133e3d6.tar.bz2
gnuradio-82d944f7eecb86210e6a36cf5218a0fec133e3d6.zip
augmented search for libusb
-rw-r--r--config/usrp_libusb.m492
-rw-r--r--gr-usrp/src/Makefile.am1
-rw-r--r--usrp/host/apps/Makefile.am4
3 files changed, 71 insertions, 26 deletions
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
])
diff --git a/gr-usrp/src/Makefile.am b/gr-usrp/src/Makefile.am
index 0835e2b9b..3d1cc1754 100644
--- a/gr-usrp/src/Makefile.am
+++ b/gr-usrp/src/Makefile.am
@@ -37,6 +37,7 @@ AM_CPPFLAGS = \
$(STD_DEFINES_AND_INCLUDES) \
$(PYTHON_CPPFLAGS) \
$(USRP_INCLUDES) \
+ $(USB_INCLUDES) \
$(WITH_INCLUDES)
lib_LTLIBRARIES = \
diff --git a/usrp/host/apps/Makefile.am b/usrp/host/apps/Makefile.am
index b0c21d55f..8aa361b22 100644
--- a/usrp/host/apps/Makefile.am
+++ b/usrp/host/apps/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2003,2006,2008 Free Software Foundation, Inc.
+# Copyright 2003,2006,2008,2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -22,7 +22,7 @@
include $(top_srcdir)/Makefile.common
AM_CPPFLAGS = $(USRP_INCLUDES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) \
- $(WITH_INCLUDES)
+ $(USB_INCLUDES) $(WITH_INCLUDES)
bin_PROGRAMS = \
usrper \