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.5 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:=0.7.9
  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:=a13710ebff0a2d0e60e08442db192a4e891db89d535306d461b8a95ede7dbd90
  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. define Package/node-hid
  22. SUBMENU:=Node.js
  23. SECTION:=lang
  24. CATEGORY:=Languages
  25. TITLE:=Node.js package to access HID devices
  26. URL:=https://github.com/node-hid/node-hid
  27. DEPENDS:=+node +node-npm +libusb-1.0 +hidapi +libudev-fbsd
  28. endef
  29. define Package/node-hid/description
  30. Node.js package to access HID devices
  31. endef
  32. TAR_OPTIONS+= --strip-components 1
  33. TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
  34. NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
  35. TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
  36. TARGET_CFLAGS+=$(FPIC) -I$(STAGING_DIR)/usr/include/libusb-1.0
  37. define Build/Compile
  38. git init $(PKG_BUILD_DIR)
  39. $(MAKE_VARS) \
  40. $(MAKE_FLAGS) \
  41. npm_config_arch=$(NODEJS_CPU) \
  42. npm_config_target_arch=$(NODEJS_CPU) \
  43. npm_config_build_from_source=true \
  44. npm_config_nodedir=$(STAGING_DIR)/usr/ \
  45. npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
  46. npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
  47. npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM) \
  48. npm install -g $(PKG_BUILD_DIR)
  49. rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
  50. rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
  51. endef
  52. define Package/node-hid/install
  53. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
  54. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{package.json,*.md} \
  55. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  56. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{binding.gyp,*.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/node-hid/src/show-devices.js $(1)/usr/bin/hid-showdevices
  65. endef
  66. $(eval $(call BuildPackage,node-hid))