X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=config%2Fusrp_libusb.m4;h=6666eaedf747a177761da1a92b82c642092a9854;hb=82d944f7eecb86210e6a36cf5218a0fec133e3d6;hp=ab8305ff09fe887858e3803d6e262fbea8d5e518;hpb=937b719d2e57d0497293d603da10cac2532346f6;p=debian%2Fgnuradio diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index ab8305ff..6666eaed 100644 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -1,51 +1,112 @@ -# Check for libusb support. -*- Autoconf -*- - -# Copyright 2003 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Boston, MA -# 02110-1301, USA. - -AC_DEFUN([USRP_LIBUSB], -[ - AC_LANG_PUSH(C) - - libusbok=yes - AC_CHECK_HEADERS([usb.h], - [], - [libusbok=no, - AC_MSG_RESULT([USRP requires libusb. usb.h not found. See http://libusb.sf.net])] - ) - - save_LIBS="$LIBS" - case "$host_os" in - darwin*) LIBS="$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://libusb.sf.net])] - ) - LIBS="$save_LIBS" - - AC_LANG_POP - - if test $libusbok = yes; then - AC_SUBST(USB_LIBS) - ifelse([$1], , :, [$1]) - else - ifelse([$2], , :, [$2]) - fi +dnl Copyright 2003,2008,2009 Free Software Foundation, Inc. +dnl +dnl This file is part of GNU Radio +dnl +dnl GNU Radio is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3, or (at your option) +dnl any later version. +dnl +dnl GNU Radio is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with GNU Radio; see the file COPYING. If not, write to +dnl the Free Software Foundation, Inc., 51 Franklin Street, +dnl Boston, MA 02110-1301, USA. + +# $1 is $req_libusb1: +# yes : check libusb-1.0 +# no : check libusb-0.12 +# "" : check libusb-0.12 + + +AC_DEFUN([USRP_LIBUSB], [ + 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, [ + 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 + + 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) + save_LIBS="$LIBS" + case "$host_os" in + darwin*) + USB_LIBS="$USB_LIBS -lIOKit" + ;; + *) ;; + 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 + fi + if test $libusbok = yes; then + AC_SUBST(USB_LIBS) + ifelse([$2], , :, [$2]) + else + USB_INCLUDES= + USB_LIBS= + ifelse([$3], , :, [$3]) + fi ])