You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.4 KiB

  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. include $(TOPDIR)/rules.mk
  8. PKG_NPM_NAME:=node-hid
  9. PKG_NAME:=$(PKG_NPM_NAME)
  10. PKG_VERSION:=2.1.1
  11. PKG_RELEASE:=1
  12. PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
  13. PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
  14. PKG_HASH:=6c1f05935215feed4e8d2f4aecf31abbad8fa783d252b0bd6041ed2f2e96e9ba
  15. PKG_BUILD_DEPENDS:=node/host
  16. PKG_USE_MIPS16:=0
  17. PKG_MAINTAINER:=Hirokazu MORIKAWA <morikw2@gmail.com>
  18. PKG_LICENSE:=MIT or X11
  19. PKG_LICENSE_FILES:=
  20. include $(INCLUDE_DIR)/package.mk
  21. include $(INCLUDE_DIR)/nls.mk
  22. define Package/node-hid
  23. SUBMENU:=Node.js
  24. SECTION:=lang
  25. CATEGORY:=Languages
  26. TITLE:=Node.js package to access HID devices
  27. URL:=https://www.npmjs.com/package/node-hid
  28. DEPENDS:=+node +node-npm +libusb-1.0 +libudev $(ICONV_DEPENDS)
  29. endef
  30. define Package/node-hid/description
  31. Node.js package to access HID devices
  32. endef
  33. TAR_OPTIONS+= --strip-components 1
  34. TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
  35. NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
  36. TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
  37. TARGET_CFLAGS+=$(FPIC) -I$(STAGING_DIR)/usr/include/libusb-1.0
  38. TARGET_LDFLAGS+=$(if $(ICONV_FULL),-liconv)
  39. define Build/Compile
  40. GYP_DEFINES='driver="hidraw"' \
  41. $(MAKE_VARS) \
  42. $(MAKE_FLAGS) \
  43. npm_config_arch=$(NODEJS_CPU) \
  44. npm_config_target_arch=$(NODEJS_CPU) \
  45. npm_config_build_from_source=true \
  46. npm_config_nodedir=$(STAGING_DIR)/usr/ \
  47. npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
  48. npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
  49. npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM) \
  50. npm install -g $(PKG_BUILD_DIR)
  51. rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
  52. rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
  53. endef
  54. define Package/node-hid/install
  55. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
  56. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{package.json,*.md,*.js} \
  57. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  58. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{node_modules,src} \
  59. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  60. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)/build/Release
  61. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/build/Release/HID*.node \
  62. $(1)/usr/lib/node/$(PKG_NPM_NAME)/build/Release/
  63. $(INSTALL_DIR) $(1)/usr/bin
  64. $(LN) ../lib/node/$(PKG_NPM_NAME)/src/show-devices.js $(1)/usr/bin/hid-showdevices
  65. endef
  66. $(eval $(call BuildPackage,node-hid))