File: libusb.m4

package info (click to toggle)
gnupg 1.4.18-7+deb8u5
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 34,476 kB
  • sloc: ansic: 127,074; sh: 7,535; asm: 4,610; makefile: 1,186; yacc: 291; perl: 196; pascal: 72; sed: 16
file content (69 lines) | stat: -rw-r--r-- 2,209 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
dnl Check for libusb
dnl Copyright (C) 2004, 2005 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"
        AC_PATH_PROG([_usb_config],["$_do_libusb/bin/libusb-config"])
     else
        AC_PATH_PROG([_usb_config],[libusb-config])
     fi

     _libusb_save_libs=$LIBS
     _libusb_save_cflags=$CFLAGS

     if test x$_usb_config != "x" ; then
        _libusb_try_libs=`$LIBS $_usb_config --libs`
        _libusb_try_cflags=`$LIBS $_usb_config --cflags`
     else
        _libusb_try_libs="-lusb"
        _libusb_try_cflags=""
     fi

     LIBS="$LIBS $_libusb_try_libs"
     CFLAGS="$CFLAGS $_libusb_try_cflags"

     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_CPPFLAGS,$_libusb_try_cflags)
        AC_SUBST(LIBUSB,$_libusb_try_libs)
        AC_CHECK_FUNCS(usb_get_busses)
     fi

     LIBS=$_libusb_save_libs
     CFLAGS=$_libusb_save_cflags

     unset _libusb_save_libs
     unset _libusb_save_cflags
     unset _libusb_try_libs
     unset _libusb_try_cflags
     unset _found_libusb
  fi
])dnl