libusb: require pkg-config support

An alternative approach to show how much cleaner the pure pkg-config
way is.

This changes the discovery procedures for libusb-1.0 and libusb-0.1,
making them depend on pkg-config being properly installed and
configured, including the necessary build host configuration for the
cross-builds (see
http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html)

It should make it possible to compile OpenOCD without changes and
extra effort on GNU/Linux, FreeBSD users would need to supply a .pc
file for their libusb implementation or add LIBUSB1_LIBS and
LIBUSB1_CFLAGS to the configure environment.

Change-Id: I826e378dd1e0d101a549a573b2c63212a7e00b64
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1467
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
Paul Fertser
2013-09-11 23:07:59 +02:00
committed by Andreas Fritiofson
parent 10df176b0f
commit 191a5736c2
12 changed files with 46 additions and 19 deletions
+7 -8
View File
@@ -19,6 +19,7 @@ AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_PROG_RANLIB
PKG_PROG_PKG_CONFIG([0.23])
dnl disable checks for C++, Fortran and GNU Java Compiler
m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
@@ -1175,10 +1176,10 @@ fi
# check for libusb library if necessary
use_libusb1=no
if test $need_usb = yes -o $need_usb_ng = yes; then
AC_CHECK_HEADER([libusb-1.0/libusb.h], [
AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
use_libusb1=yes
AC_SEARCH_LIBS([libusb_error_name], [usb-1.0],
AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
[AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
[AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
], [
@@ -1193,11 +1194,9 @@ fi
use_libusb0=no
if test $need_usb0 = yes; then
AC_CHECK_HEADERS([usb.h], [
use_libusb0=yes
], [
AC_MSG_ERROR([libusb-0.1 is required to build some OpenOCD driver(s)])
])
PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [
AC_MSG_ERROR([libusb-0.1 is required to build some OpenOCD driver(s)])
])
fi
AM_CONDITIONAL([RELEASE], [test $build_release = yes])