From 42c025634f2efe8989a1c1321cf65274f1093f36 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 8 Dec 2011 19:25:06 +0100 Subject: [PATCH] cec: make libudev optional. if libudev is not available on linux, adapter autodetection will also not be available --- configure.ac | 11 +++++++++-- src/lib/AdapterDetection.cpp | 18 ++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index e961c1b..22b6343 100644 --- a/configure.ac +++ b/configure.ac @@ -4,16 +4,23 @@ AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AC_PROG_CXX AC_PROG_LIBTOOL +has_libudev="yes" case "${host}" in *-*-linux*) - AC_SEARCH_LIBS([udev_new], [udev],, AC_MSG_ERROR("required library 'udev' is missing")) - REQUIRES="udev" + PKG_CHECK_MODULES([UDEV],[libudev],,[has_libudev="no";AC_MSG_WARN("library 'udev' is missing - adapter detection will not be available")]) ;; *-apple-darwin*) + has_libudev="no"; LIBS+="-framework CoreVideo -framework IOKit" ;; esac +if test "x$has_libudev" != "xno"; then + INCLUDES="$INCLUDES $UDEV_CFLAGS";LIBS="$LIBS $UDEV_LIBS" + AC_DEFINE([HAVE_LIBUDEV],[1],["Define to 1 if libudev is installed"]) + REQUIRES="udev" +fi + AC_SEARCH_LIBS([pthread_create],[pthread],, AC_MSG_ERROR("required library 'pthread' is missing")) libs_pre_dl=$LIBS diff --git a/src/lib/AdapterDetection.cpp b/src/lib/AdapterDetection.cpp index 98c3a0e..b304e43 100644 --- a/src/lib/AdapterDetection.cpp +++ b/src/lib/AdapterDetection.cpp @@ -43,16 +43,15 @@ #include #include #include - -#elif !defined(__WINDOWS__) -#include -#include -#include -#else +#elif defined(__WINDOWS__) #include // the virtual COM port only shows up when requesting devices with the raw device guid! static GUID USB_RAW_GUID = { 0xA5DCBF10, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } }; +#elif defined(HAVE_LIBUDEV) +#include +#include +#include #endif #define CEC_VID 0x2548 @@ -61,7 +60,7 @@ static GUID USB_RAW_GUID = { 0xA5DCBF10, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0x using namespace CEC; using namespace std; -#if !defined(__WINDOWS__) +#if defined(HAVE_LIBUDEV) bool TranslateComPort(CStdString &strString) { CStdString strTmp(strString); @@ -180,8 +179,7 @@ uint8_t CAdapterDetection::FindAdapters(cec_adapter *deviceList, uint8_t iBufSiz } IOObjectRelease(serialPortIterator); } - -#elif !defined(__WINDOWS__) +#elif defined(HAVE_LIBUDEV) struct udev *udev; if (!(udev = udev_new())) return -1; @@ -229,7 +227,7 @@ uint8_t CAdapterDetection::FindAdapters(cec_adapter *deviceList, uint8_t iBufSiz udev_enumerate_unref(enumerate); udev_unref(udev); -#else +#elif defined(__WINDOWS__) HDEVINFO hDevHandle; DWORD required = 0, iMemberIndex = 0; int nBufferSize = 0; -- 2.34.1