From 07a8c956108499157582c8ef2e8c5df7fb4630a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Sat, 19 Nov 2005 14:41:37 +0000 Subject: [PATCH] make libusb usage optional git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2053 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- configure.ac | 5 +++-- src/usb_port.c | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 714b2d6be..d9eecf7dd 100644 --- a/configure.ac +++ b/configure.ac @@ -347,7 +347,7 @@ if test "${cf_with_cxx}" = "yes" ; then AC_MSG_RESULT($cf_with_gnuradio) if test "${cf_with_gnuradio}" = "yes" ; then - PKG_CHECK_MODULES(GNURADIO, gnuradio >= 0.9, []) + PKG_CHECK_MODULES(GNURADIO, gnuradio >= 0.9) dnl check for pthreads ACX_PTHREAD([BACKEND_LIST="$BACKEND_LIST gnuradio"], [AC_MSG_FAILURE([gnuradio backend requires POSIX threads. pthreads not found.])]) @@ -372,7 +372,8 @@ AC_SUBST(GNURADIO_CFLAGS) AC_SUBST(GNURADIO_LIBS) -PKG_CHECK_MODULES(LIBUSB, libusb >= 0.1, []) +PKG_CHECK_MODULES(LIBUSB, libusb >= 0.1, , + [AC_MSG_WARN([libusb pkg-config not found, USB backends will be disabled])]) AC_CHECK_HEADERS([usb.h]) AC_MSG_CHECKING(whether to build USB backends) if test x"${LIBUSB_LIBS}" = x; then diff --git a/src/usb_port.c b/src/usb_port.c index 8c39d9fa2..633cfc4fb 100644 --- a/src/usb_port.c +++ b/src/usb_port.c @@ -2,7 +2,7 @@ * Hamlib Interface - parallel communication low-level support * Copyright (c) 2000-2005 by Stephane Fillod * - * $Id: usb_port.c,v 1.1 2005-11-01 23:02:02 fillods Exp $ + * $Id: usb_port.c,v 1.2 2005-11-19 14:41:37 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -24,17 +24,18 @@ #include "config.h" #endif +#include + /* * Compile only this model if libusb is available */ -#ifdef HAVE_USB_H +#if defined(HAVE_LIBUSB) && defined(HAVE_USB_H) #include #include /* Standard input/output definitions */ #include /* String function definitions */ #include /* UNIX standard function definitions */ -#include #include #include #include @@ -126,4 +127,16 @@ int usb_port_close(hamlib_port_t *port) return usb_close (udh) == 0 ? RIG_OK : -RIG_EIO; } -#endif /* HAVE_LIBUSB */ +#else + +int usb_port_open(hamlib_port_t *port) +{ + return -RIG_ENAVAIL; +} + +int usb_port_close(hamlib_port_t *port) +{ + return -RIG_ENAVAIL; +} + +#endif /* defined(HAVE_LIBUSB) && defined(HAVE_USB_H) */