From: Martin Ling Date: Thu, 5 Dec 2013 20:18:32 +0000 (+0000) Subject: Make libudev optional. X-Git-Tag: libserialport-0.1.0~29 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=397d89de3acc260d6246a3bfa3b59cee53aafe31;p=libserialport.git Make libudev optional. --- diff --git a/configure.ac b/configure.ac index 50f8de4..b1e98b4 100644 --- a/configure.ac +++ b/configure.ac @@ -86,10 +86,15 @@ SP_PKGLIBS="" case $target_os in *linux*) - # On Linux libudev is currently a hard requirement. + # On Linux libudev is currently required for enumeration. + AC_ARG_WITH([libudev], + [AS_HELP_STRING([--with-libudev], + [use libudev for serial port enumeration @<:@default=check@:>@])], + [], [with_libudev=check]) + AS_IF([test "x$with_libudev" != xno], [ PKG_CHECK_MODULES([libudev], [libudev >= 0], [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS"; - SP_PKGLIBS="$SP_PKGLIBS libudev"]) + SP_PKGLIBS="$SP_PKGLIBS libudev"; AC_DEFINE(HAVE_LIBUDEV)])], []) ;; *darwin*) LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation" diff --git a/serialport.c b/serialport.c index 0276567..497ce7f 100644 --- a/serialport.c +++ b/serialport.c @@ -47,7 +47,9 @@ #include #endif #ifdef __linux__ +#ifdef HAVE_LIBUDEV #include "libudev.h" +#endif #include "linux/serial.h" #include "linux_termios.h" @@ -460,7 +462,7 @@ out_release: IOObjectRelease(iter); out_done: #endif -#ifdef __linux__ +#if defined(__linux__) && defined(HAVE_LIBUDEV) struct udev *ud; struct udev_enumerate *ud_enumerate; struct udev_list_entry *ud_list;