2
dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4
dnl This file is free software, distributed under the terms of the GNU
5
dnl General Public License. As a special exception to the GNU General
6
dnl Public License, this file may be distributed as part of a program
7
dnl that contains a configuration script generated by Autoconf, under
8
dnl the same distribution terms as the rest of that program.
10
dnl Defines HAVE_LIBUSB to 1 if a working libusb setup is found, and sets
11
dnl @LIBUSB@ to the necessary libraries. HAVE_USB_GET_BUSSES is set if
12
dnl usb_get_busses() exists.
14
AC_DEFUN([GNUPG_CHECK_LIBUSB],
17
AC_HELP_STRING([--with-libusb=DIR],
18
[look for the libusb library in DIR]),
19
[_do_libusb=$withval],[_do_libusb=yes])
21
if test "$_do_libusb" != "no" ; then
22
if test -d "$withval" ; then
23
CPPFLAGS="${CPPFLAGS} -I$withval/include"
24
LDFLAGS="${LDFLAGS} -L$withval/lib"
25
AC_PATH_PROG([_usb_config],["$_do_libusb/bin/libusb-config"])
27
AC_PATH_PROG([_usb_config],[libusb-config])
30
_libusb_save_libs=$LIBS
31
_libusb_save_cflags=$CFLAGS
33
if test x$_usb_config != "x" ; then
34
_libusb_try_libs=`$LIBS $_usb_config --libs`
35
_libusb_try_cflags=`$LIBS $_usb_config --cflags`
37
_libusb_try_libs="-lusb"
41
LIBS="$LIBS $_libusb_try_libs"
42
CFLAGS="$CFLAGS $_libusb_try_cflags"
44
AC_MSG_CHECKING([whether libusb is present and sane])
46
AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <usb.h>],[
47
usb_bulk_write(NULL,0,NULL,0,0);
48
]),_found_libusb=yes,_found_libusb=no)
50
AC_MSG_RESULT([$_found_libusb])
52
if test $_found_libusb = yes ; then
53
AC_DEFINE(HAVE_LIBUSB,1,
54
[Define to 1 if you have a fully functional libusb library.])
55
AC_SUBST(LIBUSB_CPPFLAGS,$_libusb_try_cflags)
56
AC_SUBST(LIBUSB,$_libusb_try_libs)
57
AC_CHECK_FUNCS(usb_get_busses)
60
LIBS=$_libusb_save_libs
61
CFLAGS=$_libusb_save_cflags
63
unset _libusb_save_libs
64
unset _libusb_save_cflags
65
unset _libusb_try_libs
66
unset _libusb_try_cflags