X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=config%2Fusrp_libusb.m4;h=251f7df10160f7e6a4963e62d1947fdd6df064f3;hb=f92f8aae6746fa8fad1d6721fe1a8583295b38e1;hp=9a019a46071f0294fd6526b2892858867c0a2bb8;hpb=7f32e69cf2d599e0c5462164500ac2337f4417a7;p=debian%2Fgnuradio diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 old mode 100644 new mode 100755 index 9a019a46..251f7df1 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -1,4 +1,4 @@ -dnl Copyright 2003,2008 Free Software Foundation, Inc. +dnl Copyright 2003,2008,2009 Free Software Foundation, Inc. dnl dnl This file is part of GNU Radio dnl @@ -18,144 +18,115 @@ 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 +# yes : check libusb-1.0 +# no : check libusb-0.12 +# "" : check libusb-0.12 AC_DEFUN([USRP_LIBUSB], [ - libusbok=yes - 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])]) + 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) - AC_SEARCH_LIBS(libusb_bulk_transfer, [usb], [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 + libusbok=no + have_libusb1=no + LIBUSB_PKG_CONFIG_NAME='' + 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' + LIBUSB_PKG_CONFIG_NAME='libusb-1.0' ]) else - PKG_CHECK_MODULES(USB, libusb, [], [ - AC_LANG_PUSH(C) + 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', 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 + LIBUSB_PKG_CONFIG_NAME='libusb' + ], [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 + LIBUSB_PKG_CONFIG_NAME='libusb-legacy' + ], [libusbok=no]) + fi + dnl set variables for further testing + usb_header='usb.h' + usb_lib_func='usb_bulk_write' + usb_lib_name='usb' + fi + AC_SUBST(LIBUSB_PKG_CONFIG_NAME) + 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. 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 + dnl library $usb_lib_name. + + 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" + 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) - AC_CHECK_HEADERS([usb.h], [], - [libusbok=no; AC_MSG_RESULT([USRP requires libusb. usb.h not found. See http://www.libusb.org])]) + 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 + dnl On Darwin, need to include the IOKit library. + + AC_LANG_PUSH(C) save_LIBS="$LIBS" + LIBS="" case "$host_os" in darwin*) - LIBS="$LIBS -lIOKit" + USB_LIBS="$USB_LIBS -lIOKit" + LIBS="$USB_LIBS" ;; *) ;; 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="$save_LIBS" - - AC_LANG_POP - ]) - fi - - if test x$libusbok = xyes; then - if test x$have_libusb1 = xyes; then - AC_DEFINE(HAVE_LIBUSB_1, [1], [Define if libusb-1.0 found]) - fi - AC_OUTPUT_COMMANDS([ - case "$CONFIG_OTHER" in - usrp*) - outfile=usrp/host/include/usrp/$CONFIG_OTHER - tmpfile=${outfile}T - dirname="sed s,^.*/,,g" - - echo creating $outfile - cat > $tmpfile << _EOF_ - /* -*- Mode: C++ -*- - * -------------------------------------------------------------------- - * DO NOT EDIT THIS FILE! It has been automatically generated - * from: configure.in and `echo $outfile|$dirname`.in - * on host: `(hostname || uname -n) 2>/dev/null | sed 1q` - * -------------------------------------------------------------------- - * - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -_EOF_ - echo "#ifndef _`echo $outfile | $dirname | tr a-z. A-Z_`_" >> $tmpfile - echo "#define _`echo $outfile | $dirname | tr a-z. A-Z_`_" >> $tmpfile - echo >> $tmpfile - - case "$CONFIG_OTHER" in - usrp_prims*) - echo '#include ' >> $tmpfile - echo '#include ' >> $tmpfile - echo >> $tmpfile - ;; - usrp_basic*) - echo '#include ' >> $tmpfile - echo '#include ' >> $tmpfile - echo '#include ' >> $tmpfile - echo '#include ' >> $tmpfile - echo '#include ' >> $tmpfile - echo '#include ' >> $tmpfile - echo >> $tmpfile + 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 + cygwin* | mingw*) + USB_LIBS="$LIBS" ;; - esac - - if test x$have_libusb1 = xno; then - echo 'struct usb_device;'>> $tmpfile - echo 'struct usb_dev_handle;'>> $tmpfile - echo 'struct usb_device_descriptor;' >> $tmpfile - echo 'typedef usb_device libusb_device;' >> $tmpfile - echo 'typedef usb_dev_handle libusb_device_handle;' >> $tmpfile - echo 'typedef usb_device_descriptor libusb_device_descriptor;' >> $tmpfile - echo >> $tmpfile - fi - - if test x$have_libusb1 = xyes; then - echo 'struct libusb_device;' >> $tmpfile - echo 'struct libusb_device_handle;' >> $tmpfile - echo 'struct libusb_device_descriptor;' >> $tmpfile - echo >> $tmpfile - fi - - # The ugly but portable cpp stuff comes from here - infile=usrp/host/include/usrp/`echo $outfile | sed 's,.*/,,g;s,\..*$,,g'`.h.in - sed '/^##.*$/d' $infile >> $tmpfile - mv ${tmpfile} ${outfile} - ;; + *) ;; esac - - ],[ - have_libusb1=$have_libusb1 - ]) - + 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 ])