public inbox for buildroot@busybox.net
 help / color / mirror / Atom feed
From: Tomas Mudrunka <tomas.mudrunka@gmail.com>
To: buildroot@buildroot.org
Cc: tomas.mudrunka@gmail.com
Subject: [Buildroot] [PATCH 1/1] package/hidapi: add support for build without hidraw support when udev is not available
Date: Tue, 24 Mar 2026 14:00:37 +0100	[thread overview]
Message-ID: <20260324130037.1411867-1-tomas.mudrunka@gmail.com> (raw)

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

                 reply	other threads:[~2026-03-24 13:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260324130037.1411867-1-tomas.mudrunka@gmail.com \
    --to=tomas.mudrunka@gmail.com \
    --cc=buildroot@buildroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox