[RFC]xf86-input-evdev: use libsysdev as build-time fallback if libudev is missing
Isaac Dunham
ibid.ag at gmail.com
Mon Feb 2 17:35:50 PST 2015
On Mon, Feb 02, 2015 at 05:30:14PM -0800, Isaac Dunham wrote:
> Hello,
> Having grown tired of hearing complaints about udev dependencies, I
> wrote a library that does a very small subset of what libudev does with
> a slightly more concise API. It does not care how /dev is managed.
> The code may be found at:
> github.com/idunham/libsysdev.git
>
> I have ported xf86-input-evdev to use said library; the attached
> patch will allow building with it as a compile-time fallback.
> Does anyone have comments on this patch?
>
> I'm aware that it would be possible to share much of the code by using
> more #ifdef USE_UDEV; if that is better, I can adjust this.
>
> Please note: I am *not* interested in arguing about udev, whether pro
> or con. I'm just asking for a review of this patch.
Unfortuntely, I forgot the patch. My apologies.
Thanks,
Isaac Dunham
-------------- next part --------------
diff --git a/configure.ac b/configure.ac
index 46f3dc7..6a56149 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,7 +45,19 @@ XORG_DEFAULT_OPTIONS
# Obtain compiler/linker options from server and required extensions
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto inputproto)
-PKG_CHECK_MODULES(UDEV, libudev)
+PKG_CHECK_MODULES(UDEV, libudev, HAVE_UDEV="yes", HAVE_UDEV="no")
+if test "x$HAVE_UDEV" = xyes; then
+ AC_DEFINE(USE_UDEV, 1, [libudev available])
+else
+ #fallback to libsysdev
+ PKG_CHECK_MODULES(LIBSYSDEV, libsysdev, HAVE_SYSDEV="yes", HAVE_SYSDEV="no")
+ if test "x$HAVE_SYSDEV" = xyes; then
+ AC_DEFINE(USE_SYSDEV, 1, [libsysdev available])
+ else
+ echo "You must have either libudev or libsysdev installed!"
+ exit 1
+ fi
+fi
PKG_CHECK_MODULES(XI22, [inputproto >= 2.1.99.3] [xorg-server >= 1.11.99.901], HAVE_XI22="yes", HAVE_XI22="no")
PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
diff --git a/src/Makefile.am b/src/Makefile.am
index 5e0c3b3..b8083a9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,7 +30,7 @@ AM_CPPFLAGS =-I$(top_srcdir)/include $(LIBEVDEV_CFLAGS)
@DRIVER_NAME at _drv_la_LTLIBRARIES = @DRIVER_NAME at _drv.la
@DRIVER_NAME at _drv_la_LDFLAGS = -module -avoid-version
- at DRIVER_NAME@_drv_la_LIBADD = $(MTDEV_LIBS) $(UDEV_LIBS) $(LIBEVDEV_LIBS)
+ at DRIVER_NAME@_drv_la_LIBADD = $(MTDEV_LIBS) $(UDEV_LIBS) $(LIBEVDEV_LIBS) $(LIBSYSDEV_LIBS)
@DRIVER_NAME at _drv_ladir = @inputdir@
@DRIVER_NAME at _drv_la_SOURCES = @DRIVER_NAME at .c \
diff --git a/src/evdev.c b/src/evdev.c
index 2d99f07..965c885 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -39,11 +39,17 @@
#include <linux/version.h>
#include <sys/stat.h>
-#include <libudev.h>
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef USE_UDEV
+#include <libudev.h>
+#elif defined(USE_SYSDEV)
+#include <libsysdev/sysdev.h>
+#endif
+
#include <xf86.h>
#include <xf86Xinput.h>
#include <exevents.h>
@@ -231,6 +237,7 @@ EvdevIsDuplicate(InputInfoPtr pInfo)
return FALSE;
}
+#ifdef USE_UDEV
static BOOL
EvdevDeviceIsVirtual(const char* devicenode)
{
@@ -265,6 +272,31 @@ out:
udev_unref(udev);
return rc;
}
+#elif defined(USE_SYSDEV)
+static BOOL
+EvdevDeviceIsVirtual(const char* devicenode)
+{
+ struct stat st;
+ int rc = FALSE;
+ char *syspath;
+
+ if (stat(devicenode, &st) == -1)
+ goto out;
+
+ syspath = sysdev_getsyspath(major(st.st_rdev), minor(st.st_rdev),
+ S_ISCHR(st.st_mode));
+
+ if (syspath) {
+ if (strstr(syspath, "LNXSYSTM"))
+ rc = TRUE;
+
+ free(syspath);
+ }
+out:
+ return rc;
+}
+#endif
+
#ifndef HAVE_SMOOTH_SCROLLING
static int wheel_up_button = 4;
More information about the xorg-devel
mailing list