configure.ac: add libusb/libusbx support (for xpp)

* Use pkg-config
* For tight control have: --with-libusbx, --with-libusb
  - For now, we choose libusb (AKA libusb-0.1)
  - After committing support for libusbx (AKA libusb-1.0)
    we'll change the default.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
Oron Peled 2014-12-15 06:40:14 -05:00 committed by Tzafrir Cohen
parent 01faf597d6
commit 5ee15a2337
2 changed files with 75 additions and 5 deletions

View File

@ -182,6 +182,66 @@ AM_CONDITIONAL([PBX_PCAP], [test "$PBX_PCAP" = "1" -a "$DAHDI_TXMIRROR" = "1"])
AC_CHECK_FUNCS([semtimedop]) AC_CHECK_FUNCS([semtimedop])
# What the user asked for? libusb/libusbx
AC_ARG_WITH([libusbx],
[AS_HELP_STRING([--without-libusbx], [Disable libusbx @<:@default=check@:>@])],
[],
[with_libusbx=check])
AC_ARG_WITH([libusb],
[AS_HELP_STRING([--without-libusb], [Disable libusb-0.1 @<:@default=check@:>@])],
[],
[with_libusb=check])
# LIBUSBX tests
have_libusbx=
AS_IF([test "$with_libusbx" = "yes"],
[PKG_CHECK_MODULES([LIBUSBX], [libusb-1.0],
[AC_CHECK_LIB([usb-1.0], [libusb_error_name],
[
have_libusbx="yes"
AC_SUBST([PKG_CONFIG_LIBUSB], [libusb-1.0])
AC_DEFINE([HAVE_LIBUSBX], [1], [Define to 1 if you have <libusb.h>.])
AC_SUBST([PBX_USB], [1])
], [
if test "$with_libusbx" != "yes"; then
AC_MSG_NOTICE([Ignoring old libusb-1.0, trying fallback to old libusb])
fi
])
], [:])
], [])
AS_IF([test "$with_libusbx" = "yes" -a "$have_libusbx" = ""],
[AC_MSG_ERROR([No libusbx found (--with-libusbx was given)])])
# LIBUSB tests
have_libusb=
AS_IF([test "$with_libusb" != "no"],
[AS_IF([test "$have_libusbx" != ""],
[
AS_IF([test "$with_libusbx" = "check"], [
AC_MSG_NOTICE([Skipping LIBUSB tests (have good LIBUSBX)])
])
], [
PKG_CHECK_MODULES([LIBUSB], [libusb],
[
have_libusb="yes"
AC_SUBST([PKG_CONFIG_LIBUSB], [libusb])
AC_SUBST([PBX_USB], [1])
]
[AC_DEFINE([HAVE_LIBUSB], [1], [Define to 1 if you have <usb.h>.])],
[:]
)
])
], [])
AS_IF([test "$with_libusb" = "yes" -a "$have_libusb" = ""],
[AC_MSG_ERROR([No libusb found (--with-libusb was given)])])
AM_CONDITIONAL([LIBUSBX], [test "$have_libusbx" != ""])
AM_CONDITIONAL([LIBUSB], [test "$have_libusb" != ""])
AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
PBX_HDLC=0 PBX_HDLC=0
AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h]) AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
AC_COMPILE_IFELSE( AC_COMPILE_IFELSE(
@ -296,8 +356,6 @@ fi
AC_SUBST(PPPD_VERSION) AC_SUBST(PPPD_VERSION)
AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
# Taken from octasic-helper # Taken from octasic-helper
AC_SUBST([USE_OCTASIC], [yes]) AC_SUBST([USE_OCTASIC], [yes])
AM_CONDITIONAL([USE_OCTASIC], [test "$USE_OCTASIC" = 'yes']) AM_CONDITIONAL([USE_OCTASIC], [test "$USE_OCTASIC" = 'yes'])

View File

@ -66,6 +66,18 @@ if PBX_USB
SUBDIRS += oct612x SUBDIRS += oct612x
if LIBUSBX
USB_CFLAGS = $(LIBUSBX_CFLAGS)
USB_LIBS = $(LIBUSBX_LIBS)
USB_NAME = libusbx
else
if LIBUSB
USB_CFLAGS = $(LIBUSB_CFLAGS)
USB_LIBS = $(LIBUSB_LIBS)
USB_NAME = libusb
endif
endif
noinst_LTLIBRARIES = libastribank.la libecholoader.la libhexfile.la noinst_LTLIBRARIES = libastribank.la libecholoader.la libhexfile.la
libastribank_la_SOURCES = \ libastribank_la_SOURCES = \
@ -115,7 +127,7 @@ test_parse_LDADD = libhexfile.la
astribank_tool_SOURCES = astribank_tool.c astribank_tool_SOURCES = astribank_tool.c
astribank_tool_CFLAGS = $(GLOBAL_CFLAGS) astribank_tool_CFLAGS = $(GLOBAL_CFLAGS)
astribank_tool_LDFLAGS = $(USB_LIB) astribank_tool_LDFLAGS = $(USB_LIBS)
astribank_tool_LDADD = libastribank.la astribank_tool_LDADD = libastribank.la
astribank_hexload_SOURCES = \ astribank_hexload_SOURCES = \
@ -125,7 +137,7 @@ astribank_hexload_SOURCES = \
# #
astribank_hexload_CFLAGS = $(GLOBAL_CFLAGS) $(OCTASIC_CFLAGS) astribank_hexload_CFLAGS = $(GLOBAL_CFLAGS) $(OCTASIC_CFLAGS)
astribank_hexload_LDFLAGS = $(USB_LIB) astribank_hexload_LDFLAGS = $(USB_LIBS)
astribank_hexload_LDADD = \ astribank_hexload_LDADD = \
libhexfile.la \ libhexfile.la \
libastribank.la \ libastribank.la \
@ -140,7 +152,7 @@ astribank_allow_SOURCES = \
# #
astribank_allow_CFLAGS = $(GLOBAL_CFLAGS) astribank_allow_CFLAGS = $(GLOBAL_CFLAGS)
astribank_allow_LDFLAGS = $(USB_LIB) astribank_allow_LDFLAGS = $(USB_LIBS)
astribank_allow_LDADD = libastribank.la astribank_allow_LDADD = libastribank.la
man_pages = \ man_pages = \