public inbox for buildroot@busybox.net
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/hidapi: add support for build without hidraw support when udev is not available
@ 2026-03-24 13:00 Tomas Mudrunka
  0 siblings, 0 replies; only message in thread
From: Tomas Mudrunka @ 2026-03-24 13:00 UTC (permalink / raw)
  To: buildroot; +Cc: tomas.mudrunka

This allows use of libhidapi on tiny systems without udev

Signed-off-by: Tomas Mudrunka <tomas.mudrunka@gmail.com>
---
 package/hidapi/Config.in | 28 ++++++++++++++++++++++++----
 package/hidapi/hidapi.mk | 20 +++++++++++++++-----
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/package/hidapi/Config.in b/package/hidapi/Config.in
index 1d3c86b677..efacd1aa26 100644
--- a/package/hidapi/Config.in
+++ b/package/hidapi/Config.in
@@ -1,10 +1,8 @@
 config BR2_PACKAGE_HIDAPI
 	bool "hidapi"
-	depends on BR2_PACKAGE_HAS_UDEV
 	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # libusb
 	select BR2_PACKAGE_LIBUSB
-	select BR2_PACKAGE_LIBGUDEV
 	select BR2_PACKAGE_LIBICONV if !BR2_ENABLE_LOCALE
 	# runtime UTF conversion support
 	select BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY if BR2_TOOLCHAIN_USES_GLIBC
@@ -13,9 +11,31 @@ config BR2_PACKAGE_HIDAPI
 	  to interface with USB and Bluetooth HID-Class devices on
 	  Windows, Linux, and Mac OS X.
 
+	  On Linux you can disable the hidraw backend (see below) to
+	  build only libhidapi-libusb, which does not require udev.
+
 	  http://github.com/libusb/hidapi/
 
-comment "hidapi needs udev /dev management and a toolchain w/ NPTL, gcc >= 4.9"
+if BR2_PACKAGE_HIDAPI
+
+comment "hidapi hidraw backend unavailable (no udev - enable eudev or systemd)"
+	depends on !BR2_PACKAGE_HAS_UDEV
+
+config BR2_PACKAGE_HIDAPI_HIDRAW
+	bool "hidraw backend"
+	default y if BR2_PACKAGE_HAS_UDEV
+	depends on BR2_PACKAGE_HAS_UDEV
+	help
+	  Build the Linux hidraw implementation (libhidapi-hidraw). This
+	  requires libudev from a udev provider (eudev or systemd).
+
+	  Say 'n' here to build only the libusb backend
+	  (libhidapi-libusb), which is enough for applications that
+	  link against hidapi-libusb and allows using HIDAPI on systems
+	  without udev.
+
+endif
+
+comment "hidapi needs a toolchain w/ NPTL and gcc >= 4.9"
 	depends on !BR2_TOOLCHAIN_HAS_THREADS_NPTL || \
-		!BR2_PACKAGE_HAS_UDEV || \
 		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
diff --git a/package/hidapi/hidapi.mk b/package/hidapi/hidapi.mk
index c4daf934ee..11b622a8ad 100644
--- a/package/hidapi/hidapi.mk
+++ b/package/hidapi/hidapi.mk
@@ -7,16 +7,26 @@
 HIDAPI_VERSION = 0.15.0
 HIDAPI_SITE = $(call github,libusb,hidapi,hidapi-$(HIDAPI_VERSION))
 HIDAPI_INSTALL_STAGING = YES
-# No configure provided, so we need to autoreconf.
-HIDAPI_AUTORECONF = YES
+HIDAPI_SUPPORTS_IN_SOURCE_BUILD = NO
 HIDAPI_LICENSE = GPL-3.0 or BSD-3-Clause or HIDAPI license
 HIDAPI_LICENSE_FILES = LICENSE.txt LICENSE-gpl3.txt LICENSE-bsd.txt LICENSE-orig.txt
 
-HIDAPI_DEPENDENCIES = libusb libgudev
+HIDAPI_DEPENDENCIES = libusb
+
+HIDAPI_CONF_OPTS = \
+	-DHIDAPI_WITH_LIBUSB=ON \
+	-DHIDAPI_WITH_TESTS=OFF \
+	-DHIDAPI_BUILD_HIDTEST=OFF
+
+ifeq ($(BR2_PACKAGE_HIDAPI_HIDRAW),y)
+HIDAPI_CONF_OPTS += -DHIDAPI_WITH_HIDRAW=ON
+HIDAPI_DEPENDENCIES += udev
+else
+HIDAPI_CONF_OPTS += -DHIDAPI_WITH_HIDRAW=OFF
+endif
 
 ifeq ($(BR2_PACKAGE_LIBICONV),y)
 HIDAPI_DEPENDENCIES += libiconv
-HIDAPI_CONF_ENV += LIBS="-liconv"
 endif
 
-$(eval $(autotools-package))
+$(eval $(cmake-package))
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-24 13:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 13:00 [Buildroot] [PATCH 1/1] package/hidapi: add support for build without hidraw support when udev is not available Tomas Mudrunka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox