Maxing the x-axis of the time domain plot represent the actual time of the samples...
[debian/gnuradio] / config / usrp_libusb.m4
1 dnl Copyright 2003,2008,2009 Free Software Foundation, Inc.
2 dnl 
3 dnl This file is part of GNU Radio
4 dnl 
5 dnl GNU Radio is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3, or (at your option)
8 dnl any later version.
9 dnl 
10 dnl GNU Radio is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl 
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with GNU Radio; see the file COPYING.  If not, write to
17 dnl the Free Software Foundation, Inc., 51 Franklin Street,
18 dnl Boston, MA 02110-1301, USA.
19
20 # $1 is $req_libusb1:
21 #   yes : check libusb-1.0
22 #   no  : check libusb-0.12
23 #   ""  : check libusb-0.12
24
25
26 AC_DEFUN([USRP_LIBUSB], [
27   dnl Use PKGCONFIG to check for packages first, then check to
28   dnl make sure the USB_* variables work (whether from PKGCONFIG
29   dnl or overridden by the user)
30
31   libusbok=no
32   have_libusb1=no
33   LIBUSB_PKG_CONFIG_NAME=''
34   if test x$1 = xyes; then
35     PKG_CHECK_MODULES(USB, libusb-1.0, [
36       libusbok=yes
37       have_libusb1=yes
38       usb_header='libusb-1.0/libusb.h'
39       usb_lib_func='libusb_bulk_transfer'
40       usb_lib_name='usb-1.0'
41       LIBUSB_PKG_CONFIG_NAME='libusb-1.0'
42     ])
43   else
44     dnl not using libusb1 (for now); see if legacy version is found.
45     dnl it might be installed under the name either 'libusb' or
46     dnl 'libusb-legacy', or just available via the
47     dnl user's shell environment
48
49     dnl see if the pkgconfig module 'libusb' is available
50     PKG_CHECK_MODULES(USB, libusb, [
51       libusbok=yes
52       LIBUSB_PKG_CONFIG_NAME='libusb'
53       ], [libusbok=no])
54     dnl PKG_CHECK_MODULES does not work correctly when embedded
55     if test $libusbok = no; then
56       dnl if not, see if the pkgconfig module 'libusb-legacy' is available
57       PKG_CHECK_MODULES(USB, [libusb-legacy], [
58         libusbok=yes
59         LIBUSB_PKG_CONFIG_NAME='libusb-legacy'
60         ], [libusbok=no])
61     fi
62     dnl set variables for further testing
63     usb_header='usb.h'
64     usb_lib_func='usb_bulk_write'
65     usb_lib_name='usb'
66   fi
67   AC_SUBST(LIBUSB_PKG_CONFIG_NAME)
68   if test x$1 != xyes || test $have_libusb1 = yes; then
69     dnl Either (1) libusb1 was specified and found; or
70     dnl (2) libusb1 was not specified. Restart checking.
71     libusbok=yes
72
73     dnl Verify that $usb_header is a valid header, and if so,
74     dnl then verify that $usb_lib_func can be found in the
75     dnl library $usb_lib_name.
76
77     dnl If PKGCONFIG found variable USB_INCLUDEDIR, and it is
78     dnl not empty, use it for checking for $usb_header.
79     dnl Otherwise, maybe the user's shell environment is already
80     dnl configured to find this header.
81
82     AC_LANG_PUSH(C)
83     save_CPPFLAGS="$CPPFLAGS"
84     if test x$USB_INCLUDEDIR != x; then
85       USB_INCLUDES="-I$USB_INCLUDEDIR"
86       CPPFLAGS="$CPPFLAGS $USB_INCLUDES"
87       AC_SUBST(USB_INCLUDES)
88     fi
89     AC_CHECK_HEADERS([$usb_header], [], [libusbok=no])
90     CPPFLAGS="$save_CPPFLAGS"
91     AC_LANG_POP(C)
92
93     if test $libusbok = no; then
94       AC_MSG_RESULT([USRP requires libusb header '$usb_header' which was not found or was not usable. See http://www.libusb.org])
95     else
96
97       dnl found the header; now make sure the library is OK
98       dnl On Darwin, need to include the IOKit library.     
99
100       AC_LANG_PUSH(C)
101       save_LIBS="$LIBS"
102       LIBS=""
103       case "$host_os" in
104         darwin*)
105           USB_LIBS="$USB_LIBS -lIOKit"
106           LIBS="$USB_LIBS"
107           ;;
108         *) ;;
109       esac
110       AC_CHECK_LIB([$usb_lib_name], [$usb_lib_func], [], [
111         libusbok=no
112         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])
113       ])
114       case "$host_os" in
115         cygwin* | mingw*)
116           USB_LIBS="$LIBS"
117           ;;
118         *) ;;
119       esac
120       LIBS="$save_LIBS"
121       AC_LANG_POP(C)
122     fi
123   fi
124   if test $libusbok = yes; then
125     AC_SUBST(USB_LIBS)
126     ifelse([$2], , :, [$2])
127   else
128     USB_INCLUDES=
129     USB_LIBS=
130     ifelse([$3], , :, [$3])
131   fi
132 ])