aboutsummaryrefslogtreecommitdiffstats
path: root/m4/libusb.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/libusb.m4')
-rw-r--r--m4/libusb.m450
1 files changed, 50 insertions, 0 deletions
diff --git a/m4/libusb.m4 b/m4/libusb.m4
new file mode 100644
index 000000000..d11a9d954
--- /dev/null
+++ b/m4/libusb.m4
@@ -0,0 +1,50 @@
+dnl Check for libusb
+dnl Copyright (C) 2004 Free Software Foundation, Inc.
+dnl
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+dnl
+dnl Defines HAVE_LIBUSB to 1 if a working libusb setup is found, and sets
+dnl @LIBUSB@ to the necessary libraries. HAVE_USB_GET_BUSSES is set if
+dnl usb_get_busses() exists.
+
+AC_DEFUN([GNUPG_CHECK_LIBUSB],
+[
+ AC_ARG_WITH(libusb,
+ AC_HELP_STRING([--with-libusb=DIR],
+ [look for the libusb library in DIR]),
+ [_do_libusb=$withval],[_do_libusb=yes])
+
+ if test "$_do_libusb" != "no" ; then
+ if test -d "$withval" ; then
+ CPPFLAGS="${CPPFLAGS} -I$withval/include"
+ LDFLAGS="${LDFLAGS} -L$withval/lib"
+ fi
+
+ _libusb_save_libs=$LIBS
+ LIBS="$LIBS -lusb"
+
+ AC_MSG_CHECKING([whether libusb is present and sane])
+
+ AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <usb.h>],[
+usb_bulk_write(NULL,0,NULL,0,0);
+]),_found_libusb=yes,_found_libusb=no)
+
+ AC_MSG_RESULT([$_found_libusb])
+
+ if test $_found_libusb = yes ; then
+ AC_DEFINE(HAVE_LIBUSB,1,
+ [Define to 1 if you have a fully functional libusb library.])
+ AC_SUBST(LIBUSB,"-lusb")
+ AC_CHECK_FUNCS(usb_get_busses)
+ fi
+
+ LIBS=$_libusb_save_libs
+
+ unset _libusb_save_libs
+ unset _found_libusb
+ fi
+])dnl