Browse Source

hidapi: add HIDAPI, a library to access HID devices

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Paul Fertser 10 years ago
parent
commit
d045b02883
2 changed files with 99 additions and 0 deletions
  1. 77
    0
      libs/hidapi/Makefile
  2. 22
    0
      libs/hidapi/patches/010-add-iconv-linkage.patch

+ 77
- 0
libs/hidapi/Makefile View File

@@ -0,0 +1,77 @@
1
+#
2
+# Copyright (C) 2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=hidapi
11
+PKG_VERSION:=0.8.0-rc1
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE_PROTO:=git
15
+PKG_SOURCE_URL:=https://github.com/signal11/hidapi.git
16
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17
+PKG_SOURCE_VERSION:=hidapi-$(PKG_VERSION)
18
+PKG_SOURCE:=$(PKG_SOURCE_VERSION).tar.gz
19
+PKG_LICENSE:=BSD-3-Clause
20
+PKG_LICENSE_FILES:=LICENSE-bsd.txt
21
+
22
+PKG_MAINTAINER:=Paul Fertser <fercerpav@gmail.com>
23
+
24
+include $(INCLUDE_DIR)/package.mk
25
+include $(INCLUDE_DIR)/nls.mk
26
+
27
+define Package/hidapi
28
+  SECTION:=libs
29
+  CATEGORY:=Libraries
30
+  DEPENDS:=+libusb-1.0 +libiconv +librt
31
+  TITLE:=Library to talk to HID devices
32
+  URL:=http://www.signal11.us/oss/hidapi/
33
+endef
34
+
35
+define Package/hidapi/description
36
+HIDAPI is a multi-platform library which allows an application to interface
37
+with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and Mac
38
+OS X.  HIDAPI can be either built as a shared library (.so or .dll) or
39
+can be embedded directly into a target application by adding a single source
40
+file (per platform) and a single header.
41
+endef
42
+
43
+define Build/Configure
44
+endef
45
+
46
+MAKE_PATH=libusb
47
+MAKE_FLAGS+=-f Makefile.linux
48
+TARGET_CFLAGS+=$(FPIC)
49
+
50
+define Build/Compile
51
+	$(call Build/Compile/Default, libhidapi-libusb.so)
52
+	mv $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so \
53
+		$(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so.0
54
+	ln -s libhidapi-libusb.so.0 $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so
55
+	sed    's^@prefix@^/usr^; \
56
+		s^@exec_prefix@^/usr^; \
57
+		s^@libdir@^$$$${exec_prefix}/lib^; \
58
+		s^@includedir@^$$$${prefix}/include^' \
59
+		< $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc.in \
60
+		> $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc
61
+endef
62
+
63
+define Build/InstallDev
64
+	$(INSTALL_DIR) $(1)/usr/include/hidapi
65
+	$(CP) $(PKG_BUILD_DIR)/hidapi/hidapi.h $(1)/usr/include/hidapi/
66
+	$(INSTALL_DIR) $(1)/usr/lib
67
+	$(CP) $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so* $(1)/usr/lib/
68
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig/
69
+	$(CP) $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc $(1)/usr/lib/pkgconfig/
70
+endef
71
+
72
+define Package/hidapi/install
73
+	$(INSTALL_DIR) $(1)/usr/lib
74
+	$(CP) $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so* $(1)/usr/lib/
75
+endef
76
+
77
+$(eval $(call BuildPackage,hidapi))

+ 22
- 0
libs/hidapi/patches/010-add-iconv-linkage.patch View File

@@ -0,0 +1,22 @@
1
+Index: hidapi-0.8.0-rc1/libusb/Makefile.linux
2
+===================================================================
3
+--- hidapi-0.8.0-rc1.orig/libusb/Makefile.linux
4
++++ hidapi-0.8.0-rc1/libusb/Makefile.linux
5
+@@ -22,7 +22,7 @@ COBJS_LIBUSB = hid.o
6
+ COBJS = $(COBJS_LIBUSB)
7
+ CPPOBJS   = ../hidtest/hidtest.o
8
+ OBJS      = $(COBJS) $(CPPOBJS)
9
+-LIBS_USB  = `pkg-config libusb-1.0 --libs` -lrt -lpthread
10
++LIBS_USB  = `pkg-config libusb-1.0 --libs` -lrt -lpthread -liconv
11
+ LIBS      = $(LIBS_USB)
12
+ INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
13
+ 
14
+@@ -33,7 +33,7 @@ hidtest-libusb: $(COBJS_LIBUSB) $(CPPOBJ
15
+ 
16
+ # Shared Libs
17
+ libhidapi-libusb.so: $(COBJS_LIBUSB)
18
+-	$(CC) $(LDFLAGS) $(LIBS_USB) -shared -fpic -Wl,-soname,$@.0 $^ -o $@
19
++	$(CC) $(LDFLAGS) $^ $(LIBS_USB) -shared -fpic -Wl,-soname,$@.0 -o $@
20
+ 
21
+ # Objects
22
+ $(COBJS): %.o: %.c